chore(api/configs): apply ruff reformat (#7590)

This commit is contained in:
Bowen Liang 2024-08-23 23:46:01 +08:00 committed by GitHub
parent 3ace01cfb3
commit 2da63654e5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
31 changed files with 388 additions and 385 deletions

View File

@ -25,11 +25,11 @@ class DifyConfig(
): ):
model_config = SettingsConfigDict( model_config = SettingsConfigDict(
# read from dotenv format config file # read from dotenv format config file
env_file='.env', env_file=".env",
env_file_encoding='utf-8', env_file_encoding="utf-8",
frozen=True, frozen=True,
# ignore extra attributes # ignore extra attributes
extra='ignore', extra="ignore",
) )
# Before adding any config, # Before adding any config,

View File

@ -6,27 +6,28 @@ class DeploymentConfig(BaseSettings):
""" """
Deployment configs Deployment configs
""" """
APPLICATION_NAME: str = Field( APPLICATION_NAME: str = Field(
description='application name', description="application name",
default='langgenius/dify', default="langgenius/dify",
) )
DEBUG: bool = Field( DEBUG: bool = Field(
description='whether to enable debug mode.', description="whether to enable debug mode.",
default=False, default=False,
) )
TESTING: bool = Field( TESTING: bool = Field(
description='', description="",
default=False, default=False,
) )
EDITION: str = Field( EDITION: str = Field(
description='deployment edition', description="deployment edition",
default='SELF_HOSTED', default="SELF_HOSTED",
) )
DEPLOY_ENV: str = Field( DEPLOY_ENV: str = Field(
description='deployment environment, default to PRODUCTION.', description="deployment environment, default to PRODUCTION.",
default='PRODUCTION', default="PRODUCTION",
) )

View File

@ -7,13 +7,14 @@ class EnterpriseFeatureConfig(BaseSettings):
Enterprise feature configs. Enterprise feature configs.
**Before using, please contact business@dify.ai by email to inquire about licensing matters.** **Before using, please contact business@dify.ai by email to inquire about licensing matters.**
""" """
ENTERPRISE_ENABLED: bool = Field( ENTERPRISE_ENABLED: bool = Field(
description='whether to enable enterprise features.' description="whether to enable enterprise features."
'Before using, please contact business@dify.ai by email to inquire about licensing matters.', "Before using, please contact business@dify.ai by email to inquire about licensing matters.",
default=False, default=False,
) )
CAN_REPLACE_LOGO: bool = Field( CAN_REPLACE_LOGO: bool = Field(
description='whether to allow replacing enterprise logo.', description="whether to allow replacing enterprise logo.",
default=False, default=False,
) )

View File

@ -8,27 +8,28 @@ class NotionConfig(BaseSettings):
""" """
Notion integration configs Notion integration configs
""" """
NOTION_CLIENT_ID: Optional[str] = Field( NOTION_CLIENT_ID: Optional[str] = Field(
description='Notion client ID', description="Notion client ID",
default=None, default=None,
) )
NOTION_CLIENT_SECRET: Optional[str] = Field( NOTION_CLIENT_SECRET: Optional[str] = Field(
description='Notion client secret key', description="Notion client secret key",
default=None, default=None,
) )
NOTION_INTEGRATION_TYPE: Optional[str] = Field( NOTION_INTEGRATION_TYPE: Optional[str] = Field(
description='Notion integration type, default to None, available values: internal.', description="Notion integration type, default to None, available values: internal.",
default=None, default=None,
) )
NOTION_INTERNAL_SECRET: Optional[str] = Field( NOTION_INTERNAL_SECRET: Optional[str] = Field(
description='Notion internal secret key', description="Notion internal secret key",
default=None, default=None,
) )
NOTION_INTEGRATION_TOKEN: Optional[str] = Field( NOTION_INTEGRATION_TOKEN: Optional[str] = Field(
description='Notion integration token', description="Notion integration token",
default=None, default=None,
) )

View File

@ -8,17 +8,18 @@ class SentryConfig(BaseSettings):
""" """
Sentry configs Sentry configs
""" """
SENTRY_DSN: Optional[str] = Field( SENTRY_DSN: Optional[str] = Field(
description='Sentry DSN', description="Sentry DSN",
default=None, default=None,
) )
SENTRY_TRACES_SAMPLE_RATE: NonNegativeFloat = Field( SENTRY_TRACES_SAMPLE_RATE: NonNegativeFloat = Field(
description='Sentry trace sample rate', description="Sentry trace sample rate",
default=1.0, default=1.0,
) )
SENTRY_PROFILES_SAMPLE_RATE: NonNegativeFloat = Field( SENTRY_PROFILES_SAMPLE_RATE: NonNegativeFloat = Field(
description='Sentry profiles sample rate', description="Sentry profiles sample rate",
default=1.0, default=1.0,
) )

View File

