Browse Source

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

Bowen Liang 7 months ago
parent
commit
2da63654e5
31 changed files with 388 additions and 385 deletions
  1. 1 1
      api/configs/__init__.py
  2. 3 3
      api/configs/app_config.py
  3. 9 8
      api/configs/deploy/__init__.py
  4. 4 3
      api/configs/enterprise/__init__.py
  5. 6 5
      api/configs/extra/notion_config.py
  6. 4 3
      api/configs/extra/sentry_config.py
  7. 133 125
      api/configs/feature/__init__.py
  8. 50 51
      api/configs/feature/hosted_service/__init__.py
  9. 49 48
      api/configs/middleware/__init__.py
  10. 8 7
      api/configs/middleware/cache/redis_config.py
  11. 6 6
      api/configs/middleware/storage/aliyun_oss_storage_config.py
  12. 8 8
      api/configs/middleware/storage/amazon_s3_storage_config.py
  13. 4 4
      api/configs/middleware/storage/azure_blob_storage_config.py
  14. 2 2
      api/configs/middleware/storage/google_cloud_storage_config.py
  15. 5 6
      api/configs/middleware/storage/oci_storage_config.py
  16. 5 5
      api/configs/middleware/storage/tencent_cos_storage_config.py
  17. 16 23
      api/configs/middleware/vdb/analyticdb_config.py
  18. 6 6
      api/configs/middleware/vdb/chroma_config.py
  19. 7 7
      api/configs/middleware/vdb/milvus_config.py
  20. 11 12
      api/configs/middleware/vdb/myscale_config.py
  21. 5 5
      api/configs/middleware/vdb/opensearch_config.py
  22. 5 5
      api/configs/middleware/vdb/oracle_config.py
  23. 5 5
      api/configs/middleware/vdb/pgvector_config.py
  24. 5 5
      api/configs/middleware/vdb/pgvectors_config.py
  25. 5 5
      api/configs/middleware/vdb/qdrant_config.py
  26. 6 6
      api/configs/middleware/vdb/relyt_config.py
  27. 8 8
      api/configs/middleware/vdb/tencent_vector_config.py
  28. 5 5
      api/configs/middleware/vdb/tidb_vector_config.py
  29. 4 4
      api/configs/middleware/vdb/weaviate_config.py
  30. 3 3
      api/configs/packaging/__init__.py
  31. 0 1
      api/pyproject.toml

+ 1 - 1
api/configs/__init__.py

@@ -1,3 +1,3 @@
 from .app_config import DifyConfig
 
-dify_config = DifyConfig()
+dify_config = DifyConfig()

+ 3 - 3
api/configs/app_config.py

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

+ 9 - 8
api/configs/deploy/__init__.py

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

+ 4 - 3
api/configs/enterprise/__init__.py

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

+ 6 - 5
api/configs/extra/notion_config.py

@@ -8,27 +8,28 @@ class NotionConfig(BaseSettings):
     """
     Notion integration configs
     """
+
     NOTION_CLIENT_ID: Optional[str] = Field(
-        description='Notion client ID',
+        description="Notion client ID",
         default=None,
     )
 
     NOTION_CLIENT_SECRET: Optional[str] = Field(
-        description='Notion client secret key',
+        description="Notion client secret key",
         default=None,
     )
 
     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,
     )
 
     NOTION_INTERNAL_SECRET: Optional[str] = Field(
-        description='Notion internal secret key',
+        description="Notion internal secret key",
         default=None,
     )
 
     NOTION_INTEGRATION_TOKEN: Optional[str] = Field(
-        description='Notion integration token',
+        description="Notion integration token",
         default=None,
     )

+ 4 - 3
api/configs/extra/sentry_config.py

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

+ 133 - 125
api/configs/feature/__init__.py

@@ -10,16 +10,17 @@ class SecurityConfig(BaseSettings):
     """
     Secret Key configs
     """
+
     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,
     )
 
     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,
     )
 
@@ -28,12 +29,13 @@ class AppExecutionConfig(BaseSettings):
     """
     App Execution configs
     """
+
     APP_MAX_EXECUTION_TIME: PositiveInt = Field(
-        description='execution timeout in seconds for app execution',
+        description="execution timeout in seconds for app execution",
         default=1200,
     )
     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,
     )
 
@@ -42,53 +44,54 @@ class CodeExecutionSandboxConfig(BaseSettings):
     """
     Code Execution Sandbox configs
     """
