mirror of
https://github.com/langgenius/dify.git
synced 2026-03-12 02:28:54 +08:00
Signed-off-by: yihong0618 <zouzou0208@gmail.com> Signed-off-by: -LAN- <laipz8200@outlook.com> Co-authored-by: kurokobo <kuro664@gmail.com> Co-authored-by: Hiroshi Fujita <fujita-h@users.noreply.github.com> Co-authored-by: NFish <douxc512@gmail.com> Co-authored-by: Gen Sato <52241300+halogen22@users.noreply.github.com> Co-authored-by: eux <euxuuu@gmail.com> Co-authored-by: huangzhuo1949 <167434202+huangzhuo1949@users.noreply.github.com> Co-authored-by: huangzhuo <huangzhuo1@xiaomi.com> Co-authored-by: lotsik <lotsik@mail.ru> Co-authored-by: crazywoola <100913391+crazywoola@users.noreply.github.com> Co-authored-by: Wu Tianwei <30284043+WTW0313@users.noreply.github.com> Co-authored-by: nite-knite <nkCoding@gmail.com> Co-authored-by: Jyong <76649700+JohnJyong@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: gakkiyomi <gakkiyomi@aliyun.com> Co-authored-by: CN-P5 <heibai2006@gmail.com> Co-authored-by: CN-P5 <heibai2006@qq.com> Co-authored-by: Chuehnone <1897025+chuehnone@users.noreply.github.com> Co-authored-by: yihong <zouzou0208@gmail.com> Co-authored-by: Kevin9703 <51311316+Kevin9703@users.noreply.github.com> Co-authored-by: -LAN- <laipz8200@outlook.com> Co-authored-by: Boris Feld <lothiraldan@gmail.com> Co-authored-by: mbo <himabo@gmail.com> Co-authored-by: mabo <mabo@aeyes.ai> Co-authored-by: Warren Chen <warren.chen830@gmail.com> Co-authored-by: KVOJJJin <jzongcode@gmail.com> Co-authored-by: JzoNgKVO <27049666+JzoNgKVO@users.noreply.github.com> Co-authored-by: jiandanfeng <chenjh3@wangsu.com> Co-authored-by: zhu-an <70234959+xhdd123321@users.noreply.github.com> Co-authored-by: zhaoqingyu.1075 <zhaoqingyu.1075@bytedance.com> Co-authored-by: 海狸大師 <86974027+yenslife@users.noreply.github.com> Co-authored-by: Xu Song <xusong.vip@gmail.com> Co-authored-by: rayshaw001 <396301947@163.com> Co-authored-by: Ding Jiatong <dingjiatong@gmail.com> Co-authored-by: Bowen Liang <liangbowen@gf.com.cn> Co-authored-by: JasonVV <jasonwangiii@outlook.com> Co-authored-by: le0zh <newlight@qq.com> Co-authored-by: zhuxinliang <zhuxinliang@didiglobal.com> Co-authored-by: k-zaku <zaku99@outlook.jp> Co-authored-by: Joel <iamjoel007@gmail.com> Co-authored-by: luckylhb90 <luckylhb90@gmail.com> Co-authored-by: hobo.l <hobo.l@binance.com> Co-authored-by: jiangbo721 <365065261@qq.com> Co-authored-by: 刘江波 <jiangbo721@163.com> Co-authored-by: Shun Miyazawa <34241526+miya@users.noreply.github.com> Co-authored-by: EricPan <30651140+Egfly@users.noreply.github.com> Co-authored-by: crazywoola <427733928@qq.com> Co-authored-by: zxhlyh <jasonapring2015@outlook.com> Co-authored-by: sino <sino2322@gmail.com> Co-authored-by: Jhvcc <37662342+Jhvcc@users.noreply.github.com> Co-authored-by: lowell <lowell.hu@zkteco.in>
207 lines
5.2 KiB
Python
207 lines
5.2 KiB
Python
from typing import Optional
|
|
|
|
from pydantic import Field, NonNegativeInt
|
|
from pydantic_settings import BaseSettings
|
|
|
|
|
|
class HostedOpenAiConfig(BaseSettings):
|
|
"""
|
|
Configuration for hosted OpenAI service
|
|
"""
|
|
|
|
HOSTED_OPENAI_API_KEY: Optional[str] = Field(
|
|
description="API key for hosted OpenAI service",
|
|
default=None,
|
|
)
|
|
|
|
HOSTED_OPENAI_API_BASE: Optional[str] = Field(
|
|
description="Base URL for hosted OpenAI API",
|
|
default=None,
|
|
)
|
|
|
|
HOSTED_OPENAI_API_ORGANIZATION: Optional[str] = Field(
|
|
description="Organization ID for hosted OpenAI service",
|
|
default=None,
|
|
)
|
|
|
|
HOSTED_OPENAI_TRIAL_ENABLED: bool = Field(
|
|
description="Enable trial access to hosted OpenAI service",
|
|
default=False,
|
|
)
|
|
|
|
HOSTED_OPENAI_TRIAL_MODELS: str = Field(
|
|
description="Comma-separated list of available models for trial access",
|
|
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",
|
|
)
|
|
|
|
HOSTED_OPENAI_QUOTA_LIMIT: NonNegativeInt = Field(
|
|
description="Quota limit for hosted OpenAI service usage",
|
|
default=200,
|
|
)
|
|
|
|
HOSTED_OPENAI_PAID_ENABLED: bool = Field(
|
|
description="Enable paid access to hosted OpenAI service",
|
|
default=False,
|
|
)
|
|
|
|
HOSTED_OPENAI_PAID_MODELS: str = Field(
|
|
description="Comma-separated list of available models for paid access",
|
|
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",
|
|
)
|
|
|
|
|
|
class HostedAzureOpenAiConfig(BaseSettings):
|
|
"""
|
|
Configuration for hosted Azure OpenAI service
|
|
"""
|
|
|
|
HOSTED_AZURE_OPENAI_ENABLED: bool = Field(
|
|
description="Enable hosted Azure OpenAI service",
|
|
default=False,
|
|
)
|
|
|
|
HOSTED_AZURE_OPENAI_API_KEY: Optional[str] = Field(
|
|
description="API key for hosted Azure OpenAI service",
|
|
default=None,
|
|
)
|
|
|
|
HOSTED_AZURE_OPENAI_API_BASE: Optional[str] = Field(
|
|
description="Base URL for hosted Azure OpenAI API",
|
|
default=None,
|
|
)
|
|
|
|
HOSTED_AZURE_OPENAI_QUOTA_LIMIT: NonNegativeInt = Field(
|
|
description="Quota limit for hosted Azure OpenAI service usage",
|
|
default=200,
|
|
)
|
|
|
|
|
|
class HostedAnthropicConfig(BaseSettings):
|
|
"""
|
|
Configuration for hosted Anthropic service
|
|
"""
|
|
|
|
HOSTED_ANTHROPIC_API_BASE: Optional[str] = Field(
|
|
description="Base URL for hosted Anthropic API",
|
|
default=None,
|
|
)
|
|
|
|
HOSTED_ANTHROPIC_API_KEY: Optional[str] = Field(
|
|
description="API key for hosted Anthropic service",
|
|
default=None,
|
|
)
|
|
|
|
HOSTED_ANTHROPIC_TRIAL_ENABLED: bool = Field(
|
|
description="Enable trial access to hosted Anthropic service",
|
|
default=False,
|
|
)
|
|
|
|
HOSTED_ANTHROPIC_QUOTA_LIMIT: NonNegativeInt = Field(
|
|
description="Quota limit for hosted Anthropic service usage",
|
|
default=600000,
|
|
)
|
|
|
|
HOSTED_ANTHROPIC_PAID_ENABLED: bool = Field(
|
|
description="Enable paid access to hosted Anthropic service",
|
|
default=False,
|
|
)
|
|
|
|
|
|
class HostedMinmaxConfig(BaseSettings):
|
|
"""
|
|
Configuration for hosted Minmax service
|
|
"""
|
|
|
|
HOSTED_MINIMAX_ENABLED: bool = Field(
|
|
description="Enable hosted Minmax service",
|
|
default=False,
|
|
)
|
|
|
|
|
|
class HostedSparkConfig(BaseSettings):
|
|
"""
|
|
Configuration for hosted Spark service
|
|
"""
|
|
|
|
HOSTED_SPARK_ENABLED: bool = Field(
|
|
description="Enable hosted Spark service",
|
|
default=False,
|
|
)
|
|
|
|
|
|
class HostedZhipuAIConfig(BaseSettings):
|
|
"""
|
|
Configuration for hosted ZhipuAI service
|
|
"""
|
|
|
|
HOSTED_ZHIPUAI_ENABLED: bool = Field(
|
|
description="Enable hosted ZhipuAI service",
|
|
default=False,
|
|
)
|
|
|
|
|
|
class HostedModerationConfig(BaseSettings):
|
|
"""
|
|
Configuration for hosted Moderation service
|
|
"""
|
|
|
|
HOSTED_MODERATION_ENABLED: bool = Field(
|
|
description="Enable hosted Moderation service",
|
|
default=False,
|
|
)
|
|
|
|
HOSTED_MODERATION_PROVIDERS: str = Field(
|
|
description="Comma-separated list of moderation providers",
|
|
default="",
|
|
)
|
|
|
|
|
|
class HostedFetchAppTemplateConfig(BaseSettings):
|
|
"""
|
|
Configuration for fetching app templates
|
|
"""
|
|
|
|
HOSTED_FETCH_APP_TEMPLATES_MODE: str = Field(
|
|
description="Mode for fetching app templates: remote, db, or builtin default to remote,",
|
|
default="remote",
|
|
)
|
|
|
|
HOSTED_FETCH_APP_TEMPLATES_REMOTE_DOMAIN: str = Field(
|
|
description="Domain for fetching remote app templates",
|
|
default="https://tmpl.dify.ai",
|
|
)
|
|
|
|
|
|
class HostedServiceConfig(
|
|
# place the configs in alphabet order
|
|
HostedAnthropicConfig,
|
|
HostedAzureOpenAiConfig,
|
|
HostedFetchAppTemplateConfig,
|
|
HostedMinmaxConfig,
|
|
HostedOpenAiConfig,
|
|
HostedSparkConfig,
|
|
HostedZhipuAIConfig,
|
|
# moderation
|
|
HostedModerationConfig,
|
|
):
|
|
pass
|