config.py 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. from pydantic_settings import BaseSettings
  2. from typing import List
  3. class Settings(BaseSettings):
  4. app_name: str = "ai-flow"
  5. # 日志级别
  6. log_level: str = "INFO"
  7. # Redis
  8. redis_host: str
  9. redis_port: int
  10. redis_password: str
  11. redis_db: int = 0
  12. redis_timeout: int = 2000
  13. # 存储后端: "redis" 或 "local"
  14. store_backend: str = "redis"
  15. # Redis Pub/Sub
  16. redis_publish_enabled: bool = True
  17. redis_publish_channel: str = "WORKFLOW_TASK"
  18. # 工作流线程池
  19. executor_pool_size: int = 8
  20. http_timeout: int = 300
  21. step_retry_count: int = 1
  22. # 模板缓存
  23. template_cache_enabled: bool = True
  24. template_cache_dir: str = "data/templates"
  25. template_download_timeout: int = 30000
  26. template_download_max_size: int = 104857600
  27. # API Key 认证
  28. api_auth_enabled: bool = False
  29. api_auth_keys: List[str] = []
  30. api_auth_header_name: str = "Authorization"
  31. api_auth_prefix: str = "Bearer"
  32. api_auth_error_message: str = "Invalid API Key"
  33. # 本地存储
  34. task_store_data_dir: str = "data/tasks"
  35. # 阿里云 OSS
  36. aliyun_endpoint: str
  37. aliyun_access_key_id: str
  38. aliyun_access_key_secret: str
  39. aliyun_bucket_name: str
  40. # Google Cloud Storage
  41. gcs_project_id: str
  42. gcs_bucket_name: str
  43. gcs_credentials_json: str = ""
  44. gcs_credentials_file: str = ""
  45. # Gemini API
  46. gemini_api_key: str
  47. gemini_base_url: str
  48. gemini_nano_banana_model: str
  49. gemini_veo3_model: str
  50. # Kontext (BFL) API
  51. kontext_api_key: str
  52. kontext_pro_url: str
  53. kontext_max_url: str
  54. # Keling API
  55. keling_app_key: str
  56. keling_app_secret: str
  57. keling_image2video_url: str
  58. keling_video2effect_url: str
  59. # SeedDance / SeedDream API
  60. seed_api_key: str
  61. seedance_video_url: str
  62. seedream_image_url: str
  63. # 资源路径
  64. resources_path: str = "resources"
  65. model_config = {"env_prefix": "AI_FLOW_", "env_file": ".env"}
  66. settings = Settings()