+
     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(
-        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(
-        description='max depth for code execution',
+        description="max depth for code execution",
         default=9223372036854775807,
     )
 
     CODE_MIN_NUMBER: NegativeInt = Field(
-        description='',
+        description="",
         default=-9223372036854775807,
     )
 
     CODE_MAX_DEPTH: PositiveInt = Field(
-        description='max depth for code execution',
+        description="max depth for code execution",
         default=5,
     )
 
     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,
     )
 
     CODE_MAX_STRING_LENGTH: PositiveInt = Field(
-        description='max string length for code execution',
+        description="max string length for code execution",
         default=80000,
     )
 
     CODE_MAX_STRING_ARRAY_LENGTH: PositiveInt = Field(
-        description='',
+        description="",
         default=30,
     )
 
     CODE_MAX_OBJECT_ARRAY_LENGTH: PositiveInt = Field(
-        description='',
+        description="",
         default=30,
     )
 
     CODE_MAX_NUMBER_ARRAY_LENGTH: PositiveInt = Field(
-        description='',
+        description="",
         default=1000,
     )
 
@@ -97,28 +100,27 @@ class EndpointConfig(BaseSettings):
     """
     Module URL configs
     """
+
     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(
-        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(
-        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(
-        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="",
     )
 
 
@@ -126,17 +128,18 @@ class FileAccessConfig(BaseSettings):
     """
     File Access configs
     """
+
     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,
-        default='',
+        default="",
     )
 
     FILES_ACCESS_TIMEOUT: int = Field(
-        description='timeout in seconds for file accessing',
+        description="timeout in seconds for file accessing",
         default=300,
     )
 
@@ -145,23 +148,24 @@ class FileUploadConfig(BaseSettings):
     """
     File Uploading configs
     """
+
     UPLOAD_FILE_SIZE_LIMIT: NonNegativeInt = Field(
-        description='size limit in Megabytes for uploading files',
+        description="size limit in Megabytes for uploading files",
         default=15,
     )
 
     UPLOAD_FILE_BATCH_LIMIT: NonNegativeInt = Field(
-        description='batch size limit for uploading files',
+        description="batch size limit for uploading files",
         default=5,
     )
 
     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,
     )
 
     BATCH_UPLOAD_LIMIT: NonNegativeInt = Field(
-        description='',  # todo: to be clarified
+        description="",  # todo: to be clarified
         default=20,
     )
 
@@ -170,65 +174,66 @@ class HttpConfig(BaseSettings):
     """
     HTTP configs
     """
+
     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,
     )
 
     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
     @property
     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(
-        description='',
-        validation_alias=AliasChoices('WEB_API_CORS_ALLOW_ORIGINS'),
-        default='*',
+        description="",
+        validation_alias=AliasChoices("WEB_API_CORS_ALLOW_ORIGINS"),
+        default="*",
     )
 
     @computed_field
     @property
     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(
-        description='',
+        description="",
         default=300,
     )
 
     HTTP_REQUEST_MAX_READ_TIMEOUT: NonNegativeInt = Field(
-        description='',
+        description="",
         default=600,
     )
 
     HTTP_REQUEST_MAX_WRITE_TIMEOUT: NonNegativeInt = Field(
-        description='',
+        description="",
         default=600,
     )
 
     HTTP_REQUEST_NODE_MAX_BINARY_SIZE: PositiveInt = Field(
-        description='',
+        description="",
         default=10 * 1024 * 1024,
     )
 
     HTTP_REQUEST_NODE_MAX_TEXT_SIZE: PositiveInt = Field(
-        description='',
+        description="",
         default=1 * 1024 * 1024,
     )
 
     SSRF_PROXY_HTTP_URL: Optional[str] = Field(
-        description='HTTP URL for SSRF proxy',
+        description="HTTP URL for SSRF proxy",
         default=None,
     )
 
     SSRF_PROXY_HTTPS_URL: Optional[str] = Field(
-        description='HTTPS URL for SSRF proxy',
+        description="HTTPS URL for SSRF proxy",
         default=None,
     )
 
@@ -237,13 +242,14 @@ class InnerAPIConfig(BaseSettings):
     """
     Inner API configs
     """
+
     INNER_API: bool = Field(
-        description='whether to enable the inner API',
+        description="whether to enable the inner API",
         default=False,
     )
 
     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,
     )
 
