| from .app_config import DifyConfig | from .app_config import DifyConfig | ||||
| dify_config = DifyConfig() | |||||
| dify_config = DifyConfig() |
| ): | ): | ||||
| model_config = SettingsConfigDict( | model_config = SettingsConfigDict( | ||||
| # read from dotenv format config file | # read from dotenv format config file | ||||
| env_file='.env', | |||||
| env_file_encoding='utf-8', | |||||
| env_file=".env", | |||||
| 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, |
| """ | """ | ||||
| Deployment configs | Deployment configs | ||||
| """ | """ | ||||
| APPLICATION_NAME: str = Field( | APPLICATION_NAME: str = Field( | ||||
| description='application name', | |||||
| default='langgenius/dify', | |||||
| description="application name", | |||||
| 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', | |||||
| default='SELF_HOSTED', | |||||
| description="deployment edition", | |||||
| default="SELF_HOSTED", | |||||
| ) | ) | ||||
| DEPLOY_ENV: str = Field( | DEPLOY_ENV: str = Field( | ||||
| description='deployment environment, default to PRODUCTION.', | |||||
| default='PRODUCTION', | |||||
| description="deployment environment, default to PRODUCTION.", | |||||
| default="PRODUCTION", | |||||
| ) | ) |
| 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.' | |||||
| 'Before using, please contact business@dify.ai by email to inquire about licensing matters.', | |||||
| description="whether to enable enterprise features." | |||||
| "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, | ||||
| ) | ) |
| """ | """ | ||||
| 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, | ||||
| ) | ) |
| """ | """ | ||||
| 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, | ||||
| ) | ) |
| """ | """ | ||||
| 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' | |||||
| '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`.' | |||||
| 'Alternatively you can set it with `SECRET_KEY` environment variable.', | |||||
| 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." | |||||
| "You can generate a strong key using `openssl rand -base64 42`." | |||||
| "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, | ||||
| ) | ) | ||||
| """ | """ | ||||
| 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, | ||||
| ) | ) | ||||
| """ | """ | ||||
| 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', | |||||
| default='http://sandbox:8194', | |||||
| description="endpoint URL of code execution servcie", | |||||
| default="http://sandbox:8194", | |||||
| ) | ) | ||||
| CODE_EXECUTION_API_KEY: str = Field( | CODE_EXECUTION_API_KEY: str = Field( | ||||
| description='API key for code execution service', | |||||
| default='dify-sandbox', | |||||
| description="API key for code execution service", | |||||
| 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, | ||||
| ) | ) | ||||
| """ | """ | ||||
| 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.' | |||||
| 'used to concatenate the login authorization callback or notion integration callback.', | |||||
| default='', | |||||
| description="The backend URL prefix of the console API." | |||||
| "used to concatenate the login authorization callback or notion integration callback.", | |||||
| default="", | |||||
| ) | ) | ||||
| CONSOLE_WEB_URL: str = Field( | CONSOLE_WEB_URL: str = Field( | ||||
| description='The front-end URL prefix of the console web.' | |||||
| 'used to concatenate some front-end addresses and for CORS configuration use.', | |||||
| default='', | |||||
| description="The front-end URL prefix of the console web." | |||||
| "used to concatenate some front-end addresses and for CORS configuration use.", | |||||
| default="", | |||||
| ) | ) | ||||
| SERVICE_API_URL: str = Field( | SERVICE_API_URL: str = Field( | ||||
| description='Service API Url prefix.' | |||||
| 'used to display Service API Base Url to the front-end.', | |||||
| default='', | |||||
| description="Service API Url prefix." "used to display Service API Base Url to the front-end.", | |||||
| default="", | |||||
| ) | ) | ||||
| APP_WEB_URL: str = Field( | APP_WEB_URL: str = Field( | ||||
| description='WebApp Url prefix.' | |||||
| 'used to display WebAPP API Base Url to the front-end.', | |||||
| default='', | |||||
| description="WebApp Url prefix." "used to display WebAPP API Base Url to the front-end.", | |||||
| default="", | |||||
| ) | ) | ||||
| """ | """ | ||||
| File Access configs | File Access configs | ||||
| """ | """ | ||||
| FILES_URL: str = Field( | FILES_URL: str = Field( | ||||
| description='File preview or download Url prefix.' | |||||
| ' used to display File preview or download Url to the front-end or as Multi-model inputs;' | |||||
| 'Url is signed and has expiration time.', | |||||
| validation_alias=AliasChoices('FILES_URL', 'CONSOLE_API_URL'), | |||||
| description="File preview or download Url prefix." | |||||
| " used to display File preview or download Url to the front-end or as Multi-model inputs;" | |||||
| "Url is signed and has expiration time.", | |||||
| 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, | ||||
| ) | ) | ||||
| """ | """ | ||||
| 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, | ||||
| ) | ) | ||||
| """ | """ | ||||
| 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='', | |||||
| validation_alias=AliasChoices('CONSOLE_CORS_ALLOW_ORIGINS', 'CONSOLE_WEB_URL'), | |||||
| default='', | |||||
| description="", | |||||
| validation_alias=AliasChoices("CONSOLE_CORS_ALLOW_ORIGINS", "CONSOLE_WEB_URL"), | |||||
| 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='', | |||||
| validation_alias=AliasChoices('WEB_API_CORS_ALLOW_ORIGINS'), | |||||
| default='*', | |||||
| description="", | |||||
| validation_alias=AliasChoices("WEB_API_CORS_ALLOW_ORIGINS"), | |||||
| 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, | ||||
| ) | ) | ||||
| """ | """ | ||||
| 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, | ||||
| ) | ) | ||||
| """ | """ | ||||
| LOG_LEVEL: str = Field( | LOG_LEVEL: str = Field( | ||||
| description='Log output level, default to INFO.' | |||||
| 'It is recommended to set it to ERROR for production.', | |||||
| default='INFO', | |||||
| description="Log output level, default to INFO." "It is recommended to set it to ERROR for production.", | |||||
| 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', | |||||
| default='%(asctime)s.%(msecs)03d %(levelname)s [%(threadName)s] [%(filename)s:%(lineno)d] - %(message)s', | |||||
| description="log format", | |||||
| 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, | ||||
| ) | ) | ||||
| """ | """ | ||||
| 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, | ||||
| ) | ) | ||||
| """ | """ | ||||
| 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, | ||||
| ) | ) | ||||
| """ | """ | ||||
| Update configs | Update configs | ||||
| """ | """ | ||||
| CHECK_UPDATE_URL: str = Field( | CHECK_UPDATE_URL: str = Field( | ||||
| description='url for checking updates', | |||||
| default='https://updates.dify.ai', | |||||
| description="url for checking updates", | |||||
| default="https://updates.dify.ai", | |||||
| ) | ) | ||||
| """ | """ | ||||
| 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, | ||||
| ) | ) | ||||
| """ | """ | ||||
| oauth configs | oauth configs | ||||
| """ | """ | ||||
| OAUTH_REDIRECT_PATH: str = Field( | OAUTH_REDIRECT_PATH: str = Field( | ||||
| description='redirect path for OAuth', | |||||
| default='/console/api/oauth/authorize', | |||||
| description="redirect path for OAuth", | |||||
| 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, | ||||
| ) | ) | ||||
| """ | """ | ||||
| MODERATION_BUFFER_SIZE: PositiveInt = Field( | MODERATION_BUFFER_SIZE: PositiveInt = Field( | ||||
| description='buffer size for moderation', | |||||
| description="buffer size for moderation", | |||||
| default=300, | default=300, | ||||
| ) | ) | ||||
| """ | """ | ||||
| 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, | ||||
| ) | ) | ||||
| """ | """ | ||||
| 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, | ||||
| ) | ) | ||||
| """ | """ | ||||
| ETL_TYPE: str = Field( | ETL_TYPE: str = Field( | ||||
| description='RAG ETL type name, default to `dify`, available values are `dify` and `Unstructured`. ', | |||||
| default='dify', | |||||
| description="RAG ETL type name, default to `dify`, available values are `dify` and `Unstructured`. ", | |||||
| 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` .', | |||||
| default='database', | |||||
| description="source type for keyword data, default to `database`, available values are `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, | ||||
| ) | ) | ||||
| """ | """ | ||||
| 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, | ||||
| ) | ) | ||||
| """ | """ | ||||
| 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, | ||||
| ) | ) | ||||
| """ | """ | ||||
| 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', | |||||
| default='base64', | |||||
| description="multi model send image format, support base64, url, default is 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', | |||||
| default='', | |||||
| description="The heads of model providers", | |||||
| default="", | |||||
| ) | ) | ||||
| POSITION_PROVIDER_INCLUDES: str = Field( | POSITION_PROVIDER_INCLUDES: str = Field( | ||||
| description='The included model providers', | |||||
| default='', | |||||
| description="The included model providers", | |||||
| default="", | |||||
| ) | ) | ||||
| POSITION_PROVIDER_EXCLUDES: str = Field( | POSITION_PROVIDER_EXCLUDES: str = Field( | ||||
| description='The excluded model providers', | |||||
| default='', | |||||
| description="The excluded model providers", | |||||
| default="", | |||||
| ) | ) | ||||
| POSITION_TOOL_PINS: str = Field( | POSITION_TOOL_PINS: str = Field( | ||||
| description='The heads of tools', | |||||
| default='', | |||||
| description="The heads of tools", | |||||
| default="", | |||||
| ) | ) | ||||
| POSITION_TOOL_INCLUDES: str = Field( | POSITION_TOOL_INCLUDES: str = Field( | ||||
| description='The included tools', | |||||
| default='', | |||||
| description="The included tools", | |||||
| default="", | |||||
| ) | ) | ||||
| POSITION_TOOL_EXCLUDES: str = Field( | POSITION_TOOL_EXCLUDES: str = Field( | ||||
| description='The excluded tools', | |||||
| default='', | |||||
| description="The excluded tools", | |||||
| 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( | ||||
| WorkflowConfig, | WorkflowConfig, | ||||
| WorkspaceConfig, | WorkspaceConfig, | ||||
| PositionConfig, | PositionConfig, | ||||
| # hosted services config | # hosted services config | ||||
| HostedServiceConfig, | HostedServiceConfig, | ||||
| CeleryBeatConfig, | CeleryBeatConfig, |
| """ | """ | ||||
| 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='', | |||||
| 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', | |||||
| 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", | |||||
| ) | ) | ||||
| 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='', | |||||
| 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', | |||||
| 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", | |||||
| ) | ) | ||||
| """ | """ | ||||
| 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, | ||||
| ) | ) | ||||
| """ | """ | ||||
| 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, | ||||
| ) | ) | ||||
| """ | """ | ||||
| HOSTED_MINIMAX_ENABLED: bool = Field( | HOSTED_MINIMAX_ENABLED: bool = Field( | ||||
| description='', | |||||
| description="", | |||||
| default=False, | default=False, | ||||
| ) | ) | ||||
| """ | """ | ||||
| HOSTED_SPARK_ENABLED: bool = Field( | HOSTED_SPARK_ENABLED: bool = Field( | ||||
| description='', | |||||
| description="", | |||||
| default=False, | default=False, | ||||
| ) | ) | ||||
| """ | """ | ||||
| HOSTED_ZHIPUAI_ENABLED: bool = Field( | HOSTED_ZHIPUAI_ENABLED: bool = Field( | ||||
| description='', | |||||
| description="", | |||||
| default=False, | default=False, | ||||
| ) | ) | ||||
| """ | """ | ||||
| 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='', | |||||
| default='', | |||||
| description="", | |||||
| default="", | |||||
| ) | ) | ||||
| """ | """ | ||||
| HOSTED_FETCH_APP_TEMPLATES_MODE: str = Field( | HOSTED_FETCH_APP_TEMPLATES_MODE: str = Field( | ||||
| description='the mode for fetching app templates,' | |||||
| ' default to remote,' | |||||
| ' available values: remote, db, builtin', | |||||
| default='remote', | |||||
| description="the mode for fetching app templates," | |||||
| " default to remote," | |||||
| " available values: remote, db, builtin", | |||||
| 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', | |||||
| default='https://tmpl.dify.ai', | |||||
| description="the domain for fetching remote app templates", | |||||
| default="https://tmpl.dify.ai", | |||||
| ) | ) | ||||
| HostedOpenAiConfig, | HostedOpenAiConfig, | ||||
| HostedSparkConfig, | HostedSparkConfig, | ||||
| HostedZhipuAIConfig, | HostedZhipuAIConfig, | ||||
| # moderation | # moderation | ||||
| HostedModerationConfig, | HostedModerationConfig, | ||||
| ): | ): |
| class StorageConfig(BaseSettings): | class StorageConfig(BaseSettings): | ||||
| STORAGE_TYPE: str = Field( | STORAGE_TYPE: str = Field( | ||||
| description='storage type,' | |||||
| ' default to `local`,' | |||||
| ' available values are `local`, `s3`, `azure-blob`, `aliyun-oss`, `google-storage`.', | |||||
| default='local', | |||||
| description="storage type," | |||||
| " default to `local`," | |||||
| " available values are `local`, `s3`, `azure-blob`, `aliyun-oss`, `google-storage`.", | |||||
| default="local", | |||||
| ) | ) | ||||
| STORAGE_LOCAL_PATH: str = Field( | STORAGE_LOCAL_PATH: str = Field( | ||||
| description='local storage path', | |||||
| default='storage', | |||||
| description="local storage path", | |||||
| 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', | |||||
| default='jieba', | |||||
| description="keyword store type", | |||||
| default="jieba", | |||||
| ) | ) | ||||
| class DatabaseConfig: | class DatabaseConfig: | ||||
| DB_HOST: str = Field( | DB_HOST: str = Field( | ||||
| description='db host', | |||||
| default='localhost', | |||||
| description="db host", | |||||
| 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', | |||||
| default='postgres', | |||||
| description="db username", | |||||
| default="postgres", | |||||
| ) | ) | ||||
| DB_PASSWORD: str = Field( | DB_PASSWORD: str = Field( | ||||
| description='db password', | |||||
| default='', | |||||
| description="db password", | |||||
| default="", | |||||
| ) | ) | ||||
| DB_DATABASE: str = Field( | DB_DATABASE: str = Field( | ||||
| description='db database', | |||||
| default='dify', | |||||
| description="db database", | |||||
| default="dify", | |||||
| ) | ) | ||||
| DB_CHARSET: str = Field( | DB_CHARSET: str = Field( | ||||
| description='db charset', | |||||
| default='', | |||||
| description="db charset", | |||||
| default="", | |||||
| ) | ) | ||||
| DB_EXTRAS: str = Field( | DB_EXTRAS: str = Field( | ||||
| description='db extras options. Example: keepalives_idle=60&keepalives=1', | |||||
| default='', | |||||
| description="db extras options. Example: keepalives_idle=60&keepalives=1", | |||||
| default="", | |||||
| ) | ) | ||||
| SQLALCHEMY_DATABASE_URI_SCHEME: str = Field( | SQLALCHEMY_DATABASE_URI_SCHEME: str = Field( | ||||
| description='db uri scheme', | |||||
| default='postgresql', | |||||
| description="db uri scheme", | |||||
| 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}" | |||||
| if self.DB_CHARSET | |||||
| else self.DB_EXTRAS | |||||
| f"{self.DB_EXTRAS}&client_encoding={self.DB_CHARSET}" 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}://" | |||||
| f"{quote_plus(self.DB_USERNAME)}:{quote_plus(self.DB_PASSWORD)}@{self.DB_HOST}:{self.DB_PORT}/{self.DB_DATABASE}" | |||||
| f"{db_extras}") | |||||
| 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"{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, | ||||
| ) | ) | ||||
| @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, | |||||
| 'max_overflow': self.SQLALCHEMY_MAX_OVERFLOW, | |||||
| 'pool_recycle': self.SQLALCHEMY_POOL_RECYCLE, | |||||
| 'pool_pre_ping': self.SQLALCHEMY_POOL_PRE_PING, | |||||
| 'connect_args': {'options': '-c timezone=UTC'}, | |||||
| "pool_size": self.SQLALCHEMY_POOL_SIZE, | |||||
| "max_overflow": self.SQLALCHEMY_MAX_OVERFLOW, | |||||
| "pool_recycle": self.SQLALCHEMY_POOL_RECYCLE, | |||||
| "pool_pre_ping": self.SQLALCHEMY_POOL_PRE_PING, | |||||
| "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`', | |||||
| default='database', | |||||
| description="Celery backend, available values are `database`, `redis`", | |||||
| 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) \ | |||||
| if self.CELERY_BACKEND == 'database' else self.CELERY_BROKER_URL | |||||
| return ( | |||||
| "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( | ||||
| DatabaseConfig, | DatabaseConfig, | ||||
| KeywordStoreConfig, | KeywordStoreConfig, | ||||
| RedisConfig, | RedisConfig, | ||||
| # configs of storage and storage providers | # configs of storage and storage providers | ||||
| StorageConfig, | StorageConfig, | ||||
| AliyunOSSStorageConfig, | AliyunOSSStorageConfig, | ||||
| TencentCloudCOSStorageConfig, | TencentCloudCOSStorageConfig, | ||||
| S3StorageConfig, | S3StorageConfig, | ||||
| OCIStorageConfig, | OCIStorageConfig, | ||||
| # configs of vdb and vdb providers | # configs of vdb and vdb providers | ||||
| VectorStoreConfig, | VectorStoreConfig, | ||||
| AnalyticdbConfig, | AnalyticdbConfig, |
| """ | """ | ||||
| Redis configs | Redis configs | ||||
| """ | """ | ||||
| REDIS_HOST: str = Field( | REDIS_HOST: str = Field( | ||||
| description='Redis host', | |||||
| default='localhost', | |||||
| description="Redis host", | |||||
| 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, | ||||
| ) | ) |
| """ | """ | ||||
| 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, | ||||
| ) | ) |
| """ | """ | ||||
| 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', | |||||
| default='auto', | |||||
| description="S3 storage address style", | |||||
| 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, | ||||
| ) | ) |
| """ | """ | ||||
| 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, | ||||
| ) | ) |
| """ | """ | ||||
| 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, | ||||
| ) | ) |
| """ | """ | ||||
| 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, | ||||
| ) | ) | ||||
| """ | """ | ||||
| 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, | ||||
| ) | ) |
| 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( | |||||
| default=None, | |||||
| description="The Access Key ID provided by Alibaba Cloud for authentication." | |||||
| ANALYTICDB_KEY_ID: Optional[str] = Field( | |||||
| default=None, description="The Access Key ID provided by Alibaba Cloud for authentication." | |||||
| ) | ) | ||||
| ANALYTICDB_KEY_SECRET : Optional[str] = Field( | |||||
| default=None, | |||||
| description="The Secret Access Key corresponding to the Access Key ID for secure access." | |||||
| ANALYTICDB_KEY_SECRET: Optional[str] = Field( | |||||
| default=None, description="The Secret Access Key corresponding to the Access Key ID for secure access." | |||||
| ) | ) | ||||
| ANALYTICDB_REGION_ID : Optional[str] = Field( | |||||
| default=None, | |||||
| description="The region where the AnalyticDB instance is deployed (e.g., 'cn-hangzhou')." | |||||
| ANALYTICDB_REGION_ID: Optional[str] = Field( | |||||
| default=None, 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( | |||||
| default=None, | |||||
| description="The account name used to log in to the AnalyticDB instance." | |||||
| ANALYTICDB_ACCOUNT: Optional[str] = Field( | |||||
| default=None, description="The account name used to log in to the AnalyticDB instance." | |||||
| ) | ) | ||||
| ANALYTICDB_PASSWORD : Optional[str] = Field( | |||||
| default=None, | |||||
| description="The password associated with the AnalyticDB account for authentication." | |||||
| ANALYTICDB_PASSWORD: Optional[str] = Field( | |||||
| default=None, description="The password associated with the AnalyticDB account for authentication." | |||||
| ) | ) | ||||
| ANALYTICDB_NAMESPACE : Optional[str] = Field( | |||||
| default=None, | |||||
| description="The namespace within AnalyticDB for schema isolation." | |||||
| ANALYTICDB_NAMESPACE: Optional[str] = Field( | |||||
| default=None, description="The namespace within AnalyticDB for schema isolation." | |||||
| ) | ) | ||||
| ANALYTICDB_NAMESPACE_PASSWORD : Optional[str] = Field( | |||||
| default=None, | |||||
| description="The password for accessing the specified namespace within the AnalyticDB instance." | |||||
| ANALYTICDB_NAMESPACE_PASSWORD: Optional[str] = Field( | |||||
| default=None, description="The password for accessing the specified namespace within the AnalyticDB instance." | |||||
| ) | ) |
| """ | """ | ||||
| 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, | ||||
| ) | ) |
| """ | """ | ||||
| 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`', | |||||
| default='default', | |||||
| description="Milvus database, default to `default`", | |||||
| default="default", | |||||
| ) | ) |
| from pydantic import BaseModel, Field, PositiveInt | from pydantic import BaseModel, Field, PositiveInt | ||||
| """ | """ | ||||
| MYSCALE_HOST: str = Field( | MYSCALE_HOST: str = Field( | ||||
| description='MyScale host', | |||||
| default='localhost', | |||||
| description="MyScale host", | |||||
| 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', | |||||
| default='default', | |||||
| description="MyScale user", | |||||
| default="default", | |||||
| ) | ) | ||||
| MYSCALE_PASSWORD: str = Field( | MYSCALE_PASSWORD: str = Field( | ||||
| description='MyScale password', | |||||
| default='', | |||||
| description="MyScale password", | |||||
| default="", | |||||
| ) | ) | ||||
| MYSCALE_DATABASE: str = Field( | MYSCALE_DATABASE: str = Field( | ||||
| description='MyScale database name', | |||||
| default='default', | |||||
| description="MyScale database name", | |||||
| default="default", | |||||
| ) | ) | ||||
| MYSCALE_FTS_PARAMS: str = Field( | MYSCALE_FTS_PARAMS: str = Field( | ||||
| description='MyScale fts index parameters', | |||||
| default='', | |||||
| description="MyScale fts index parameters", | |||||
| default="", | |||||
| ) | ) |
| """ | """ | ||||
| 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, | ||||
| ) | ) |
| """ | """ | ||||
| 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, | ||||
| ) | ) |
| """ | """ | ||||
| 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, | ||||
| ) | ) |
| """ | """ | ||||
| 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, | ||||
| ) | ) |
| """ | """ | ||||
| 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, | ||||
| ) | ) |
| """ | """ | ||||
| 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', | |||||
| default='default', | |||||
| description="Relyt database", | |||||
| default="default", | |||||
| ) | ) |
| """ | """ | ||||
| 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, | ||||
| ) | ) |
| """ | """ | ||||
| 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, | ||||
| ) | ) |
| """ | """ | ||||
| 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, | ||||
| ) | ) |
| """ | """ | ||||
| CURRENT_VERSION: str = Field( | CURRENT_VERSION: str = Field( | ||||
| description='Dify version', | |||||
| default='0.7.1', | |||||
| description="Dify version", | |||||
| 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="", | |||||
| ) | ) |
| "services/**/*.py", | "services/**/*.py", | ||||
| "tasks/**/*.py", | "tasks/**/*.py", | ||||
| "tests/**/*.py", | "tests/**/*.py", | ||||
| "configs/**/*.py", | |||||
| ] | ] | ||||
| [tool.pytest_env] | [tool.pytest_env] |