2024-06-22 17:41:17 +08:00
|
|
|
from typing import Optional
|
|
|
|
|
2024-07-07 12:18:15 +08:00
|
|
|
from pydantic import Field, NonNegativeInt
|
|
|
|
from pydantic_settings import BaseSettings
|
2024-06-22 17:41:17 +08:00
|
|
|
|
|
|
|
|
2024-07-07 12:18:15 +08:00
|
|
|
class HostedOpenAiConfig(BaseSettings):
|
2024-06-22 17:41:17 +08:00
|
|
|
"""
|
|
|
|
Hosted OpenAI service config
|
|
|
|
"""
|
|
|
|
|
|
|
|
HOSTED_OPENAI_API_KEY: Optional[str] = Field(
|
2024-08-23 23:46:01 +08:00
|
|
|
description="",
|
2024-06-22 17:41:17 +08:00
|
|
|
default=None,
|
|
|
|
)
|
|
|
|
|
|
|
|
HOSTED_OPENAI_API_BASE: Optional[str] = Field(
|
2024-08-23 23:46:01 +08:00
|
|
|
description="",
|
2024-06-22 17:41:17 +08:00
|
|
|
default=None,
|
|
|
|
)
|
|
|
|
|
|
|
|
HOSTED_OPENAI_API_ORGANIZATION: Optional[str] = Field(
|
2024-08-23 23:46:01 +08:00
|
|
|
description="",
|
2024-06-22 17:41:17 +08:00
|
|
|
default=None,
|
|
|
|
)
|
|
|
|
|
|
|
|
HOSTED_OPENAI_TRIAL_ENABLED: bool = Field(
|
2024-08-23 23:46:01 +08:00
|
|
|
description="",
|
2024-06-22 17:41:17 +08:00
|
|
|
default=False,
|
|
|
|
)
|
|
|
|
|
|
|
|
HOSTED_OPENAI_TRIAL_MODELS: str = Field(
|
2024-08-23 23:46:01 +08:00
|
|
|
description="",
|
|
|
|
default="gpt-3.5-turbo,"
|
|
|
|
"gpt-3.5-turbo-1106,"
|
|
|
|
"gpt-3.5-turbo-instruct,"
|
|
|
|
"gpt-3.5-turbo-16k,"
|
|
|
|
"gpt-3.5-turbo-16k-0613,"
|
|
|
|
"gpt-3.5-turbo-0613,"
|
|
|
|
"gpt-3.5-turbo-0125,"
|
|
|
|
"text-davinci-003",
|
2024-06-22 17:41:17 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
HOSTED_OPENAI_QUOTA_LIMIT: NonNegativeInt = Field(
|
2024-08-23 23:46:01 +08:00
|
|
|
description="",
|
2024-06-22 17:41:17 +08:00
|
|
|
default=200,
|
|
|
|
)
|
|
|
|
|
|
|
|
HOSTED_OPENAI_PAID_ENABLED: bool = Field(
|
2024-08-23 23:46:01 +08:00
|
|
|
description="",
|
2024-06-22 17:41:17 +08:00
|
|
|
default=False,
|
|
|
|
)
|
|
|
|
|
|
|
|
HOSTED_OPENAI_PAID_MODELS: str = Field(
|
2024-08-23 23:46:01 +08:00
|
|
|
description="",
|
|
|
|
default="gpt-4,"
|
|
|
|
"gpt-4-turbo-preview,"
|
|
|
|
"gpt-4-turbo-2024-04-09,"
|
|
|
|
"gpt-4-1106-preview,"
|
|
|
|
"gpt-4-0125-preview,"
|
|
|
|
"gpt-3.5-turbo,"
|
|
|
|
"gpt-3.5-turbo-16k,"
|
|
|
|
"gpt-3.5-turbo-16k-0613,"
|
|
|
|
"gpt-3.5-turbo-1106,"
|
|
|
|
"gpt-3.5-turbo-0613,"
|
|
|
|
"gpt-3.5-turbo-0125,"
|
|
|
|
"gpt-3.5-turbo-instruct,"
|
|
|
|
"text-davinci-003",
|
2024-06-22 17:41:17 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2024-07-07 12:18:15 +08:00
|
|
|
class HostedAzureOpenAiConfig(BaseSettings):
|
2024-06-22 17:41:17 +08:00
|
|
|
"""
|
|
|
|
Hosted OpenAI service config
|
|
|
|
"""
|
|
|
|
|
|
|
|
HOSTED_AZURE_OPENAI_ENABLED: bool = Field(
|
2024-08-23 23:46:01 +08:00
|
|
|
description="",
|
2024-06-22 17:41:17 +08:00
|
|
|
default=False,
|
|
|
|
)
|
|
|
|
|
2024-07-17 15:52:51 +08:00
|
|
|
HOSTED_AZURE_OPENAI_API_KEY: Optional[str] = Field(
|
2024-08-23 23:46:01 +08:00
|
|
|
description="",
|
2024-06-22 17:41:17 +08:00
|
|
|
default=None,
|
|
|
|
)
|
|
|
|
|
|
|
|
HOSTED_AZURE_OPENAI_API_BASE: Optional[str] = Field(
|
2024-08-23 23:46:01 +08:00
|
|
|
description="",
|
2024-06-22 17:41:17 +08:00
|
|
|
default=None,
|
|
|
|
)
|
|
|
|
|
|
|
|
HOSTED_AZURE_OPENAI_QUOTA_LIMIT: NonNegativeInt = Field(
|
2024-08-23 23:46:01 +08:00
|
|
|
description="",
|
2024-06-22 17:41:17 +08:00
|
|
|
default=200,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2024-07-07 12:18:15 +08:00
|
|
|
class HostedAnthropicConfig(BaseSettings):
|
2024-06-22 17:41:17 +08:00
|
|
|
"""
|
|
|
|
Hosted Azure OpenAI service config
|
|
|
|
"""
|
|
|
|
|
|
|
|
HOSTED_ANTHROPIC_API_BASE: Optional[str] = Field(
|
2024-08-23 23:46:01 +08:00
|
|
|
description="",
|
2024-06-22 17:41:17 +08:00
|
|
|
default=None,
|
|
|
|
)
|
|
|
|
|
|
|
|
HOSTED_ANTHROPIC_API_KEY: Optional[str] = Field(
|
2024-08-23 23:46:01 +08:00
|
|
|
description="",
|
2024-06-22 17:41:17 +08:00
|
|
|
default=None,
|
|
|
|
)
|
|
|
|
|
|
|
|
HOSTED_ANTHROPIC_TRIAL_ENABLED: bool = Field(
|
2024-08-23 23:46:01 +08:00
|
|
|
description="",
|
2024-06-22 17:41:17 +08:00
|
|
|
default=False,
|
|
|
|
)
|
|
|
|
|
|
|
|
HOSTED_ANTHROPIC_QUOTA_LIMIT: NonNegativeInt = Field(
|
2024-08-23 23:46:01 +08:00
|
|
|
description="",
|
2024-06-22 17:41:17 +08:00
|
|
|
default=600000,
|
|
|
|
)
|
|
|
|
|
|
|
|
HOSTED_ANTHROPIC_PAID_ENABLED: bool = Field(
|
2024-08-23 23:46:01 +08:00
|
|
|
description="",
|
2024-06-22 17:41:17 +08:00
|
|
|
default=False,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2024-07-07 12:18:15 +08:00
|
|
|
class HostedMinmaxConfig(BaseSettings):
|
2024-06-22 17:41:17 +08:00
|
|
|
"""
|
|
|
|
Hosted Minmax service config
|
|
|
|
"""
|
|
|
|
|
|
|
|
HOSTED_MINIMAX_ENABLED: bool = Field(
|
2024-08-23 23:46:01 +08:00
|
|
|
description="",
|
2024-06-22 17:41:17 +08:00
|
|
|
default=False,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2024-07-07 12:18:15 +08:00
|
|
|
class HostedSparkConfig(BaseSettings):
|
2024-06-22 17:41:17 +08:00
|
|
|
"""
|
|
|
|
Hosted Spark service config
|
|
|
|
"""
|
|
|
|
|
|
|
|
HOSTED_SPARK_ENABLED: bool = Field(
|
2024-08-23 23:46:01 +08:00
|
|
|
description="",
|
2024-06-22 17:41:17 +08:00
|
|
|
default=False,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2024-07-07 12:18:15 +08:00
|
|
|
class HostedZhipuAIConfig(BaseSettings):
|
2024-06-22 17:41:17 +08:00
|
|
|
"""
|
|
|
|
Hosted Minmax service config
|
|
|
|
"""
|
|
|
|
|
|
|
|
HOSTED_ZHIPUAI_ENABLED: bool = Field(
|
2024-08-23 23:46:01 +08:00
|
|
|
description="",
|
2024-06-22 17:41:17 +08:00
|
|
|
default=False,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2024-07-07 12:18:15 +08:00
|
|
|
class HostedModerationConfig(BaseSettings):
|
2024-06-22 17:41:17 +08:00
|
|
|
"""
|
|
|
|
Hosted Moderation service config
|
|
|
|
"""
|
|
|
|
|
|
|
|
HOSTED_MODERATION_ENABLED: bool = Field(
|
2024-08-23 23:46:01 +08:00
|
|
|
description="",
|
2024-06-22 17:41:17 +08:00
|
|
|
default=False,
|
|
|
|
)
|
|
|
|
|
|
|
|
HOSTED_MODERATION_PROVIDERS: str = Field(
|
2024-08-23 23:46:01 +08:00
|
|
|
description="",
|
|
|
|
default="",
|
2024-06-22 17:41:17 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2024-07-07 12:18:15 +08:00
|
|
|
class HostedFetchAppTemplateConfig(BaseSettings):
|
2024-06-22 17:41:17 +08:00
|
|
|
"""
|
|
|
|
Hosted Moderation service config
|
|
|
|
"""
|
|
|
|
|
|
|
|
HOSTED_FETCH_APP_TEMPLATES_MODE: str = Field(
|
2024-08-23 23:46:01 +08:00
|
|
|
description="the mode for fetching app templates,"
|
|
|
|
" default to remote,"
|
|
|
|
" available values: remote, db, builtin",
|
|
|
|
default="remote",
|
2024-06-22 17:41:17 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
HOSTED_FETCH_APP_TEMPLATES_REMOTE_DOMAIN: str = Field(
|
2024-08-23 23:46:01 +08:00
|
|
|
description="the domain for fetching remote app templates",
|
|
|
|
default="https://tmpl.dify.ai",
|
2024-06-22 17:41:17 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
class HostedServiceConfig(
|
|
|
|
# place the configs in alphabet order
|
|
|
|
HostedAnthropicConfig,
|
|
|
|
HostedAzureOpenAiConfig,
|
|
|
|
HostedFetchAppTemplateConfig,
|
|
|
|
HostedMinmaxConfig,
|
|
|
|
HostedOpenAiConfig,
|
|
|
|
HostedSparkConfig,
|
|
|
|
HostedZhipuAIConfig,
|
|
|
|
# moderation
|
|
|
|
HostedModerationConfig,
|
|
|
|
):
|
|
|
|
pass
|