@@ -254,28 +260,27 @@ class LoggingConfig(BaseSettings):
     """
 
     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(
-        description='logging output file path',
+        description="logging output file path",
         default=None,
     )
 
     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(
-        description='log date format',
+        description="log date format",
         default=None,
     )
 
     LOG_TZ: Optional[str] = Field(
-        description='specify log timezone, eg: America/New_York',
+        description="specify log timezone, eg: America/New_York",
         default=None,
     )
 
@@ -284,8 +289,9 @@ class ModelLoadBalanceConfig(BaseSettings):
     """
     Model load balance configs
     """
+
     MODEL_LB_ENABLED: bool = Field(
-        description='whether to enable model load balancing',
+        description="whether to enable model load balancing",
         default=False,
     )
 
@@ -294,8 +300,9 @@ class BillingConfig(BaseSettings):
     """
     Platform Billing Configurations
     """
+
     BILLING_ENABLED: bool = Field(
-        description='whether to enable billing',
+        description="whether to enable billing",
         default=False,
     )
 
@@ -304,9 +311,10 @@ class UpdateConfig(BaseSettings):
     """
     Update configs
     """
+
     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",
     )
 
 
@@ -316,22 +324,22 @@ class WorkflowConfig(BaseSettings):
     """
 
     WORKFLOW_MAX_EXECUTION_STEPS: PositiveInt = Field(
-        description='max execution steps in single workflow execution',
+        description="max execution steps in single workflow execution",
         default=500,
     )
 
     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,
     )
 
     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,
     )
 
     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,
     )
 
@@ -340,28 +348,29 @@ class OAuthConfig(BaseSettings):
     """
     oauth configs
     """
+
     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(
-        description='GitHub client id for OAuth',
+        description="GitHub client id for OAuth",
         default=None,
     )
 
     GITHUB_CLIENT_SECRET: Optional[str] = Field(
-        description='GitHub client secret key for OAuth',
+        description="GitHub client secret key for OAuth",
         default=None,
     )
 
     GOOGLE_CLIENT_ID: Optional[str] = Field(
-        description='Google client id for OAuth',
+        description="Google client id for OAuth",
         default=None,
     )
 
     GOOGLE_CLIENT_SECRET: Optional[str] = Field(
-        description='Google client secret key for OAuth',
+        description="Google client secret key for OAuth",
         default=None,
     )
 
@@ -372,7 +381,7 @@ class ModerationConfig(BaseSettings):
     """
 
     MODERATION_BUFFER_SIZE: PositiveInt = Field(
-        description='buffer size for moderation',
+        description="buffer size for moderation",
         default=300,
     )
 
@@ -383,7 +392,7 @@ class ToolConfig(BaseSettings):
     """
 
     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,
     )
 
