__init__.py 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818
  1. from typing import Annotated, Literal, Optional
  2. from pydantic import (
  3. AliasChoices,
  4. Field,
  5. HttpUrl,
  6. NegativeInt,
  7. NonNegativeInt,
  8. PositiveFloat,
  9. PositiveInt,
  10. computed_field,
  11. )
  12. from pydantic_settings import BaseSettings
  13. from configs.feature.hosted_service import HostedServiceConfig
  14. class SecurityConfig(BaseSettings):
  15. """
  16. Security-related configurations for the application
  17. """
  18. SECRET_KEY: str = Field(
  19. description="Secret key for secure session cookie signing."
  20. "Make sure you are changing this key for your deployment with a strong key."
  21. "Generate a strong key using `openssl rand -base64 42` or set via the `SECRET_KEY` environment variable.",
  22. default="",
  23. )
  24. RESET_PASSWORD_TOKEN_EXPIRY_MINUTES: PositiveInt = Field(
  25. description="Duration in minutes for which a password reset token remains valid",
  26. default=5,
  27. )
  28. LOGIN_DISABLED: bool = Field(
  29. description="Whether to disable login checks",
  30. default=False,
  31. )
  32. ADMIN_API_KEY_ENABLE: bool = Field(
  33. description="Whether to enable admin api key for authentication",
  34. default=False,
  35. )
  36. ADMIN_API_KEY: Optional[str] = Field(
  37. description="admin api key for authentication",
  38. default=None,
  39. )
  40. class AppExecutionConfig(BaseSettings):
  41. """
  42. Configuration parameters for application execution
  43. """
  44. APP_MAX_EXECUTION_TIME: PositiveInt = Field(
  45. description="Maximum allowed execution time for the application in seconds",
  46. default=1200,
  47. )
  48. APP_MAX_ACTIVE_REQUESTS: NonNegativeInt = Field(
  49. description="Maximum number of concurrent active requests per app (0 for unlimited)",
  50. default=0,
  51. )
  52. class CodeExecutionSandboxConfig(BaseSettings):
  53. """
  54. Configuration for the code execution sandbox environment
  55. """
  56. CODE_EXECUTION_ENDPOINT: HttpUrl = Field(
  57. description="URL endpoint for the code execution service",
  58. default="http://sandbox:8194",
  59. )
  60. CODE_EXECUTION_API_KEY: str = Field(
  61. description="API key for accessing the code execution service",
  62. default="dify-sandbox",
  63. )
  64. CODE_EXECUTION_CONNECT_TIMEOUT: Optional[float] = Field(
  65. description="Connection timeout in seconds for code execution requests",
  66. default=10.0,
  67. )
  68. CODE_EXECUTION_READ_TIMEOUT: Optional[float] = Field(
  69. description="Read timeout in seconds for code execution requests",
  70. default=60.0,
  71. )
  72. CODE_EXECUTION_WRITE_TIMEOUT: Optional[float] = Field(
  73. description="Write timeout in seconds for code execution request",
  74. default=10.0,
  75. )
  76. CODE_MAX_NUMBER: PositiveInt = Field(
  77. description="Maximum allowed numeric value in code execution",
  78. default=9223372036854775807,
  79. )
  80. CODE_MIN_NUMBER: NegativeInt = Field(
  81. description="Minimum allowed numeric value in code execution",
  82. default=-9223372036854775807,
  83. )
  84. CODE_MAX_DEPTH: PositiveInt = Field(
  85. description="Maximum allowed depth for nested structures in code execution",
  86. default=5,
  87. )
  88. CODE_MAX_PRECISION: PositiveInt = Field(
  89. description="Maximum number of decimal places for floating-point numbers in code execution",
  90. default=20,
  91. )
  92. CODE_MAX_STRING_LENGTH: PositiveInt = Field(
  93. description="Maximum allowed length for strings in code execution",
  94. default=80000,
  95. )
  96. CODE_MAX_STRING_ARRAY_LENGTH: PositiveInt = Field(
  97. description="Maximum allowed length for string arrays in code execution",
  98. default=30,
  99. )
  100. CODE_MAX_OBJECT_ARRAY_LENGTH: PositiveInt = Field(
  101. description="Maximum allowed length for object arrays in code execution",
  102. default=30,
  103. )
  104. CODE_MAX_NUMBER_ARRAY_LENGTH: PositiveInt = Field(
  105. description="Maximum allowed length for numeric arrays in code execution",
  106. default=1000,
  107. )
  108. class EndpointConfig(BaseSettings):
  109. """
  110. Configuration for various application endpoints and URLs
  111. """
  112. CONSOLE_API_URL: str = Field(
  113. description="Base URL for the console API,"
  114. "used for login authentication callback or notion integration callbacks",
  115. default="",
  116. )
  117. CONSOLE_WEB_URL: str = Field(
  118. description="Base URL for the console web interface," "used for frontend references and CORS configuration",
  119. default="",
  120. )
  121. SERVICE_API_URL: str = Field(
  122. description="Base URL for the service API, displayed to users for API access",
  123. default="",
  124. )
  125. APP_WEB_URL: str = Field(
  126. description="Base URL for the web application, used for frontend references",
  127. default="",
  128. )
  129. class FileAccessConfig(BaseSettings):
  130. """
  131. Configuration for file access and handling
  132. """
  133. FILES_URL: str = Field(
  134. description="Base URL for file preview or download,"
  135. " used for frontend display and multi-model inputs"
  136. "Url is signed and has expiration time.",
  137. validation_alias=AliasChoices("FILES_URL", "CONSOLE_API_URL"),
  138. alias_priority=1,
  139. default="",
  140. )
  141. FILES_ACCESS_TIMEOUT: int = Field(
  142. description="Expiration time in seconds for file access URLs",
  143. default=300,
  144. )
  145. class FileUploadConfig(BaseSettings):
  146. """
  147. Configuration for file upload limitations
  148. """
  149. UPLOAD_FILE_SIZE_LIMIT: NonNegativeInt = Field(
  150. description="Maximum allowed file size for uploads in megabytes",
  151. default=15,
  152. )
  153. UPLOAD_FILE_BATCH_LIMIT: NonNegativeInt = Field(
  154. description="Maximum number of files allowed in a single upload batch",
  155. default=5,
  156. )
  157. UPLOAD_IMAGE_FILE_SIZE_LIMIT: NonNegativeInt = Field(
  158. description="Maximum allowed image file size for uploads in megabytes",
  159. default=10,
  160. )
  161. UPLOAD_VIDEO_FILE_SIZE_LIMIT: NonNegativeInt = Field(
  162. description="video file size limit in Megabytes for uploading files",
  163. default=100,
  164. )
  165. UPLOAD_AUDIO_FILE_SIZE_LIMIT: NonNegativeInt = Field(
  166. description="audio file size limit in Megabytes for uploading files",
  167. default=50,
  168. )
  169. BATCH_UPLOAD_LIMIT: NonNegativeInt = Field(
  170. description="Maximum number of files allowed in a batch upload operation",
  171. default=20,
  172. )
  173. WORKFLOW_FILE_UPLOAD_LIMIT: PositiveInt = Field(
  174. description="Maximum number of files allowed in a workflow upload operation",
  175. default=10,
  176. )
  177. class HttpConfig(BaseSettings):
  178. """
  179. HTTP-related configurations for the application
  180. """
  181. API_COMPRESSION_ENABLED: bool = Field(
  182. description="Enable or disable gzip compression for HTTP responses",
  183. default=False,
  184. )
  185. inner_CONSOLE_CORS_ALLOW_ORIGINS: str = Field(
  186. description="Comma-separated list of allowed origins for CORS in the console",
  187. validation_alias=AliasChoices("CONSOLE_CORS_ALLOW_ORIGINS", "CONSOLE_WEB_URL"),
  188. default="",
  189. )
  190. @computed_field
  191. def CONSOLE_CORS_ALLOW_ORIGINS(self) -> list[str]:
  192. return self.inner_CONSOLE_CORS_ALLOW_ORIGINS.split(",")
  193. inner_WEB_API_CORS_ALLOW_ORIGINS: str = Field(
  194. description="",
  195. validation_alias=AliasChoices("WEB_API_CORS_ALLOW_ORIGINS"),
  196. default="*",
  197. )
  198. @computed_field
  199. def WEB_API_CORS_ALLOW_ORIGINS(self) -> list[str]:
  200. return self.inner_WEB_API_CORS_ALLOW_ORIGINS.split(",")
  201. HTTP_REQUEST_MAX_CONNECT_TIMEOUT: Annotated[
  202. PositiveInt, Field(ge=10, description="Maximum connection timeout in seconds for HTTP requests")
  203. ] = 10
  204. HTTP_REQUEST_MAX_READ_TIMEOUT: Annotated[
  205. PositiveInt, Field(ge=60, description="Maximum read timeout in seconds for HTTP requests")
  206. ] = 60
  207. HTTP_REQUEST_MAX_WRITE_TIMEOUT: Annotated[
  208. PositiveInt, Field(ge=10, description="Maximum write timeout in seconds for HTTP requests")
  209. ] = 20
  210. HTTP_REQUEST_NODE_MAX_BINARY_SIZE: PositiveInt = Field(
  211. description="Maximum allowed size in bytes for binary data in HTTP requests",
  212. default=10 * 1024 * 1024,
  213. )
  214. HTTP_REQUEST_NODE_MAX_TEXT_SIZE: PositiveInt = Field(
  215. description="Maximum allowed size in bytes for text data in HTTP requests",
  216. default=1 * 1024 * 1024,
  217. )
  218. SSRF_DEFAULT_MAX_RETRIES: PositiveInt = Field(
  219. description="Maximum number of retries for network requests (SSRF)",
  220. default=3,
  221. )
  222. SSRF_PROXY_ALL_URL: Optional[str] = Field(
  223. description="Proxy URL for HTTP or HTTPS requests to prevent Server-Side Request Forgery (SSRF)",
  224. default=None,
  225. )
  226. SSRF_PROXY_HTTP_URL: Optional[str] = Field(
  227. description="Proxy URL for HTTP requests to prevent Server-Side Request Forgery (SSRF)",
  228. default=None,
  229. )
  230. SSRF_PROXY_HTTPS_URL: Optional[str] = Field(
  231. description="Proxy URL for HTTPS requests to prevent Server-Side Request Forgery (SSRF)",
  232. default=None,
  233. )
  234. SSRF_DEFAULT_TIME_OUT: PositiveFloat = Field(
  235. description="The default timeout period used for network requests (SSRF)",
  236. default=5,
  237. )
  238. SSRF_DEFAULT_CONNECT_TIME_OUT: PositiveFloat = Field(
  239. description="The default connect timeout period used for network requests (SSRF)",
  240. default=5,
  241. )
  242. SSRF_DEFAULT_READ_TIME_OUT: PositiveFloat = Field(
  243. description="The default read timeout period used for network requests (SSRF)",
  244. default=5,
  245. )
  246. SSRF_DEFAULT_WRITE_TIME_OUT: PositiveFloat = Field(
  247. description="The default write timeout period used for network requests (SSRF)",
  248. default=5,
  249. )
  250. RESPECT_XFORWARD_HEADERS_ENABLED: bool = Field(
  251. description="Enable or disable the X-Forwarded-For Proxy Fix middleware from Werkzeug"
  252. " to respect X-* headers to redirect clients",
  253. default=False,
  254. )
  255. class InnerAPIConfig(BaseSettings):
  256. """
  257. Configuration for internal API functionality
  258. """
  259. INNER_API: bool = Field(
  260. description="Enable or disable the internal API",
  261. default=False,
  262. )
  263. INNER_API_KEY: Optional[str] = Field(
  264. description="API key for accessing the internal API",
  265. default=None,
  266. )
  267. class LoggingConfig(BaseSettings):
  268. """
  269. Configuration for application logging
  270. """
  271. LOG_LEVEL: str = Field(
  272. description="Logging level, default to INFO. Set to ERROR for production environments.",
  273. default="INFO",
  274. )
  275. LOG_FILE: Optional[str] = Field(
  276. description="File path for log output.",
  277. default=None,
  278. )
  279. LOG_FILE_MAX_SIZE: PositiveInt = Field(
  280. description="Maximum file size for file rotation retention, the unit is megabytes (MB)",
  281. default=20,
  282. )
  283. LOG_FILE_BACKUP_COUNT: PositiveInt = Field(
  284. description="Maximum file backup count file rotation retention",
  285. default=5,
  286. )
  287. LOG_FORMAT: str = Field(
  288. description="Format string for log messages",
  289. default="%(asctime)s.%(msecs)03d %(levelname)s [%(threadName)s] [%(filename)s:%(lineno)d] - %(message)s",
  290. )
  291. LOG_DATEFORMAT: Optional[str] = Field(
  292. description="Date format string for log timestamps",
  293. default=None,
  294. )
  295. LOG_TZ: Optional[str] = Field(
  296. description="Timezone for log timestamps (e.g., 'America/New_York')",
  297. default="UTC",
  298. )
  299. class ModelLoadBalanceConfig(BaseSettings):
  300. """
  301. Configuration for model load balancing
  302. """
  303. MODEL_LB_ENABLED: bool = Field(
  304. description="Enable or disable load balancing for models",
  305. default=False,
  306. )
  307. class BillingConfig(BaseSettings):
  308. """
  309. Configuration for platform billing features
  310. """
  311. BILLING_ENABLED: bool = Field(
  312. description="Enable or disable billing functionality",
  313. default=False,
  314. )
  315. class UpdateConfig(BaseSettings):
  316. """
  317. Configuration for application update checks
  318. """
  319. CHECK_UPDATE_URL: str = Field(
  320. description="URL to check for application updates",
  321. default="https://updates.dify.ai",
  322. )
  323. class WorkflowConfig(BaseSettings):
  324. """
  325. Configuration for workflow execution
  326. """
  327. WORKFLOW_MAX_EXECUTION_STEPS: PositiveInt = Field(
  328. description="Maximum number of steps allowed in a single workflow execution",
  329. default=500,
  330. )
  331. WORKFLOW_MAX_EXECUTION_TIME: PositiveInt = Field(
  332. description="Maximum execution time in seconds for a single workflow",
  333. default=1200,
  334. )
  335. WORKFLOW_CALL_MAX_DEPTH: PositiveInt = Field(
  336. description="Maximum allowed depth for nested workflow calls",
  337. default=5,
  338. )
  339. WORKFLOW_PARALLEL_DEPTH_LIMIT: PositiveInt = Field(
  340. description="Maximum allowed depth for nested parallel executions",
  341. default=3,
  342. )
  343. MAX_VARIABLE_SIZE: PositiveInt = Field(
  344. description="Maximum size in bytes for a single variable in workflows. Default to 200 KB.",
  345. default=200 * 1024,
  346. )
  347. class WorkflowNodeExecutionConfig(BaseSettings):
  348. """
  349. Configuration for workflow node execution
  350. """
  351. MAX_SUBMIT_COUNT: PositiveInt = Field(
  352. description="Maximum number of submitted thread count in a ThreadPool for parallel node execution",
  353. default=100,
  354. )
  355. class AuthConfig(BaseSettings):
  356. """
  357. Configuration for authentication and OAuth
  358. """
  359. OAUTH_REDIRECT_PATH: str = Field(
  360. description="Redirect path for OAuth authentication callbacks",
  361. default="/console/api/oauth/authorize",
  362. )
  363. GITHUB_CLIENT_ID: Optional[str] = Field(
  364. description="GitHub OAuth client ID",
  365. default=None,
  366. )
  367. GITHUB_CLIENT_SECRET: Optional[str] = Field(
  368. description="GitHub OAuth client secret",
  369. default=None,
  370. )
  371. GOOGLE_CLIENT_ID: Optional[str] = Field(
  372. description="Google OAuth client ID",
  373. default=None,
  374. )
  375. GOOGLE_CLIENT_SECRET: Optional[str] = Field(
  376. description="Google OAuth client secret",
  377. default=None,
  378. )
  379. ACCESS_TOKEN_EXPIRE_MINUTES: PositiveInt = Field(
  380. description="Expiration time for access tokens in minutes",
  381. default=60,
  382. )
  383. REFRESH_TOKEN_EXPIRE_DAYS: PositiveFloat = Field(
  384. description="Expiration time for refresh tokens in days",
  385. default=30,
  386. )
  387. LOGIN_LOCKOUT_DURATION: PositiveInt = Field(
  388. description="Time (in seconds) a user must wait before retrying login after exceeding the rate limit.",
  389. default=86400,
  390. )
  391. class ModerationConfig(BaseSettings):
  392. """
  393. Configuration for content moderation
  394. """
  395. MODERATION_BUFFER_SIZE: PositiveInt = Field(
  396. description="Size of the buffer for content moderation processing",
  397. default=300,
  398. )
  399. class ToolConfig(BaseSettings):
  400. """
  401. Configuration for tool management
  402. """
  403. TOOL_ICON_CACHE_MAX_AGE: PositiveInt = Field(
  404. description="Maximum age in seconds for caching tool icons",
  405. default=3600,
  406. )
  407. class MailConfig(BaseSettings):
  408. """
  409. Configuration for email services
  410. """
  411. MAIL_TYPE: Optional[str] = Field(
  412. description="Email service provider type ('smtp' or 'resend'), default to None.",
  413. default=None,
  414. )
  415. MAIL_DEFAULT_SEND_FROM: Optional[str] = Field(
  416. description="Default email address to use as the sender",
  417. default=None,
  418. )
  419. RESEND_API_KEY: Optional[str] = Field(
  420. description="API key for Resend email service",
  421. default=None,
  422. )
  423. RESEND_API_URL: Optional[str] = Field(
  424. description="API URL for Resend email service",
  425. default=None,
  426. )
  427. SMTP_SERVER: Optional[str] = Field(
  428. description="SMTP server hostname",
  429. default=None,
  430. )
  431. SMTP_PORT: Optional[int] = Field(
  432. description="SMTP server port number",
  433. default=465,
  434. )
  435. SMTP_USERNAME: Optional[str] = Field(
  436. description="Username for SMTP authentication",
  437. default=None,
  438. )
  439. SMTP_PASSWORD: Optional[str] = Field(
  440. description="Password for SMTP authentication",
  441. default=None,
  442. )
  443. SMTP_USE_TLS: bool = Field(
  444. description="Enable TLS encryption for SMTP connections",
  445. default=False,
  446. )
  447. SMTP_OPPORTUNISTIC_TLS: bool = Field(
  448. description="Enable opportunistic TLS for SMTP connections",
  449. default=False,
  450. )
  451. EMAIL_SEND_IP_LIMIT_PER_MINUTE: PositiveInt = Field(
  452. description="Maximum number of emails allowed to be sent from the same IP address in a minute",
  453. default=50,
  454. )
  455. class RagEtlConfig(BaseSettings):
  456. """
  457. Configuration for RAG ETL processes
  458. """
  459. # TODO: This config is not only for rag etl, it is also for file upload, we should move it to file upload config
  460. ETL_TYPE: str = Field(
  461. description="RAG ETL type ('dify' or 'Unstructured'), default to 'dify'",
  462. default="dify",
  463. )
  464. KEYWORD_DATA_SOURCE_TYPE: str = Field(
  465. description="Data source type for keyword extraction"
  466. " ('database' or other supported types), default to 'database'",
  467. default="database",
  468. )
  469. UNSTRUCTURED_API_URL: Optional[str] = Field(
  470. description="API URL for Unstructured.io service",
  471. default=None,
  472. )
  473. UNSTRUCTURED_API_KEY: Optional[str] = Field(
  474. description="API key for Unstructured.io service",
  475. default="",
  476. )
  477. SCARF_NO_ANALYTICS: Optional[str] = Field(
  478. description="This is about whether to disable Scarf analytics in Unstructured library.",
  479. default="false",
  480. )
  481. class DataSetConfig(BaseSettings):
  482. """
  483. Configuration for dataset management
  484. """
  485. PLAN_SANDBOX_CLEAN_DAY_SETTING: PositiveInt = Field(
  486. description="Interval in days for dataset cleanup operations - plan: sandbox",
  487. default=30,
  488. )
  489. PLAN_PRO_CLEAN_DAY_SETTING: PositiveInt = Field(
  490. description="Interval in days for dataset cleanup operations - plan: pro and team",
  491. default=7,
  492. )
  493. DATASET_OPERATOR_ENABLED: bool = Field(
  494. description="Enable or disable dataset operator functionality",
  495. default=False,
  496. )
  497. TIDB_SERVERLESS_NUMBER: PositiveInt = Field(
  498. description="number of tidb serverless cluster",
  499. default=500,
  500. )
  501. CREATE_TIDB_SERVICE_JOB_ENABLED: bool = Field(
  502. description="Enable or disable create tidb service job",
  503. default=False,
  504. )
  505. PLAN_SANDBOX_CLEAN_MESSAGE_DAY_SETTING: PositiveInt = Field(
  506. description="Interval in days for message cleanup operations - plan: sandbox",
  507. default=30,
  508. )
  509. class WorkspaceConfig(BaseSettings):
  510. """
  511. Configuration for workspace management
  512. """
  513. INVITE_EXPIRY_HOURS: PositiveInt = Field(
  514. description="Expiration time in hours for workspace invitation links",
  515. default=72,
  516. )
  517. class IndexingConfig(BaseSettings):
  518. """
  519. Configuration for indexing operations
  520. """
  521. INDEXING_MAX_SEGMENTATION_TOKENS_LENGTH: PositiveInt = Field(
  522. description="Maximum token length for text segmentation during indexing",
  523. default=4000,
  524. )
  525. CHILD_CHUNKS_PREVIEW_NUMBER: PositiveInt = Field(
  526. description="Maximum number of child chunks to preview",
  527. default=50,
  528. )
  529. class MultiModalTransferConfig(BaseSettings):
  530. MULTIMODAL_SEND_FORMAT: Literal["base64", "url"] = Field(
  531. description="Format for sending files in multimodal contexts ('base64' or 'url'), default is base64",
  532. default="base64",
  533. )
  534. class CeleryBeatConfig(BaseSettings):
  535. CELERY_BEAT_SCHEDULER_TIME: int = Field(
  536. description="Interval in days for Celery Beat scheduler execution, default to 1 day",
  537. default=1,
  538. )
  539. class PositionConfig(BaseSettings):
  540. POSITION_PROVIDER_PINS: str = Field(
  541. description="Comma-separated list of pinned model providers",
  542. default="",
  543. )
  544. POSITION_PROVIDER_INCLUDES: str = Field(
  545. description="Comma-separated list of included model providers",
  546. default="",
  547. )
  548. POSITION_PROVIDER_EXCLUDES: str = Field(
  549. description="Comma-separated list of excluded model providers",
  550. default="",
  551. )
  552. POSITION_TOOL_PINS: str = Field(
  553. description="Comma-separated list of pinned tools",
  554. default="",
  555. )
  556. POSITION_TOOL_INCLUDES: str = Field(
  557. description="Comma-separated list of included tools",
  558. default="",
  559. )
  560. POSITION_TOOL_EXCLUDES: str = Field(
  561. description="Comma-separated list of excluded tools",
  562. default="",
  563. )
  564. @property
  565. def POSITION_PROVIDER_PINS_LIST(self) -> list[str]:
  566. return [item.strip() for item in self.POSITION_PROVIDER_PINS.split(",") if item.strip() != ""]
  567. @property
  568. def POSITION_PROVIDER_INCLUDES_SET(self) -> set[str]:
  569. return {item.strip() for item in self.POSITION_PROVIDER_INCLUDES.split(",") if item.strip() != ""}
  570. @property
  571. def POSITION_PROVIDER_EXCLUDES_SET(self) -> set[str]:
  572. return {item.strip() for item in self.POSITION_PROVIDER_EXCLUDES.split(",") if item.strip() != ""}
  573. @property
  574. def POSITION_TOOL_PINS_LIST(self) -> list[str]:
  575. return [item.strip() for item in self.POSITION_TOOL_PINS.split(",") if item.strip() != ""]
  576. @property
  577. def POSITION_TOOL_INCLUDES_SET(self) -> set[str]:
  578. return {item.strip() for item in self.POSITION_TOOL_INCLUDES.split(",") if item.strip() != ""}
  579. @property
  580. def POSITION_TOOL_EXCLUDES_SET(self) -> set[str]:
  581. return {item.strip() for item in self.POSITION_TOOL_EXCLUDES.split(",") if item.strip() != ""}
  582. class LoginConfig(BaseSettings):
  583. ENABLE_EMAIL_CODE_LOGIN: bool = Field(
  584. description="whether to enable email code login",
  585. default=False,
  586. )
  587. ENABLE_EMAIL_PASSWORD_LOGIN: bool = Field(
  588. description="whether to enable email password login",
  589. default=True,
  590. )
  591. ENABLE_SOCIAL_OAUTH_LOGIN: bool = Field(
  592. description="whether to enable github/google oauth login",
  593. default=False,
  594. )
  595. EMAIL_CODE_LOGIN_TOKEN_EXPIRY_MINUTES: PositiveInt = Field(
  596. description="expiry time in minutes for email code login token",
  597. default=5,
  598. )
  599. ALLOW_REGISTER: bool = Field(
  600. description="whether to enable register",
  601. default=False,
  602. )
  603. ALLOW_CREATE_WORKSPACE: bool = Field(
  604. description="whether to enable create workspace",
  605. default=False,
  606. )
  607. class AccountConfig(BaseSettings):
  608. ACCOUNT_DELETION_TOKEN_EXPIRY_MINUTES: PositiveInt = Field(
  609. description="Duration in minutes for which a account deletion token remains valid",
  610. default=5,
  611. )
  612. class FeatureConfig(
  613. # place the configs in alphabet order
  614. AppExecutionConfig,
  615. AuthConfig, # Changed from OAuthConfig to AuthConfig
  616. BillingConfig,
  617. CodeExecutionSandboxConfig,
  618. DataSetConfig,
  619. EndpointConfig,
  620. FileAccessConfig,
  621. FileUploadConfig,
  622. HttpConfig,
  623. InnerAPIConfig,
  624. IndexingConfig,
  625. LoggingConfig,
  626. MailConfig,
  627. ModelLoadBalanceConfig,
  628. ModerationConfig,
  629. MultiModalTransferConfig,
  630. PositionConfig,
  631. RagEtlConfig,
  632. SecurityConfig,
  633. ToolConfig,
  634. UpdateConfig,
  635. WorkflowConfig,
  636. WorkflowNodeExecutionConfig,
  637. WorkspaceConfig,
  638. LoginConfig,
  639. AccountConfig,
  640. # hosted services config
  641. HostedServiceConfig,
  642. CeleryBeatConfig,
  643. ):
  644. pass