@ -10,16 +10,17 @@ class SecurityConfig(BaseSettings):
""" """
Secret Key configs Secret Key configs
""" """
SECRET_KEY: Optional[str] = Field( SECRET_KEY: Optional[str] = Field(
description='Your App secret key will be used for securely signing the session cookie' description="Your App secret key will be used for securely signing the session cookie"
'Make sure you are changing this key for your deployment with a strong key.' "Make sure you are changing this key for your deployment with a strong key."
'You can generate a strong key using `openssl rand -base64 42`.' "You can generate a strong key using `openssl rand -base64 42`."
'Alternatively you can set it with `SECRET_KEY` environment variable.', "Alternatively you can set it with `SECRET_KEY` environment variable.",
default=None, default=None,
) )
RESET_PASSWORD_TOKEN_EXPIRY_HOURS: PositiveInt = Field( RESET_PASSWORD_TOKEN_EXPIRY_HOURS: PositiveInt = Field(
description='Expiry time in hours for reset token', description="Expiry time in hours for reset token",
default=24, default=24,
) )
@ -28,12 +29,13 @@ class AppExecutionConfig(BaseSettings):
""" """
App Execution configs App Execution configs
""" """
APP_MAX_EXECUTION_TIME: PositiveInt = Field( APP_MAX_EXECUTION_TIME: PositiveInt = Field(
description='execution timeout in seconds for app execution', description="execution timeout in seconds for app execution",
default=1200, default=1200,
) )
APP_MAX_ACTIVE_REQUESTS: NonNegativeInt = Field( APP_MAX_ACTIVE_REQUESTS: NonNegativeInt = Field(
description='max active request per app, 0 means unlimited', description="max active request per app, 0 means unlimited",
default=0, default=0,
) )
@ -42,53 +44,54 @@ class CodeExecutionSandboxConfig(BaseSettings):
""" """
Code Execution Sandbox configs Code Execution Sandbox configs
""" """
CODE_EXECUTION_ENDPOINT: str = Field( CODE_EXECUTION_ENDPOINT: str = Field(
description='endpoint URL of code execution servcie', description="endpoint URL of code execution servcie",
default='http://sandbox:8194', default="http://sandbox:8194",
) )
CODE_EXECUTION_API_KEY: str = Field( CODE_EXECUTION_API_KEY: str = Field(
description='API key for code execution service', description="API key for code execution service",
default='dify-sandbox', default="dify-sandbox",
) )
CODE_MAX_NUMBER: PositiveInt = Field( CODE_MAX_NUMBER: PositiveInt = Field(
description='max depth for code execution', description="max depth for code execution",
default=9223372036854775807, default=9223372036854775807,
) )
CODE_MIN_NUMBER: NegativeInt = Field( CODE_MIN_NUMBER: NegativeInt = Field(
description='', description="",
default=-9223372036854775807, default=-9223372036854775807,
) )
CODE_MAX_DEPTH: PositiveInt = Field( CODE_MAX_DEPTH: PositiveInt = Field(
description='max depth for code execution', description="max depth for code execution",
default=5, default=5,
) )
CODE_MAX_PRECISION: PositiveInt = Field( CODE_MAX_PRECISION: PositiveInt = Field(
description='max precision digits for float type in code execution', description="max precision digits for float type in code execution",
default=20, default=20,
) )
CODE_MAX_STRING_LENGTH: PositiveInt = Field( CODE_MAX_STRING_LENGTH: PositiveInt = Field(
description='max string length for code execution', description="max string length for code execution",
default=80000, default=80000,
) )
CODE_MAX_STRING_ARRAY_LENGTH: PositiveInt = Field( CODE_MAX_STRING_ARRAY_LENGTH: PositiveInt = Field(
description='', description="",
default=30, default=30,
) )
CODE_MAX_OBJECT_ARRAY_LENGTH: PositiveInt = Field( CODE_MAX_OBJECT_ARRAY_LENGTH: PositiveInt = Field(
description='', description="",
default=30, default=30,
) )
CODE_MAX_NUMBER_ARRAY_LENGTH: PositiveInt = Field( CODE_MAX_NUMBER_ARRAY_LENGTH: PositiveInt = Field(
description='', description="",
default=1000, default=1000,
) )
@ -97,28 +100,27 @@ class EndpointConfig(BaseSettings):
""" """
Module URL configs Module URL configs
""" """
CONSOLE_API_URL: str = Field( CONSOLE_API_URL: str = Field(
description='The backend URL prefix of the console API.' description="The backend URL prefix of the console API."
'used to concatenate the login authorization callback or notion integration callback.', "used to concatenate the login authorization callback or notion integration callback.",
default='', default="",
) )
CONSOLE_WEB_URL: str = Field( CONSOLE_WEB_URL: str = Field(
description='The front-end URL prefix of the console web.' description="The front-end URL prefix of the console web."
'used to concatenate some front-end addresses and for CORS configuration use.', "used to concatenate some front-end addresses and for CORS configuration use.",
default='', default="",
) )
SERVICE_API_URL: str = Field( SERVICE_API_URL: str = Field(
description='Service API Url prefix.' description="Service API Url prefix." "used to display Service API Base Url to the front-end.",
'used to display Service API Base Url to the front-end.', default="",
default='',
) )
APP_WEB_URL: str = Field( APP_WEB_URL: str = Field(
description='WebApp Url prefix.' description="WebApp Url prefix." "used to display WebAPP API Base Url to the front-end.",
'used to display WebAPP API Base Url to the front-end.', default="",
default='',
) )
@ -126,17 +128,18 @@ class FileAccessConfig(BaseSettings):
""" """
File Access configs File Access configs
""" """
FILES_URL: str = Field( FILES_URL: str = Field(
description='File preview or download Url prefix.' description="File preview or download Url prefix."
' used to display File preview or download Url to the front-end or as Multi-model inputs;' " used to display File preview or download Url to the front-end or as Multi-model inputs;"
'Url is signed and has expiration time.', "Url is signed and has expiration time.",
validation_alias=AliasChoices('FILES_URL', 'CONSOLE_API_URL'), validation_alias=AliasChoices("FILES_URL", "CONSOLE_API_URL"),
alias_priority=1, alias_priority=1,
default='', default="",
) )
FILES_ACCESS_TIMEOUT: int = Field( FILES_ACCESS_TIMEOUT: int = Field(
description='timeout in seconds for file accessing', description="timeout in seconds for file accessing",
default=300, default=300,
) )
@ -145,23 +148,24 @@ class FileUploadConfig(BaseSettings):
""" """
File Uploading configs File Uploading configs
""" """
UPLOAD_FILE_SIZE_LIMIT: NonNegativeInt = Field( UPLOAD_FILE_SIZE_LIMIT: NonNegativeInt = Field(
description='size limit in Megabytes for uploading files', description="size limit in Megabytes for uploading files",
default=15, default=15,
) )
UPLOAD_FILE_BATCH_LIMIT: NonNegativeInt = Field( UPLOAD_FILE_BATCH_LIMIT: NonNegativeInt = Field(
description='batch size limit for uploading files', description="batch size limit for uploading files",
default=5, default=5,
) )
UPLOAD_IMAGE_FILE_SIZE_LIMIT: NonNegativeInt = Field( UPLOAD_IMAGE_FILE_SIZE_LIMIT: NonNegativeInt = Field(
description='image file size limit in Megabytes for uploading files', description="image file size limit in Megabytes for uploading files",
default=10, default=10,
) )
BATCH_UPLOAD_LIMIT: NonNegativeInt = Field( BATCH_UPLOAD_LIMIT: NonNegativeInt = Field(
description='', # todo: to be clarified description="", # todo: to be clarified
default=20, default=20,
) )
@ -170,65 +174,66 @@ class HttpConfig(BaseSettings):
""" """
HTTP configs HTTP configs
""" """
API_COMPRESSION_ENABLED: bool = Field( API_COMPRESSION_ENABLED: bool = Field(
description='whether to enable HTTP response compression of gzip', description="whether to enable HTTP response compression of gzip",
default=False, default=False,
) )
inner_CONSOLE_CORS_ALLOW_ORIGINS: str = Field( inner_CONSOLE_CORS_ALLOW_ORIGINS: str = Field(
description='', description="",
validation_alias=AliasChoices('CONSOLE_CORS_ALLOW_ORIGINS', 'CONSOLE_WEB_URL'), validation_alias=AliasChoices("CONSOLE_CORS_ALLOW_ORIGINS", "CONSOLE_WEB_URL"),
default='', default="",
) )
@computed_field @computed_field
@property @property
def CONSOLE_CORS_ALLOW_ORIGINS(self) -> list[str]: def CONSOLE_CORS_ALLOW_ORIGINS(self) -> list[str]:
return self.inner_CONSOLE_CORS_ALLOW_ORIGINS.split(',') return self.inner_CONSOLE_CORS_ALLOW_ORIGINS.split(",")
inner_WEB_API_CORS_ALLOW_ORIGINS: str = Field( inner_WEB_API_CORS_ALLOW_ORIGINS: str = Field(
description='', description="",
validation_alias=AliasChoices('WEB_API_CORS_ALLOW_ORIGINS'), validation_alias=AliasChoices("WEB_API_CORS_ALLOW_ORIGINS"),
default='*', default="*",
) )
@computed_field @computed_field
@property @property
def WEB_API_CORS_ALLOW_ORIGINS(self) -> list[str]: def WEB_API_CORS_ALLOW_ORIGINS(self) -> list[str]:
return self.inner_WEB_API_CORS_ALLOW_ORIGINS.split(',') return self.inner_WEB_API_CORS_ALLOW_ORIGINS.split(",")
HTTP_REQUEST_MAX_CONNECT_TIMEOUT: NonNegativeInt = Field( HTTP_REQUEST_MAX_CONNECT_TIMEOUT: NonNegativeInt = Field(
description='', description="",
default=300, default=300,
) )
HTTP_REQUEST_MAX_READ_TIMEOUT: NonNegativeInt = Field( HTTP_REQUEST_MAX_READ_TIMEOUT: NonNegativeInt = Field(
description='', description="",
default=600, default=600,
) )
HTTP_REQUEST_MAX_WRITE_TIMEOUT: NonNegativeInt = Field( HTTP_REQUEST_MAX_WRITE_TIMEOUT: NonNegativeInt = Field(
description='', description="",
default=600, default=600,
) )
HTTP_REQUEST_NODE_MAX_BINARY_SIZE: PositiveInt = Field( HTTP_REQUEST_NODE_MAX_BINARY_SIZE: PositiveInt = Field(
description='', description="",
default=10 * 1024 * 1024, default=10 * 1024 * 1024,
) )
HTTP_REQUEST_NODE_MAX_TEXT_SIZE: PositiveInt = Field( HTTP_REQUEST_NODE_MAX_TEXT_SIZE: PositiveInt = Field(
description='', description="",
default=1 * 1024 * 1024, default=1 * 1024 * 1024,
) )
SSRF_PROXY_HTTP_URL: Optional[str] = Field( SSRF_PROXY_HTTP_URL: Optional[str] = Field(
description='HTTP URL for SSRF proxy', description="HTTP URL for SSRF proxy",
default=None, default=None,
) )
SSRF_PROXY_HTTPS_URL: Optional[str] = Field( SSRF_PROXY_HTTPS_URL: Optional[str] = Field(
description='HTTPS URL for SSRF proxy', description="HTTPS URL for SSRF proxy",
default=None, default=None,
) )
@ -237,13 +242,14 @@ class InnerAPIConfig(BaseSettings):
""" """
Inner API configs Inner API configs
""" """
INNER_API: bool = Field( INNER_API: bool = Field(
description='whether to enable the inner API', description="whether to enable the inner API",
default=False, default=False,
) )
INNER_API_KEY: Optional[str] = Field( INNER_API_KEY: Optional[str] = Field(
description='The inner API key is used to authenticate the inner API', description="The inner API key is used to authenticate the inner API",
default=None, default=None,
) )
@ -254,28 +260,27 @@ class LoggingConfig(BaseSettings):
""" """
LOG_LEVEL: str = Field( LOG_LEVEL: str = Field(
description='Log output level, default to INFO.' description="Log output level, default to INFO." "It is recommended to set it to ERROR for production.",
'It is recommended to set it to ERROR for production.', default="INFO",
default='INFO',
) )
LOG_FILE: Optional[str] = Field( LOG_FILE: Optional[str] = Field(
description='logging output file path', description="logging output file path",
default=None, default=None,
) )
LOG_FORMAT: str = Field( LOG_FORMAT: str = Field(
description='log format', description="log format",
default='%(asctime)s.%(msecs)03d %(levelname)s [%(threadName)s] [%(filename)s:%(lineno)d] - %(message)s', default="%(asctime)s.%(msecs)03d %(levelname)s [%(threadName)s] [%(filename)s:%(lineno)d] - %(message)s",
) )
LOG_DATEFORMAT: Optional[str] = Field( LOG_DATEFORMAT: Optional[str] = Field(
description='log date format', description="log date format",
default=None, default=None,
) )
LOG_TZ: Optional[str] = Field( LOG_TZ: Optional[str] = Field(
description='specify log timezone, eg: America/New_York', description="specify log timezone, eg: America/New_York",
default=None, default=None,
) )
@ -284,8 +289,9 @@ class ModelLoadBalanceConfig(BaseSettings):
""" """
Model load balance configs Model load balance configs
""" """
MODEL_LB_ENABLED: bool = Field( MODEL_LB_ENABLED: bool = Field(
description='whether to enable model load balancing', description="whether to enable model load balancing",
default=False, default=False,
) )
@ -294,8 +300,9 @@ class BillingConfig(BaseSettings):
""" """
Platform Billing Configurations Platform Billing Configurations
""" """
BILLING_ENABLED: bool = Field( BILLING_ENABLED: bool = Field(
description='whether to enable billing', description="whether to enable billing",
default=False, default=False,
) )
@ -304,9 +311,10 @@ class UpdateConfig(BaseSettings):
""" """
Update configs Update configs
""" """
CHECK_UPDATE_URL: str = Field( CHECK_UPDATE_URL: str = Field(
description='url for checking updates', description="url for checking updates",
default='https://updates.dify.ai', default="https://updates.dify.ai",
) )
@ -316,22 +324,22 @@ class WorkflowConfig(BaseSettings):
""" """
WORKFLOW_MAX_EXECUTION_STEPS: PositiveInt = Field( WORKFLOW_MAX_EXECUTION_STEPS: PositiveInt = Field(
description='max execution steps in single workflow execution', description="max execution steps in single workflow execution",
default=500, default=500,
) )
WORKFLOW_MAX_EXECUTION_TIME: PositiveInt = Field( WORKFLOW_MAX_EXECUTION_TIME: PositiveInt = Field(
description='max execution time in seconds in single workflow execution', description="max execution time in seconds in single workflow execution",
default=1200, default=1200,
) )
WORKFLOW_CALL_MAX_DEPTH: PositiveInt = Field( WORKFLOW_CALL_MAX_DEPTH: PositiveInt = Field(
description='max depth of calling in single workflow execution', description="max depth of calling in single workflow execution",
default=5, default=5,
) )
MAX_VARIABLE_SIZE: PositiveInt = Field( MAX_VARIABLE_SIZE: PositiveInt = Field(
description='The maximum size in bytes of a variable. default to 5KB.', description="The maximum size in bytes of a variable. default to 5KB.",
default=5 * 1024, default=5 * 1024,
) )
@ -340,28 +348,29 @@ class OAuthConfig(BaseSettings):
""" """
oauth configs oauth configs
""" """
OAUTH_REDIRECT_PATH: str = Field( OAUTH_REDIRECT_PATH: str = Field(
description='redirect path for OAuth', description="redirect path for OAuth",
default='/console/api/oauth/authorize', default="/console/api/oauth/authorize",
) )
GITHUB_CLIENT_ID: Optional[str] = Field( GITHUB_CLIENT_ID: Optional[str] = Field(
description='GitHub client id for OAuth', description="GitHub client id for OAuth",
default=None, default=None,
) )
GITHUB_CLIENT_SECRET: Optional[str] = Field( GITHUB_CLIENT_SECRET: Optional[str] = Field(
description='GitHub client secret key for OAuth', description="GitHub client secret key for OAuth",
default=None, default=None,
) )
GOOGLE_CLIENT_ID: Optional[str] = Field( GOOGLE_CLIENT_ID: Optional[str] = Field(
description='Google client id for OAuth', description="Google client id for OAuth",
default=None, default=None,
) )
GOOGLE_CLIENT_SECRET: Optional[str] = Field( GOOGLE_CLIENT_SECRET: Optional[str] = Field(
description='Google client secret key for OAuth', description="Google client secret key for OAuth",
default=None, default=None,
) )
@ -372,7 +381,7 @@ class ModerationConfig(BaseSettings):
""" """
MODERATION_BUFFER_SIZE: PositiveInt = Field( MODERATION_BUFFER_SIZE: PositiveInt = Field(
description='buffer size for moderation', description="buffer size for moderation",
default=300, default=300,
) )
@ -383,7 +392,7 @@ class ToolConfig(BaseSettings):
""" """
TOOL_ICON_CACHE_MAX_AGE: PositiveInt = Field( TOOL_ICON_CACHE_MAX_AGE: PositiveInt = Field(
description='max age in seconds for tool icon caching', description="max age in seconds for tool icon caching",
default=3600, default=3600,
) )
@ -394,52 +403,52 @@ class MailConfig(BaseSettings):
""" """
MAIL_TYPE: Optional[str] = Field( MAIL_TYPE: Optional[str] = Field(
description='Mail provider type name, default to None, availabile values are `smtp` and `resend`.', description="Mail provider type name, default to None, availabile values are `smtp` and `resend`.",
default=None, default=None,
) )
MAIL_DEFAULT_SEND_FROM: Optional[str] = Field( MAIL_DEFAULT_SEND_FROM: Optional[str] = Field(
description='default email address for sending from ', description="default email address for sending from ",
default=None, default=None,
) )
RESEND_API_KEY: Optional[str] = Field( RESEND_API_KEY: Optional[str] = Field(
description='API key for Resend', description="API key for Resend",
default=None, default=None,
) )
RESEND_API_URL: Optional[str] = Field( RESEND_API_URL: Optional[str] = Field(
description='API URL for Resend', description="API URL for Resend",
default=None, default=None,
) )
SMTP_SERVER: Optional[str] = Field( SMTP_SERVER: Optional[str] = Field(
description='smtp server host', description="smtp server host",
default=None, default=None,
) )
SMTP_PORT: Optional[int] = Field( SMTP_PORT: Optional[int] = Field(
description='smtp server port', description="smtp server port",
default=465, default=465,
) )
SMTP_USERNAME: Optional[str] = Field( SMTP_USERNAME: Optional[str] = Field(
description='smtp server username', description="smtp server username",
default=None, default=None,
) )
SMTP_PASSWORD: Optional[str] = Field( SMTP_PASSWORD: Optional[str] = Field(
description='smtp server password', description="smtp server password",
default=None, default=None,
) )
SMTP_USE_TLS: bool = Field( SMTP_USE_TLS: bool = Field(
description='whether to use TLS connection to smtp server', description="whether to use TLS connection to smtp server",
default=False, default=False,
) )
SMTP_OPPORTUNISTIC_TLS: bool = Field( SMTP_OPPORTUNISTIC_TLS: bool = Field(
description='whether to use opportunistic TLS connection to smtp server', description="whether to use opportunistic TLS connection to smtp server",
default=False, default=False,
) )
@ -450,22 +459,22 @@ class RagEtlConfig(BaseSettings):
""" """
ETL_TYPE: str = Field( ETL_TYPE: str = Field(
description='RAG ETL type name, default to `dify`, available values are `dify` and `Unstructured`. ', description="RAG ETL type name, default to `dify`, available values are `dify` and `Unstructured`. ",
default='dify', default="dify",
) )
KEYWORD_DATA_SOURCE_TYPE: str = Field( KEYWORD_DATA_SOURCE_TYPE: str = Field(
description='source type for keyword data, default to `database`, available values are `database` .', description="source type for keyword data, default to `database`, available values are `database` .",
default='database', default="database",
) )
UNSTRUCTURED_API_URL: Optional[str] = Field( UNSTRUCTURED_API_URL: Optional[str] = Field(
description='API URL for Unstructured', description="API URL for Unstructured",
default=None, default=None,
) )
UNSTRUCTURED_API_KEY: Optional[str] = Field( UNSTRUCTURED_API_KEY: Optional[str] = Field(
description='API key for Unstructured', description="API key for Unstructured",
default=None, default=None,
) )
@ -476,12 +485,12 @@ class DataSetConfig(BaseSettings):
""" """
CLEAN_DAY_SETTING: PositiveInt = Field( CLEAN_DAY_SETTING: PositiveInt = Field(
description='interval in days for cleaning up dataset', description="interval in days for cleaning up dataset",
default=30, default=30,
) )
DATASET_OPERATOR_ENABLED: bool = Field( DATASET_OPERATOR_ENABLED: bool = Field(
description='whether to enable dataset operator', description="whether to enable dataset operator",
default=False, default=False,
) )
@ -492,7 +501,7 @@ class WorkspaceConfig(BaseSettings):
""" """
INVITE_EXPIRY_HOURS: PositiveInt = Field( INVITE_EXPIRY_HOURS: PositiveInt = Field(
description='workspaces invitation expiration in hours', description="workspaces invitation expiration in hours",
default=72, default=72,
) )
@ -503,79 +512,79 @@ class IndexingConfig(BaseSettings):
""" """
INDEXING_MAX_SEGMENTATION_TOKENS_LENGTH: PositiveInt = Field( INDEXING_MAX_SEGMENTATION_TOKENS_LENGTH: PositiveInt = Field(
description='max segmentation token length for indexing', description="max segmentation token length for indexing",
default=1000, default=1000,
) )
class ImageFormatConfig(BaseSettings): class ImageFormatConfig(BaseSettings):
MULTIMODAL_SEND_IMAGE_FORMAT: str = Field( MULTIMODAL_SEND_IMAGE_FORMAT: str = Field(
description='multi model send image format, support base64, url, default is base64', description="multi model send image format, support base64, url, default is base64",
default='base64', default="base64",
) )
class CeleryBeatConfig(BaseSettings): class CeleryBeatConfig(BaseSettings):
CELERY_BEAT_SCHEDULER_TIME: int = Field( CELERY_BEAT_SCHEDULER_TIME: int = Field(
description='the time of the celery scheduler, default to 1 day', description="the time of the celery scheduler, default to 1 day",
default=1, default=1,
) )
class PositionConfig(BaseSettings): class PositionConfig(BaseSettings):
POSITION_PROVIDER_PINS: str = Field( POSITION_PROVIDER_PINS: str = Field(
description='The heads of model providers', description="The heads of model providers",
default='', default="",
) )
POSITION_PROVIDER_INCLUDES: str = Field( POSITION_PROVIDER_INCLUDES: str = Field(
description='The included model providers', description="The included model providers",
default='', default="",
) )
POSITION_PROVIDER_EXCLUDES: str = Field( POSITION_PROVIDER_EXCLUDES: str = Field(
description='The excluded model providers', description="The excluded model providers",
default='', default="",
) )
POSITION_TOOL_PINS: str = Field( POSITION_TOOL_PINS: str = Field(
description='The heads of tools', description="The heads of tools",
default='', default="",
) )
POSITION_TOOL_INCLUDES: str = Field( POSITION_TOOL_INCLUDES: str = Field(
description='The included tools', description="The included tools",
default='', default="",
) )
POSITION_TOOL_EXCLUDES: str = Field( POSITION_TOOL_EXCLUDES: str = Field(
description='The excluded tools', description="The excluded tools",
default='', default="",
) )
@computed_field @computed_field
def POSITION_PROVIDER_PINS_LIST(self) -> list[str]: def POSITION_PROVIDER_PINS_LIST(self) -> list[str]:
return [item.strip() for item in self.POSITION_PROVIDER_PINS.split(',') if item.strip() != ''] return [item.strip() for item in self.POSITION_PROVIDER_PINS.split(",") if item.strip() != ""]
@computed_field @computed_field
def POSITION_PROVIDER_INCLUDES_SET(self) -> set[str]: def POSITION_PROVIDER_INCLUDES_SET(self) -> set[str]:
return {item.strip() for item in self.POSITION_PROVIDER_INCLUDES.split(',') if item.strip() != ''} return {item.strip() for item in self.POSITION_PROVIDER_INCLUDES.split(",") if item.strip() != ""}
@computed_field @computed_field
def POSITION_PROVIDER_EXCLUDES_SET(self) -> set[str]: def POSITION_PROVIDER_EXCLUDES_SET(self) -> set[str]:
return {item.strip() for item in self.POSITION_PROVIDER_EXCLUDES.split(',') if item.strip() != ''} return {item.strip() for item in self.POSITION_PROVIDER_EXCLUDES.split(",") if item.strip() != ""}
@computed_field @computed_field
def POSITION_TOOL_PINS_LIST(self) -> list[str]: def POSITION_TOOL_PINS_LIST(self) -> list[str]:
return [item.strip() for item in self.POSITION_TOOL_PINS.split(',') if item.strip() != ''] return [item.strip() for item in self.POSITION_TOOL_PINS.split(",") if item.strip() != ""]
@computed_field @computed_field
def POSITION_TOOL_INCLUDES_SET(self) -> set[str]: def POSITION_TOOL_INCLUDES_SET(self) -> set[str]:
return {item.strip() for item in self.POSITION_TOOL_INCLUDES.split(',') if item.strip() != ''} return {item.strip() for item in self.POSITION_TOOL_INCLUDES.split(",") if item.strip() != ""}
@computed_field @computed_field
def POSITION_TOOL_EXCLUDES_SET(self) -> set[str]: def POSITION_TOOL_EXCLUDES_SET(self) -> set[str]:
return {item.strip() for item in self.POSITION_TOOL_EXCLUDES.split(',') if item.strip() != ''} return {item.strip() for item in self.POSITION_TOOL_EXCLUDES.split(",") if item.strip() != ""}
class FeatureConfig( class FeatureConfig(
@ -603,7 +612,6 @@ class FeatureConfig(
WorkflowConfig, WorkflowConfig,
WorkspaceConfig, WorkspaceConfig,
PositionConfig, PositionConfig,
# hosted services config # hosted services config
HostedServiceConfig, HostedServiceConfig,
CeleryBeatConfig, CeleryBeatConfig,

View File

@ -10,62 +10,62 @@ class HostedOpenAiConfig(BaseSettings):
""" """
HOSTED_OPENAI_API_KEY: Optional[str] = Field( HOSTED_OPENAI_API_KEY: Optional[str] = Field(
description='', description="",
default=None, default=None,
) )
HOSTED_OPENAI_API_BASE: Optional[str] = Field( HOSTED_OPENAI_API_BASE: Optional[str] = Field(
description='', description="",
default=None, default=None,
) )
HOSTED_OPENAI_API_ORGANIZATION: Optional[str] = Field( HOSTED_OPENAI_API_ORGANIZATION: Optional[str] = Field(
description='', description="",
default=None, default=None,
) )
HOSTED_OPENAI_TRIAL_ENABLED: bool = Field( HOSTED_OPENAI_TRIAL_ENABLED: bool = Field(
description='', description="",
default=False, default=False,
) )
HOSTED_OPENAI_TRIAL_MODELS: str = Field( HOSTED_OPENAI_TRIAL_MODELS: str = Field(
description='', description="",
default='gpt-3.5-turbo,' default="gpt-3.5-turbo,"
'gpt-3.5-turbo-1106,' "gpt-3.5-turbo-1106,"
'gpt-3.5-turbo-instruct,' "gpt-3.5-turbo-instruct,"
'gpt-3.5-turbo-16k,' "gpt-3.5-turbo-16k,"
'gpt-3.5-turbo-16k-0613,' "gpt-3.5-turbo-16k-0613,"
'gpt-3.5-turbo-0613,' "gpt-3.5-turbo-0613,"
'gpt-3.5-turbo-0125,' "gpt-3.5-turbo-0125,"
'text-davinci-003', "text-davinci-003",
) )
HOSTED_OPENAI_QUOTA_LIMIT: NonNegativeInt = Field( HOSTED_OPENAI_QUOTA_LIMIT: NonNegativeInt = Field(
description='', description="",
default=200, default=200,
) )
HOSTED_OPENAI_PAID_ENABLED: bool = Field( HOSTED_OPENAI_PAID_ENABLED: bool = Field(
description='', description="",
default=False, default=False,
) )
HOSTED_OPENAI_PAID_MODELS: str = Field( HOSTED_OPENAI_PAID_MODELS: str = Field(
description='', description="",
default='gpt-4,' default="gpt-4,"
'gpt-4-turbo-preview,' "gpt-4-turbo-preview,"
'gpt-4-turbo-2024-04-09,' "gpt-4-turbo-2024-04-09,"
'gpt-4-1106-preview,' "gpt-4-1106-preview,"
'gpt-4-0125-preview,' "gpt-4-0125-preview,"
'gpt-3.5-turbo,' "gpt-3.5-turbo,"
'gpt-3.5-turbo-16k,' "gpt-3.5-turbo-16k,"
'gpt-3.5-turbo-16k-0613,' "gpt-3.5-turbo-16k-0613,"
'gpt-3.5-turbo-1106,' "gpt-3.5-turbo-1106,"
'gpt-3.5-turbo-0613,' "gpt-3.5-turbo-0613,"
'gpt-3.5-turbo-0125,' "gpt-3.5-turbo-0125,"
'gpt-3.5-turbo-instruct,' "gpt-3.5-turbo-instruct,"
'text-davinci-003', "text-davinci-003",
) )
@ -75,22 +75,22 @@ class HostedAzureOpenAiConfig(BaseSettings):
""" """
HOSTED_AZURE_OPENAI_ENABLED: bool = Field( HOSTED_AZURE_OPENAI_ENABLED: bool = Field(
description='', description="",
default=False, default=False,
) )
HOSTED_AZURE_OPENAI_API_KEY: Optional[str] = Field( HOSTED_AZURE_OPENAI_API_KEY: Optional[str] = Field(
description='', description="",
default=None, default=None,
) )
HOSTED_AZURE_OPENAI_API_BASE: Optional[str] = Field( HOSTED_AZURE_OPENAI_API_BASE: Optional[str] = Field(
description='', description="",
default=None, default=None,
) )
HOSTED_AZURE_OPENAI_QUOTA_LIMIT: NonNegativeInt = Field( HOSTED_AZURE_OPENAI_QUOTA_LIMIT: NonNegativeInt = Field(
description='', description="",
default=200, default=200,
) )
@ -101,27 +101,27 @@ class HostedAnthropicConfig(BaseSettings):
""" """
HOSTED_ANTHROPIC_API_BASE: Optional[str] = Field( HOSTED_ANTHROPIC_API_BASE: Optional[str] = Field(
description='', description="",
default=None, default=None,
) )
HOSTED_ANTHROPIC_API_KEY: Optional[str] = Field( HOSTED_ANTHROPIC_API_KEY: Optional[str] = Field(
description='', description="",
default=None, default=None,
) )
HOSTED_ANTHROPIC_TRIAL_ENABLED: bool = Field( HOSTED_ANTHROPIC_TRIAL_ENABLED: bool = Field(
description='', description="",
default=False, default=False,
) )
HOSTED_ANTHROPIC_QUOTA_LIMIT: NonNegativeInt = Field( HOSTED_ANTHROPIC_QUOTA_LIMIT: NonNegativeInt = Field(
description='', description="",
default=600000, default=600000,
) )
HOSTED_ANTHROPIC_PAID_ENABLED: bool = Field( HOSTED_ANTHROPIC_PAID_ENABLED: bool = Field(
description='', description="",
default=False, default=False,
) )
@ -132,7 +132,7 @@ class HostedMinmaxConfig(BaseSettings):
""" """
HOSTED_MINIMAX_ENABLED: bool = Field( HOSTED_MINIMAX_ENABLED: bool = Field(
description='', description="",
default=False, default=False,
) )
@ -143,7 +143,7 @@ class HostedSparkConfig(BaseSettings):
""" """
HOSTED_SPARK_ENABLED: bool = Field( HOSTED_SPARK_ENABLED: bool = Field(
description='', description="",
default=False, default=False,
) )
@ -154,7 +154,7 @@ class HostedZhipuAIConfig(BaseSettings):
""" """
HOSTED_ZHIPUAI_ENABLED: bool = Field( HOSTED_ZHIPUAI_ENABLED: bool = Field(
description='', description="",
default=False, default=False,
) )
@ -165,13 +165,13 @@ class HostedModerationConfig(BaseSettings):
""" """
HOSTED_MODERATION_ENABLED: bool = Field( HOSTED_MODERATION_ENABLED: bool = Field(
description='', description="",
default=False, default=False,
) )
HOSTED_MODERATION_PROVIDERS: str = Field( HOSTED_MODERATION_PROVIDERS: str = Field(
description='', description="",
default='', default="",
) )
@ -181,15 +181,15 @@ class HostedFetchAppTemplateConfig(BaseSettings):
""" """
HOSTED_FETCH_APP_TEMPLATES_MODE: str = Field( HOSTED_FETCH_APP_TEMPLATES_MODE: str = Field(
description='the mode for fetching app templates,' description="the mode for fetching app templates,"
' default to remote,' " default to remote,"
' available values: remote, db, builtin', " available values: remote, db, builtin",
default='remote', default="remote",
) )
HOSTED_FETCH_APP_TEMPLATES_REMOTE_DOMAIN: str = Field( HOSTED_FETCH_APP_TEMPLATES_REMOTE_DOMAIN: str = Field(
description='the domain for fetching remote app templates', description="the domain for fetching remote app templates",
default='https://tmpl.dify.ai', default="https://tmpl.dify.ai",
) )
@ -202,7 +202,6 @@ class HostedServiceConfig(
HostedOpenAiConfig, HostedOpenAiConfig,
HostedSparkConfig, HostedSparkConfig,
HostedZhipuAIConfig, HostedZhipuAIConfig,
# moderation # moderation
HostedModerationConfig, HostedModerationConfig,
): ):

View File

@ -28,108 +28,108 @@ from configs.middleware.vdb.weaviate_config import WeaviateConfig
class StorageConfig(BaseSettings): class StorageConfig(BaseSettings):
STORAGE_TYPE: str = Field( STORAGE_TYPE: str = Field(
description='storage type,' description="storage type,"
' default to `local`,' " default to `local`,"
' available values are `local`, `s3`, `azure-blob`, `aliyun-oss`, `google-storage`.', " available values are `local`, `s3`, `azure-blob`, `aliyun-oss`, `google-storage`.",
default='local', default="local",
) )
STORAGE_LOCAL_PATH: str = Field( STORAGE_LOCAL_PATH: str = Field(
description='local storage path', description="local storage path",
default='storage', default="storage",
) )
class VectorStoreConfig(BaseSettings): class VectorStoreConfig(BaseSettings):
VECTOR_STORE: Optional[str] = Field( VECTOR_STORE: Optional[str] = Field(
description='vector store type', description="vector store type",
default=None, default=None,
) )
class KeywordStoreConfig(BaseSettings): class KeywordStoreConfig(BaseSettings):
KEYWORD_STORE: str = Field( KEYWORD_STORE: str = Field(
description='keyword store type', description="keyword store type",
default='jieba', default="jieba",
) )
class DatabaseConfig: class DatabaseConfig:
DB_HOST: str = Field( DB_HOST: str = Field(
description='db host', description="db host",
default='localhost', default="localhost",
) )
DB_PORT: PositiveInt = Field( DB_PORT: PositiveInt = Field(
description='db port', description="db port",
default=5432, default=5432,
) )
DB_USERNAME: str = Field( DB_USERNAME: str = Field(
description='db username', description="db username",
default='postgres', default="postgres",
) )
DB_PASSWORD: str = Field( DB_PASSWORD: str = Field(
description='db password', description="db password",
default='', default="",
) )
DB_DATABASE: str = Field( DB_DATABASE: str = Field(
description='db database', description="db database",
default='dify', default="dify",
) )
DB_CHARSET: str = Field( DB_CHARSET: str = Field(
description='db charset', description="db charset",
default='', default="",
) )
DB_EXTRAS: str = Field( DB_EXTRAS: str = Field(
description='db extras options. Example: keepalives_idle=60&keepalives=1', description="db extras options. Example: keepalives_idle=60&keepalives=1",
default='', default="",
) )
SQLALCHEMY_DATABASE_URI_SCHEME: str = Field( SQLALCHEMY_DATABASE_URI_SCHEME: str = Field(
description='db uri scheme', description="db uri scheme",
default='postgresql', default="postgresql",
) )
@computed_field @computed_field
@property @property
def SQLALCHEMY_DATABASE_URI(self) -> str: def SQLALCHEMY_DATABASE_URI(self) -> str:
db_extras = ( db_extras = (
f"{self.DB_EXTRAS}&client_encoding={self.DB_CHARSET}" f"{self.DB_EXTRAS}&client_encoding={self.DB_CHARSET}" if self.DB_CHARSET else self.DB_EXTRAS
if self.DB_CHARSET
else self.DB_EXTRAS
).strip("&") ).strip("&")
db_extras = f"?{db_extras}" if db_extras else "" db_extras = f"?{db_extras}" if db_extras else ""
return (f"{self.SQLALCHEMY_DATABASE_URI_SCHEME}://" return (
f"{self.SQLALCHEMY_DATABASE_URI_SCHEME}://"
f"{quote_plus(self.DB_USERNAME)}:{quote_plus(self.DB_PASSWORD)}@{self.DB_HOST}:{self.DB_PORT}/{self.DB_DATABASE}" f"{quote_plus(self.DB_USERNAME)}:{quote_plus(self.DB_PASSWORD)}@{self.DB_HOST}:{self.DB_PORT}/{self.DB_DATABASE}"
f"{db_extras}") f"{db_extras}"
)
SQLALCHEMY_POOL_SIZE: NonNegativeInt = Field( SQLALCHEMY_POOL_SIZE: NonNegativeInt = Field(
description='pool size of SqlAlchemy', description="pool size of SqlAlchemy",
default=30, default=30,
) )
SQLALCHEMY_MAX_OVERFLOW: NonNegativeInt = Field( SQLALCHEMY_MAX_OVERFLOW: NonNegativeInt = Field(
description='max overflows for SqlAlchemy', description="max overflows for SqlAlchemy",
default=10, default=10,
) )
SQLALCHEMY_POOL_RECYCLE: NonNegativeInt = Field( SQLALCHEMY_POOL_RECYCLE: NonNegativeInt = Field(
description='SqlAlchemy pool recycle', description="SqlAlchemy pool recycle",
default=3600, default=3600,
) )
SQLALCHEMY_POOL_PRE_PING: bool = Field( SQLALCHEMY_POOL_PRE_PING: bool = Field(
description='whether to enable pool pre-ping in SqlAlchemy', description="whether to enable pool pre-ping in SqlAlchemy",
default=False, default=False,
) )
SQLALCHEMY_ECHO: bool | str = Field( SQLALCHEMY_ECHO: bool | str = Field(
description='whether to enable SqlAlchemy echo', description="whether to enable SqlAlchemy echo",
default=False, default=False,
) )
@ -137,35 +137,38 @@ class DatabaseConfig:
@property @property
def SQLALCHEMY_ENGINE_OPTIONS(self) -> dict[str, Any]: def SQLALCHEMY_ENGINE_OPTIONS(self) -> dict[str, Any]:
return { return {
'pool_size': self.SQLALCHEMY_POOL_SIZE, "pool_size": self.SQLALCHEMY_POOL_SIZE,
'max_overflow': self.SQLALCHEMY_MAX_OVERFLOW, "max_overflow": self.SQLALCHEMY_MAX_OVERFLOW,
'pool_recycle': self.SQLALCHEMY_POOL_RECYCLE, "pool_recycle": self.SQLALCHEMY_POOL_RECYCLE,
'pool_pre_ping': self.SQLALCHEMY_POOL_PRE_PING, "pool_pre_ping": self.SQLALCHEMY_POOL_PRE_PING,
'connect_args': {'options': '-c timezone=UTC'}, "connect_args": {"options": "-c timezone=UTC"},
} }
class CeleryConfig(DatabaseConfig): class CeleryConfig(DatabaseConfig):
CELERY_BACKEND: str = Field( CELERY_BACKEND: str = Field(
description='Celery backend, available values are `database`, `redis`', description="Celery backend, available values are `database`, `redis`",
default='database', default="database",
) )
CELERY_BROKER_URL: Optional[str] = Field( CELERY_BROKER_URL: Optional[str] = Field(
description='CELERY_BROKER_URL', description="CELERY_BROKER_URL",
default=None, default=None,
) )
@computed_field @computed_field
@property @property
def CELERY_RESULT_BACKEND(self) -> str | None: def CELERY_RESULT_BACKEND(self) -> str | None:
return 'db+{}'.format(self.SQLALCHEMY_DATABASE_URI) \ return (
if self.CELERY_BACKEND == 'database' else self.CELERY_BROKER_URL "db+{}".format(self.SQLALCHEMY_DATABASE_URI)
if self.CELERY_BACKEND == "database"
else self.CELERY_BROKER_URL
)
@computed_field @computed_field
@property @property
def BROKER_USE_SSL(self) -> bool: def BROKER_USE_SSL(self) -> bool:
return self.CELERY_BROKER_URL.startswith('rediss://') if self.CELERY_BROKER_URL else False return self.CELERY_BROKER_URL.startswith("rediss://") if self.CELERY_BROKER_URL else False
class MiddlewareConfig( class MiddlewareConfig(
@ -174,7 +177,6 @@ class MiddlewareConfig(
DatabaseConfig, DatabaseConfig,
KeywordStoreConfig, KeywordStoreConfig,
RedisConfig, RedisConfig,
# configs of storage and storage providers # configs of storage and storage providers
StorageConfig, StorageConfig,
AliyunOSSStorageConfig, AliyunOSSStorageConfig,
@ -183,7 +185,6 @@ class MiddlewareConfig(
TencentCloudCOSStorageConfig, TencentCloudCOSStorageConfig,
S3StorageConfig, S3StorageConfig,
OCIStorageConfig, OCIStorageConfig,
# configs of vdb and vdb providers # configs of vdb and vdb providers
VectorStoreConfig, VectorStoreConfig,
AnalyticdbConfig, AnalyticdbConfig,

View File

@ -8,32 +8,33 @@ class RedisConfig(BaseSettings):
""" """
Redis configs Redis configs
""" """
REDIS_HOST: str = Field( REDIS_HOST: str = Field(
description='Redis host', description="Redis host",
default='localhost', default="localhost",
) )
REDIS_PORT: PositiveInt = Field( REDIS_PORT: PositiveInt = Field(
description='Redis port', description="Redis port",
default=6379, default=6379,
) )
REDIS_USERNAME: Optional[str] = Field( REDIS_USERNAME: Optional[str] = Field(
description='Redis username', description="Redis username",
default=None, default=None,
) )
REDIS_PASSWORD: Optional[str] = Field( REDIS_PASSWORD: Optional[str] = Field(
description='Redis password', description="Redis password",
default=None, default=None,
) )
REDIS_DB: NonNegativeInt = Field( REDIS_DB: NonNegativeInt = Field(
description='Redis database id, default to 0', description="Redis database id, default to 0",
default=0, default=0,
) )
REDIS_USE_SSL: bool = Field( REDIS_USE_SSL: bool = Field(
description='whether to use SSL for Redis connection', description="whether to use SSL for Redis connection",
default=False, default=False,
) )

View File

@ -10,31 +10,31 @@ class AliyunOSSStorageConfig(BaseSettings):
""" """
ALIYUN_OSS_BUCKET_NAME: Optional[str] = Field( ALIYUN_OSS_BUCKET_NAME: Optional[str] = Field(
description='Aliyun OSS bucket name', description="Aliyun OSS bucket name",
default=None, default=None,
) )
ALIYUN_OSS_ACCESS_KEY: Optional[str] = Field( ALIYUN_OSS_ACCESS_KEY: Optional[str] = Field(
description='Aliyun OSS access key', description="Aliyun OSS access key",
default=None, default=None,
) )
ALIYUN_OSS_SECRET_KEY: Optional[str] = Field( ALIYUN_OSS_SECRET_KEY: Optional[str] = Field(
description='Aliyun OSS secret key', description="Aliyun OSS secret key",
default=None, default=None,
) )
ALIYUN_OSS_ENDPOINT: Optional[str] = Field( ALIYUN_OSS_ENDPOINT: Optional[str] = Field(
description='Aliyun OSS endpoint URL', description="Aliyun OSS endpoint URL",
default=None, default=None,
) )
ALIYUN_OSS_REGION: Optional[str] = Field( ALIYUN_OSS_REGION: Optional[str] = Field(
description='Aliyun OSS region', description="Aliyun OSS region",
default=None, default=None,
) )
ALIYUN_OSS_AUTH_VERSION: Optional[str] = Field( ALIYUN_OSS_AUTH_VERSION: Optional[str] = Field(
description='Aliyun OSS authentication version', description="Aliyun OSS authentication version",
default=None, default=None,
) )

View File

@ -10,36 +10,36 @@ class S3StorageConfig(BaseSettings):
""" """
S3_ENDPOINT: Optional[str] = Field( S3_ENDPOINT: Optional[str] = Field(
description='S3 storage endpoint', description="S3 storage endpoint",
default=None, default=None,
) )
S3_REGION: Optional[str] = Field( S3_REGION: Optional[str] = Field(
description='S3 storage region', description="S3 storage region",
default=None, default=None,
) )
S3_BUCKET_NAME: Optional[str] = Field( S3_BUCKET_NAME: Optional[str] = Field(
description='S3 storage bucket name', description="S3 storage bucket name",
default=None, default=None,
) )
S3_ACCESS_KEY: Optional[str] = Field( S3_ACCESS_KEY: Optional[str] = Field(
description='S3 storage access key', description="S3 storage access key",
default=None, default=None,
) )
S3_SECRET_KEY: Optional[str] = Field( S3_SECRET_KEY: Optional[str] = Field(
description='S3 storage secret key', description="S3 storage secret key",
default=None, default=None,
) )
S3_ADDRESS_STYLE: str = Field( S3_ADDRESS_STYLE: str = Field(
description='S3 storage address style', description="S3 storage address style",
default='auto', default="auto",
) )
S3_USE_AWS_MANAGED_IAM: bool = Field( S3_USE_AWS_MANAGED_IAM: bool = Field(
description='whether to use aws managed IAM for S3', description="whether to use aws managed IAM for S3",
default=False, default=False,
) )

View File

@ -10,21 +10,21 @@ class AzureBlobStorageConfig(BaseSettings):
""" """
AZURE_BLOB_ACCOUNT_NAME: Optional[str] = Field( AZURE_BLOB_ACCOUNT_NAME: Optional[str] = Field(
description='Azure Blob account name', description="Azure Blob account name",
default=None, default=None,
) )
AZURE_BLOB_ACCOUNT_KEY: Optional[str] = Field( AZURE_BLOB_ACCOUNT_KEY: Optional[str] = Field(
description='Azure Blob account key', description="Azure Blob account key",
default=None, default=None,
) )
AZURE_BLOB_CONTAINER_NAME: Optional[str] = Field( AZURE_BLOB_CONTAINER_NAME: Optional[str] = Field(
description='Azure Blob container name', description="Azure Blob container name",
default=None, default=None,
) )
AZURE_BLOB_ACCOUNT_URL: Optional[str] = Field( AZURE_BLOB_ACCOUNT_URL: Optional[str] = Field(
description='Azure Blob account URL', description="Azure Blob account URL",
default=None, default=None,
) )

View File

@ -10,11 +10,11 @@ class GoogleCloudStorageConfig(BaseSettings):
""" """
GOOGLE_STORAGE_BUCKET_NAME: Optional[str] = Field( GOOGLE_STORAGE_BUCKET_NAME: Optional[str] = Field(
description='Google Cloud storage bucket name', description="Google Cloud storage bucket name",
default=None, default=None,
) )
GOOGLE_STORAGE_SERVICE_ACCOUNT_JSON_BASE64: Optional[str] = Field( GOOGLE_STORAGE_SERVICE_ACCOUNT_JSON_BASE64: Optional[str] = Field(
description='Google Cloud storage service account json base64', description="Google Cloud storage service account json base64",
default=None, default=None,
) )

View File

@ -10,27 +10,26 @@ class OCIStorageConfig(BaseSettings):
""" """
OCI_ENDPOINT: Optional[str] = Field( OCI_ENDPOINT: Optional[str] = Field(
description='OCI storage endpoint', description="OCI storage endpoint",
default=None, default=None,
) )
OCI_REGION: Optional[str] = Field( OCI_REGION: Optional[str] = Field(
description='OCI storage region', description="OCI storage region",
default=None, default=None,
) )
OCI_BUCKET_NAME: Optional[str] = Field( OCI_BUCKET_NAME: Optional[str] = Field(
description='OCI storage bucket name', description="OCI storage bucket name",
default=None, default=None,
) )
OCI_ACCESS_KEY: Optional[str] = Field( OCI_ACCESS_KEY: Optional[str] = Field(
description='OCI storage access key', description="OCI storage access key",
default=None, default=None,
) )
OCI_SECRET_KEY: Optional[str] = Field( OCI_SECRET_KEY: Optional[str] = Field(
description='OCI storage secret key', description="OCI storage secret key",
default=None, default=None,
) )

View File

@ -10,26 +10,26 @@ class TencentCloudCOSStorageConfig(BaseSettings):
""" """
TENCENT_COS_BUCKET_NAME: Optional[str] = Field( TENCENT_COS_BUCKET_NAME: Optional[str] = Field(
description='Tencent Cloud COS bucket name', description="Tencent Cloud COS bucket name",
default=None, default=None,
) )
TENCENT_COS_REGION: Optional[str] = Field( TENCENT_COS_REGION: Optional[str] = Field(
description='Tencent Cloud COS region', description="Tencent Cloud COS region",
default=None, default=None,
) )
TENCENT_COS_SECRET_ID: Optional[str] = Field( TENCENT_COS_SECRET_ID: Optional[str] = Field(
description='Tencent Cloud COS secret id', description="Tencent Cloud COS secret id",
default=None, default=None,
) )
TENCENT_COS_SECRET_KEY: Optional[str] = Field( TENCENT_COS_SECRET_KEY: Optional[str] = Field(
description='Tencent Cloud COS secret key', description="Tencent Cloud COS secret key",
default=None, default=None,
) )
TENCENT_COS_SCHEME: Optional[str] = Field( TENCENT_COS_SCHEME: Optional[str] = Field(
description='Tencent Cloud COS scheme', description="Tencent Cloud COS scheme",
default=None, default=None,
) )

View File

@ -10,35 +10,28 @@ class AnalyticdbConfig(BaseModel):
https://www.alibabacloud.com/help/en/analyticdb-for-postgresql/getting-started/create-an-instance-instances-with-vector-engine-optimization-enabled https://www.alibabacloud.com/help/en/analyticdb-for-postgresql/getting-started/create-an-instance-instances-with-vector-engine-optimization-enabled
""" """
ANALYTICDB_KEY_ID : Optional[str] = Field( ANALYTICDB_KEY_ID: Optional[str] = Field(
default=None, default=None, description="The Access Key ID provided by Alibaba Cloud for authentication."
description="The Access Key ID provided by Alibaba Cloud for authentication."
) )
ANALYTICDB_KEY_SECRET : Optional[str] = Field( ANALYTICDB_KEY_SECRET: Optional[str] = Field(
default=None, default=None, description="The Secret Access Key corresponding to the Access Key ID for secure access."
description="The Secret Access Key corresponding to the Access Key ID for secure access."
) )
ANALYTICDB_REGION_ID : Optional[str] = Field( ANALYTICDB_REGION_ID: Optional[str] = Field(
default=None, default=None, description="The region where the AnalyticDB instance is deployed (e.g., 'cn-hangzhou')."
description="The region where the AnalyticDB instance is deployed (e.g., 'cn-hangzhou')."
) )
ANALYTICDB_INSTANCE_ID : Optional[str] = Field( ANALYTICDB_INSTANCE_ID: Optional[str] = Field(
default=None, default=None,
description="The unique identifier of the AnalyticDB instance you want to connect to (e.g., 'gp-ab123456').." description="The unique identifier of the AnalyticDB instance you want to connect to (e.g., 'gp-ab123456')..",
) )
ANALYTICDB_ACCOUNT : Optional[str] = Field( ANALYTICDB_ACCOUNT: Optional[str] = Field(
default=None, default=None, description="The account name used to log in to the AnalyticDB instance."
description="The account name used to log in to the AnalyticDB instance."
) )
ANALYTICDB_PASSWORD : Optional[str] = Field( ANALYTICDB_PASSWORD: Optional[str] = Field(
default=None, default=None, description="The password associated with the AnalyticDB account for authentication."
description="The password associated with the AnalyticDB account for authentication."
) )
ANALYTICDB_NAMESPACE : Optional[str] = Field( ANALYTICDB_NAMESPACE: Optional[str] = Field(
default=None, default=None, description="The namespace within AnalyticDB for schema isolation."
description="The namespace within AnalyticDB for schema isolation."
) )
ANALYTICDB_NAMESPACE_PASSWORD : Optional[str] = Field( ANALYTICDB_NAMESPACE_PASSWORD: Optional[str] = Field(
default=None, default=None, description="The password for accessing the specified namespace within the AnalyticDB instance."
description="The password for accessing the specified namespace within the AnalyticDB instance."
) )

View File

@ -10,31 +10,31 @@ class ChromaConfig(BaseSettings):
""" """
CHROMA_HOST: Optional[str] = Field( CHROMA_HOST: Optional[str] = Field(
description='Chroma host', description="Chroma host",
default=None, default=None,
) )
CHROMA_PORT: PositiveInt = Field( CHROMA_PORT: PositiveInt = Field(
description='Chroma port', description="Chroma port",
default=8000, default=8000,
) )
CHROMA_TENANT: Optional[str] = Field( CHROMA_TENANT: Optional[str] = Field(
description='Chroma database', description="Chroma database",
default=None, default=None,
) )
CHROMA_DATABASE: Optional[str] = Field( CHROMA_DATABASE: Optional[str] = Field(
description='Chroma database', description="Chroma database",
default=None, default=None,
) )
CHROMA_AUTH_PROVIDER: Optional[str] = Field( CHROMA_AUTH_PROVIDER: Optional[str] = Field(
description='Chroma authentication provider', description="Chroma authentication provider",
default=None, default=None,
) )
CHROMA_AUTH_CREDENTIALS: Optional[str] = Field( CHROMA_AUTH_CREDENTIALS: Optional[str] = Field(
description='Chroma authentication credentials', description="Chroma authentication credentials",
default=None, default=None,
) )

View File

@ -10,31 +10,31 @@ class MilvusConfig(BaseSettings):
""" """
MILVUS_HOST: Optional[str] = Field( MILVUS_HOST: Optional[str] = Field(
description='Milvus host', description="Milvus host",
default=None, default=None,
) )
MILVUS_PORT: PositiveInt = Field( MILVUS_PORT: PositiveInt = Field(
description='Milvus RestFul API port', description="Milvus RestFul API port",
default=9091, default=9091,
) )
MILVUS_USER: Optional[str] = Field( MILVUS_USER: Optional[str] = Field(
description='Milvus user', description="Milvus user",
default=None, default=None,
) )
MILVUS_PASSWORD: Optional[str] = Field( MILVUS_PASSWORD: Optional[str] = Field(
description='Milvus password', description="Milvus password",
default=None, default=None,
) )
MILVUS_SECURE: bool = Field( MILVUS_SECURE: bool = Field(
description='whether to use SSL connection for Milvus', description="whether to use SSL connection for Milvus",
default=False, default=False,
) )
MILVUS_DATABASE: str = Field( MILVUS_DATABASE: str = Field(
description='Milvus database, default to `default`', description="Milvus database, default to `default`",
default='default', default="default",
) )

View File

@ -1,4 +1,3 @@
from pydantic import BaseModel, Field, PositiveInt from pydantic import BaseModel, Field, PositiveInt
@ -8,31 +7,31 @@ class MyScaleConfig(BaseModel):
""" """
MYSCALE_HOST: str = Field( MYSCALE_HOST: str = Field(
description='MyScale host', description="MyScale host",
default='localhost', default="localhost",
) )
MYSCALE_PORT: PositiveInt = Field( MYSCALE_PORT: PositiveInt = Field(
description='MyScale port', description="MyScale port",
default=8123, default=8123,
) )
MYSCALE_USER: str = Field( MYSCALE_USER: str = Field(
description='MyScale user', description="MyScale user",
default='default', default="default",
) )
MYSCALE_PASSWORD: str = Field( MYSCALE_PASSWORD: str = Field(
description='MyScale password', description="MyScale password",
default='', default="",
) )
MYSCALE_DATABASE: str = Field( MYSCALE_DATABASE: str = Field(
description='MyScale database name', description="MyScale database name",
default='default', default="default",
) )
MYSCALE_FTS_PARAMS: str = Field( MYSCALE_FTS_PARAMS: str = Field(
description='MyScale fts index parameters', description="MyScale fts index parameters",
default='', default="",
) )

View File

@ -10,26 +10,26 @@ class OpenSearchConfig(BaseSettings):
""" """
OPENSEARCH_HOST: Optional[str] = Field( OPENSEARCH_HOST: Optional[str] = Field(
description='OpenSearch host', description="OpenSearch host",
default=None, default=None,
) )
OPENSEARCH_PORT: PositiveInt = Field( OPENSEARCH_PORT: PositiveInt = Field(
description='OpenSearch port', description="OpenSearch port",
default=9200, default=9200,
) )
OPENSEARCH_USER: Optional[str] = Field( OPENSEARCH_USER: Optional[str] = Field(
description='OpenSearch user', description="OpenSearch user",
default=None, default=None,
) )
OPENSEARCH_PASSWORD: Optional[str] = Field( OPENSEARCH_PASSWORD: Optional[str] = Field(
description='OpenSearch password', description="OpenSearch password",
default=None, default=None,
) )
OPENSEARCH_SECURE: bool = Field( OPENSEARCH_SECURE: bool = Field(
description='whether to use SSL connection for OpenSearch', description="whether to use SSL connection for OpenSearch",
default=False, default=False,
) )

View File

@ -10,26 +10,26 @@ class OracleConfig(BaseSettings):
""" """
ORACLE_HOST: Optional[str] = Field( ORACLE_HOST: Optional[str] = Field(
description='ORACLE host', description="ORACLE host",
default=None, default=None,
) )
ORACLE_PORT: Optional[PositiveInt] = Field( ORACLE_PORT: Optional[PositiveInt] = Field(
description='ORACLE port', description="ORACLE port",
default=1521, default=1521,
) )
ORACLE_USER: Optional[str] = Field( ORACLE_USER: Optional[str] = Field(
description='ORACLE user', description="ORACLE user",
default=None, default=None,
) )
ORACLE_PASSWORD: Optional[str] = Field( ORACLE_PASSWORD: Optional[str] = Field(
description='ORACLE password', description="ORACLE password",
default=None, default=None,
) )
ORACLE_DATABASE: Optional[str] = Field( ORACLE_DATABASE: Optional[str] = Field(
description='ORACLE database', description="ORACLE database",
default=None, default=None,
) )

View File

@ -10,26 +10,26 @@ class PGVectorConfig(BaseSettings):
""" """
PGVECTOR_HOST: Optional[str] = Field( PGVECTOR_HOST: Optional[str] = Field(
description='PGVector host', description="PGVector host",
default=None, default=None,
) )
PGVECTOR_PORT: Optional[PositiveInt] = Field( PGVECTOR_PORT: Optional[PositiveInt] = Field(
description='PGVector port', description="PGVector port",
default=5433, default=5433,
) )
PGVECTOR_USER: Optional[str] = Field( PGVECTOR_USER: Optional[str] = Field(
description='PGVector user', description="PGVector user",
default=None, default=None,
) )
PGVECTOR_PASSWORD: Optional[str] = Field( PGVECTOR_PASSWORD: Optional[str] = Field(
description='PGVector password', description="PGVector password",
default=None, default=None,
) )
PGVECTOR_DATABASE: Optional[str] = Field( PGVECTOR_DATABASE: Optional[str] = Field(
description='PGVector database', description="PGVector database",
default=None, default=None,
) )

View File

@ -10,26 +10,26 @@ class PGVectoRSConfig(BaseSettings):
""" """
PGVECTO_RS_HOST: Optional[str] = Field( PGVECTO_RS_HOST: Optional[str] = Field(
description='PGVectoRS host', description="PGVectoRS host",
default=None, default=None,
) )
PGVECTO_RS_PORT: Optional[PositiveInt] = Field( PGVECTO_RS_PORT: Optional[PositiveInt] = Field(
description='PGVectoRS port', description="PGVectoRS port",
default=5431, default=5431,
) )
PGVECTO_RS_USER: Optional[str] = Field( PGVECTO_RS_USER: Optional[str] = Field(
description='PGVectoRS user', description="PGVectoRS user",
default=None, default=None,
) )
PGVECTO_RS_PASSWORD: Optional[str] = Field( PGVECTO_RS_PASSWORD: Optional[str] = Field(
description='PGVectoRS password', description="PGVectoRS password",
default=None, default=None,
) )
PGVECTO_RS_DATABASE: Optional[str] = Field( PGVECTO_RS_DATABASE: Optional[str] = Field(
description='PGVectoRS database', description="PGVectoRS database",
default=None, default=None,
) )

View File

@ -10,26 +10,26 @@ class QdrantConfig(BaseSettings):
""" """
QDRANT_URL: Optional[str] = Field( QDRANT_URL: Optional[str] = Field(
description='Qdrant url', description="Qdrant url",
default=None, default=None,
) )
QDRANT_API_KEY: Optional[str] = Field( QDRANT_API_KEY: Optional[str] = Field(
description='Qdrant api key', description="Qdrant api key",
default=None, default=None,
) )
QDRANT_CLIENT_TIMEOUT: NonNegativeInt = Field( QDRANT_CLIENT_TIMEOUT: NonNegativeInt = Field(
description='Qdrant client timeout in seconds', description="Qdrant client timeout in seconds",
default=20, default=20,
) )
QDRANT_GRPC_ENABLED: bool = Field( QDRANT_GRPC_ENABLED: bool = Field(
description='whether enable grpc support for Qdrant connection', description="whether enable grpc support for Qdrant connection",
default=False, default=False,
) )
QDRANT_GRPC_PORT: PositiveInt = Field( QDRANT_GRPC_PORT: PositiveInt = Field(
description='Qdrant grpc port', description="Qdrant grpc port",
default=6334, default=6334,
) )

View File

@ -10,26 +10,26 @@ class RelytConfig(BaseSettings):
""" """
RELYT_HOST: Optional[str] = Field( RELYT_HOST: Optional[str] = Field(
description='Relyt host', description="Relyt host",
default=None, default=None,
) )
RELYT_PORT: PositiveInt = Field( RELYT_PORT: PositiveInt = Field(
description='Relyt port', description="Relyt port",
default=9200, default=9200,
) )
RELYT_USER: Optional[str] = Field( RELYT_USER: Optional[str] = Field(
description='Relyt user', description="Relyt user",
default=None, default=None,
) )
RELYT_PASSWORD: Optional[str] = Field( RELYT_PASSWORD: Optional[str] = Field(
description='Relyt password', description="Relyt password",
default=None, default=None,
) )
RELYT_DATABASE: Optional[str] = Field( RELYT_DATABASE: Optional[str] = Field(
description='Relyt database', description="Relyt database",
default='default', default="default",
) )

View File

@ -10,41 +10,41 @@ class TencentVectorDBConfig(BaseSettings):
""" """
TENCENT_VECTOR_DB_URL: Optional[str] = Field( TENCENT_VECTOR_DB_URL: Optional[str] = Field(
description='Tencent Vector URL', description="Tencent Vector URL",
default=None, default=None,
) )
TENCENT_VECTOR_DB_API_KEY: Optional[str] = Field( TENCENT_VECTOR_DB_API_KEY: Optional[str] = Field(
description='Tencent Vector API key', description="Tencent Vector API key",
default=None, default=None,
) )
TENCENT_VECTOR_DB_TIMEOUT: PositiveInt = Field( TENCENT_VECTOR_DB_TIMEOUT: PositiveInt = Field(
description='Tencent Vector timeout in seconds', description="Tencent Vector timeout in seconds",
default=30, default=30,
) )
TENCENT_VECTOR_DB_USERNAME: Optional[str] = Field( TENCENT_VECTOR_DB_USERNAME: Optional[str] = Field(
description='Tencent Vector username', description="Tencent Vector username",
default=None, default=None,
) )
TENCENT_VECTOR_DB_PASSWORD: Optional[str] = Field( TENCENT_VECTOR_DB_PASSWORD: Optional[str] = Field(
description='Tencent Vector password', description="Tencent Vector password",
default=None, default=None,
) )
TENCENT_VECTOR_DB_SHARD: PositiveInt = Field( TENCENT_VECTOR_DB_SHARD: PositiveInt = Field(
description='Tencent Vector sharding number', description="Tencent Vector sharding number",
default=1, default=1,
) )
TENCENT_VECTOR_DB_REPLICAS: NonNegativeInt = Field( TENCENT_VECTOR_DB_REPLICAS: NonNegativeInt = Field(
description='Tencent Vector replicas', description="Tencent Vector replicas",
default=2, default=2,
) )
TENCENT_VECTOR_DB_DATABASE: Optional[str] = Field( TENCENT_VECTOR_DB_DATABASE: Optional[str] = Field(
description='Tencent Vector Database', description="Tencent Vector Database",
default=None, default=None,
) )

View File

@ -10,26 +10,26 @@ class TiDBVectorConfig(BaseSettings):
""" """
TIDB_VECTOR_HOST: Optional[str] = Field( TIDB_VECTOR_HOST: Optional[str] = Field(
description='TiDB Vector host', description="TiDB Vector host",
default=None, default=None,
) )
TIDB_VECTOR_PORT: Optional[PositiveInt] = Field( TIDB_VECTOR_PORT: Optional[PositiveInt] = Field(
description='TiDB Vector port', description="TiDB Vector port",
default=4000, default=4000,
) )
TIDB_VECTOR_USER: Optional[str] = Field( TIDB_VECTOR_USER: Optional[str] = Field(
description='TiDB Vector user', description="TiDB Vector user",
default=None, default=None,
) )
TIDB_VECTOR_PASSWORD: Optional[str] = Field( TIDB_VECTOR_PASSWORD: Optional[str] = Field(
description='TiDB Vector password', description="TiDB Vector password",
default=None, default=None,
) )
TIDB_VECTOR_DATABASE: Optional[str] = Field( TIDB_VECTOR_DATABASE: Optional[str] = Field(
description='TiDB Vector database', description="TiDB Vector database",
default=None, default=None,
) )

View File

@ -10,21 +10,21 @@ class WeaviateConfig(BaseSettings):
""" """
WEAVIATE_ENDPOINT: Optional[str] = Field( WEAVIATE_ENDPOINT: Optional[str] = Field(
description='Weaviate endpoint URL', description="Weaviate endpoint URL",
default=None, default=None,
) )
WEAVIATE_API_KEY: Optional[str] = Field( WEAVIATE_API_KEY: Optional[str] = Field(
description='Weaviate API key', description="Weaviate API key",
default=None, default=None,
) )
WEAVIATE_GRPC_ENABLED: bool = Field( WEAVIATE_GRPC_ENABLED: bool = Field(
description='whether to enable gRPC for Weaviate connection', description="whether to enable gRPC for Weaviate connection",
default=True, default=True,
) )
WEAVIATE_BATCH_SIZE: PositiveInt = Field( WEAVIATE_BATCH_SIZE: PositiveInt = Field(
description='Weaviate batch size', description="Weaviate batch size",
default=100, default=100,
) )

View File

@ -8,11 +8,11 @@ class PackagingInfo(BaseSettings):
""" """
CURRENT_VERSION: str = Field( CURRENT_VERSION: str = Field(
description='Dify version', description="Dify version",
default='0.7.1', default="0.7.1",
) )
COMMIT_SHA: str = Field( COMMIT_SHA: str = Field(
description="SHA-1 checksum of the git commit used to build the app", description="SHA-1 checksum of the git commit used to build the app",
default='', default="",
) )

View File

@ -77,7 +77,6 @@ exclude = [
"services/**/*.py", "services/**/*.py",
"tasks/**/*.py", "tasks/**/*.py",
"tests/**/*.py", "tests/**/*.py",
"configs/**/*.py",
] ]
[tool.pytest_env] [tool.pytest_env]