@@ -394,52 +403,52 @@ class MailConfig(BaseSettings):
     """
 
     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,
     )
 
     MAIL_DEFAULT_SEND_FROM: Optional[str] = Field(
-        description='default email address for sending from ',
+        description="default email address for sending from ",
         default=None,
     )
 
     RESEND_API_KEY: Optional[str] = Field(
-        description='API key for Resend',
+        description="API key for Resend",
         default=None,
     )
 
     RESEND_API_URL: Optional[str] = Field(
-        description='API URL for Resend',
+        description="API URL for Resend",
         default=None,
     )
 
     SMTP_SERVER: Optional[str] = Field(
-        description='smtp server host',
+        description="smtp server host",
         default=None,
     )
 
     SMTP_PORT: Optional[int] = Field(
-        description='smtp server port',
+        description="smtp server port",
         default=465,
     )
 
     SMTP_USERNAME: Optional[str] = Field(
-        description='smtp server username',
+        description="smtp server username",
         default=None,
     )
 
     SMTP_PASSWORD: Optional[str] = Field(
-        description='smtp server password',
+        description="smtp server password",
         default=None,
     )
 
     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,
     )
 
     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,
     )
 
@@ -450,22 +459,22 @@ class RagEtlConfig(BaseSettings):
     """
 
     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(
-        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(
-        description='API URL for Unstructured',
+        description="API URL for Unstructured",
         default=None,
     )
 
     UNSTRUCTURED_API_KEY: Optional[str] = Field(
-        description='API key for Unstructured',
+        description="API key for Unstructured",
         default=None,
     )
 
@@ -476,12 +485,12 @@ class DataSetConfig(BaseSettings):
     """
 
     CLEAN_DAY_SETTING: PositiveInt = Field(
-        description='interval in days for cleaning up dataset',
+        description="interval in days for cleaning up dataset",
         default=30,
     )
 
     DATASET_OPERATOR_ENABLED: bool = Field(
-        description='whether to enable dataset operator',
+        description="whether to enable dataset operator",
         default=False,
     )
 
@@ -492,7 +501,7 @@ class WorkspaceConfig(BaseSettings):
     """
 
     INVITE_EXPIRY_HOURS: PositiveInt = Field(
-        description='workspaces invitation expiration in hours',
+        description="workspaces invitation expiration in hours",
         default=72,
     )
 
@@ -503,79 +512,79 @@ class IndexingConfig(BaseSettings):
     """
 
     INDEXING_MAX_SEGMENTATION_TOKENS_LENGTH: PositiveInt = Field(
-        description='max segmentation token length for indexing',
+        description="max segmentation token length for indexing",
         default=1000,
     )
 
 
 class ImageFormatConfig(BaseSettings):
     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):
     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,
     )
 
 
 class PositionConfig(BaseSettings):
     POSITION_PROVIDER_PINS: str = Field(
-        description='The heads of model providers',
-        default='',
+        description="The heads of model providers",
+        default="",
     )
 
     POSITION_PROVIDER_INCLUDES: str = Field(
-        description='The included model providers',
-        default='',
+        description="The included model providers",
+        default="",
     )
 
     POSITION_PROVIDER_EXCLUDES: str = Field(
-        description='The excluded model providers',
-        default='',
+        description="The excluded model providers",
+        default="",
     )
 
     POSITION_TOOL_PINS: str = Field(
-        description='The heads of tools',
-        default='',
+        description="The heads of tools",
+        default="",
     )
 
     POSITION_TOOL_INCLUDES: str = Field(
-        description='The included tools',
-        default='',
+        description="The included tools",
+        default="",
     )
 
     POSITION_TOOL_EXCLUDES: str = Field(
-        description='The excluded tools',
-        default='',
+        description="The excluded tools",
+        default="",
     )
 
     @computed_field
     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
     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
     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
     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
     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
     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(
@@ -603,7 +612,6 @@ class FeatureConfig(
     WorkflowConfig,
     WorkspaceConfig,
     PositionConfig,
-
     # hosted services config
     HostedServiceConfig,
     CeleryBeatConfig,

+ 50 - 51
api/configs/feature/hosted_service/__init__.py

@@ -10,62 +10,62 @@ class HostedOpenAiConfig(BaseSettings):
     """
 
     HOSTED_OPENAI_API_KEY: Optional[str] = Field(
-        description='',
+        description="",
         default=None,
     )
 
     HOSTED_OPENAI_API_BASE: Optional[str] = Field(
-        description='',
+        description="",
         default=None,
     )
 
     HOSTED_OPENAI_API_ORGANIZATION: Optional[str] = Field(
-        description='',
+        description="",
         default=None,
     )
 
     HOSTED_OPENAI_TRIAL_ENABLED: bool = Field(
-        description='',
+        description="",
         default=False,
     )
 
     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(
-        description='',
+        description="",
         default=200,
     )
 
     HOSTED_OPENAI_PAID_ENABLED: bool = Field(
-        description='',
+        description="",
         default=False,
     )
 
     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",
     )
 
 
@@ -75,22 +75,22 @@ class HostedAzureOpenAiConfig(BaseSettings):
     """
 
     HOSTED_AZURE_OPENAI_ENABLED: bool = Field(
-        description='',
+        description="",
         default=False,
     )
 
     HOSTED_AZURE_OPENAI_API_KEY: Optional[str] = Field(
-        description='',
+        description="",
         default=None,
     )
 
     HOSTED_AZURE_OPENAI_API_BASE: Optional[str] = Field(
-        description='',
+        description="",
         default=None,
     )
 
     HOSTED_AZURE_OPENAI_QUOTA_LIMIT: NonNegativeInt = Field(
-        description='',
+        description="",
         default=200,
     )
 
@@ -101,27 +101,27 @@ class HostedAnthropicConfig(BaseSettings):
     """
 
     HOSTED_ANTHROPIC_API_BASE: Optional[str] = Field(
-        description='',
+        description="",
         default=None,
     )
 
     HOSTED_ANTHROPIC_API_KEY: Optional[str] = Field(
-        description='',
+        description="",
         default=None,
     )
 
     HOSTED_ANTHROPIC_TRIAL_ENABLED: bool = Field(
-        description='',
+        description="",
         default=False,
     )
 
     HOSTED_ANTHROPIC_QUOTA_LIMIT: NonNegativeInt = Field(
-        description='',
+        description="",
         default=600000,
     )
 
     HOSTED_ANTHROPIC_PAID_ENABLED: bool = Field(
-        description='',
+        description="",
         default=False,
     )
 
@@ -132,7 +132,7 @@ class HostedMinmaxConfig(BaseSettings):
     """
 
     HOSTED_MINIMAX_ENABLED: bool = Field(
-        description='',
+        description="",
         default=False,
     )
 
@@ -143,7 +143,7 @@ class HostedSparkConfig(BaseSettings):
     """
 
     HOSTED_SPARK_ENABLED: bool = Field(
-        description='',
+        description="",
         default=False,
     )
 
@@ -154,7 +154,7 @@ class HostedZhipuAIConfig(BaseSettings):
     """
 
     HOSTED_ZHIPUAI_ENABLED: bool = Field(
-        description='',
+        description="",
         default=False,
     )
 
@@ -165,13 +165,13 @@ class HostedModerationConfig(BaseSettings):
     """
 
     HOSTED_MODERATION_ENABLED: bool = Field(
-        description='',
+        description="",
         default=False,
     )
 
     HOSTED_MODERATION_PROVIDERS: str = Field(
-        description='',
-        default='',
+        description="",
+        default="",
     )
 
 
@@ -181,15 +181,15 @@ class HostedFetchAppTemplateConfig(BaseSettings):
     """
 
     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(
-        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",
     )
 
 
@@ -202,7 +202,6 @@ class HostedServiceConfig(
     HostedOpenAiConfig,
     HostedSparkConfig,
     HostedZhipuAIConfig,
-
     # moderation
     HostedModerationConfig,
 ):

+ 49 - 48
api/configs/middleware/__init__.py

@@ -28,108 +28,108 @@ from configs.middleware.vdb.weaviate_config import WeaviateConfig
 
 class StorageConfig(BaseSettings):
     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(
-        description='local storage path',
-        default='storage',
+        description="local storage path",
+        default="storage",
     )
 
 
 class VectorStoreConfig(BaseSettings):
     VECTOR_STORE: Optional[str] = Field(
-        description='vector store type',
+        description="vector store type",
         default=None,
     )
 
 
 class KeywordStoreConfig(BaseSettings):
     KEYWORD_STORE: str = Field(
-        description='keyword store type',
-        default='jieba',
+        description="keyword store type",
+        default="jieba",
     )
 
 
 class DatabaseConfig:
     DB_HOST: str = Field(
-        description='db host',
-        default='localhost',
+        description="db host",
+        default="localhost",
     )
 
     DB_PORT: PositiveInt = Field(
-        description='db port',
+        description="db port",
         default=5432,
     )
 
     DB_USERNAME: str = Field(
-        description='db username',
-        default='postgres',
+        description="db username",
+        default="postgres",
     )
 
     DB_PASSWORD: str = Field(
-        description='db password',
-        default='',
+        description="db password",
+        default="",
     )
 
     DB_DATABASE: str = Field(
-        description='db database',
-        default='dify',
+        description="db database",
+        default="dify",
     )
 
     DB_CHARSET: str = Field(
-        description='db charset',
-        default='',
+        description="db charset",
+        default="",
     )
 
     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(
-        description='db uri scheme',
-        default='postgresql',
+        description="db uri scheme",
+        default="postgresql",
     )
 
     @computed_field
     @property
     def SQLALCHEMY_DATABASE_URI(self) -> str:
         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("&")
         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(
-        description='pool size of SqlAlchemy',
+        description="pool size of SqlAlchemy",
         default=30,
     )
 
     SQLALCHEMY_MAX_OVERFLOW: NonNegativeInt = Field(
-        description='max overflows for SqlAlchemy',
+        description="max overflows for SqlAlchemy",
         default=10,
     )
 
     SQLALCHEMY_POOL_RECYCLE: NonNegativeInt = Field(
-        description='SqlAlchemy pool recycle',
+        description="SqlAlchemy pool recycle",
         default=3600,
     )
 
     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,
     )
 
     SQLALCHEMY_ECHO: bool | str = Field(
-        description='whether to enable SqlAlchemy echo',
+        description="whether to enable SqlAlchemy echo",
         default=False,
     )
 
@@ -137,35 +137,38 @@ class DatabaseConfig:
     @property
     def SQLALCHEMY_ENGINE_OPTIONS(self) -> dict[str, Any]:
         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):
     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(
-        description='CELERY_BROKER_URL',
+        description="CELERY_BROKER_URL",
         default=None,
     )
 
     @computed_field
     @property
     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
     @property
     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(
@@ -174,7 +177,6 @@ class MiddlewareConfig(
     DatabaseConfig,
     KeywordStoreConfig,
     RedisConfig,
-
     # configs of storage and storage providers
     StorageConfig,
     AliyunOSSStorageConfig,
@@ -183,7 +185,6 @@ class MiddlewareConfig(
     TencentCloudCOSStorageConfig,
     S3StorageConfig,
     OCIStorageConfig,
-
     # configs of vdb and vdb providers
     VectorStoreConfig,
     AnalyticdbConfig,

+ 8 - 7
api/configs/middleware/cache/redis_config.py

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

+ 6 - 6
api/configs/middleware/storage/aliyun_oss_storage_config.py

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

+ 8 - 8
api/configs/middleware/storage/amazon_s3_storage_config.py

@@ -10,36 +10,36 @@ class S3StorageConfig(BaseSettings):
     """
 
     S3_ENDPOINT: Optional[str] = Field(
-        description='S3 storage endpoint',
+        description="S3 storage endpoint",
         default=None,
     )
 
     S3_REGION: Optional[str] = Field(
-        description='S3 storage region',
+        description="S3 storage region",
         default=None,
     )
 
     S3_BUCKET_NAME: Optional[str] = Field(
-        description='S3 storage bucket name',
+        description="S3 storage bucket name",
         default=None,
     )
 
     S3_ACCESS_KEY: Optional[str] = Field(
-        description='S3 storage access key',
+        description="S3 storage access key",
         default=None,
     )
 
     S3_SECRET_KEY: Optional[str] = Field(
-        description='S3 storage secret key',
+        description="S3 storage secret key",
         default=None,
     )
 
     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(
-        description='whether to use aws managed IAM for S3',
+        description="whether to use aws managed IAM for S3",
         default=False,
     )

+ 4 - 4
api/configs/middleware/storage/azure_blob_storage_config.py

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

+ 2 - 2
api/configs/middleware/storage/google_cloud_storage_config.py

@@ -10,11 +10,11 @@ class GoogleCloudStorageConfig(BaseSettings):
     """
 
     GOOGLE_STORAGE_BUCKET_NAME: Optional[str] = Field(
-        description='Google Cloud storage bucket name',
+        description="Google Cloud storage bucket name",
         default=None,
     )
 
     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,
     )

+ 5 - 6
api/configs/middleware/storage/oci_storage_config.py

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

+ 5 - 5
api/configs/middleware/storage/tencent_cos_storage_config.py

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

+ 16 - 23
api/configs/middleware/vdb/analyticdb_config.py

@@ -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
     """
 
-    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,
-        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."
     )

+ 6 - 6
api/configs/middleware/vdb/chroma_config.py

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

+ 7 - 7
api/configs/middleware/vdb/milvus_config.py

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

+ 11 - 12
api/configs/middleware/vdb/myscale_config.py

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

+ 5 - 5
api/configs/middleware/vdb/opensearch_config.py

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

+ 5 - 5
api/configs/middleware/vdb/oracle_config.py

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

+ 5 - 5
api/configs/middleware/vdb/pgvector_config.py

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

+ 5 - 5
api/configs/middleware/vdb/pgvectors_config.py

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

+ 5 - 5
api/configs/middleware/vdb/qdrant_config.py

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

+ 6 - 6
api/configs/middleware/vdb/relyt_config.py

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

+ 8 - 8
api/configs/middleware/vdb/tencent_vector_config.py

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

+ 5 - 5
api/configs/middleware/vdb/tidb_vector_config.py

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

+ 4 - 4
api/configs/middleware/vdb/weaviate_config.py

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

+ 3 - 3
api/configs/packaging/__init__.py

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

+ 0 - 1
api/pyproject.toml

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