global_settings.py 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. from pydantic import Field
  2. from pydantic_settings import BaseSettings, SettingsConfigDict
  3. from .settings import *
  4. class GlobalConfigSettings(BaseSettings):
  5. """应用全局配置"""
  6. # ============ 应用基础配置 ============
  7. app_name: str = Field(default="LongArticleTaskServer", description="应用名称")
  8. environment: str = Field(
  9. default="development", description="运行环境: development/pre/production"
  10. )
  11. debug: bool = Field(default=False, description="调试模式")
  12. # ============ 数据库配置 ============
  13. aigc_db: AigcDatabaseConfig = Field(default_factory=AigcDatabaseConfig)
  14. long_video_db: LongVideoDatabaseConfig = Field(
  15. default_factory=LongVideoDatabaseConfig
  16. )
  17. long_articles_db: LongArticlesDatabaseConfig = Field(
  18. default_factory=LongArticlesDatabaseConfig
  19. )
  20. piaoquan_crawler_db: PiaoquanCrawlerDatabaseConfig = Field(
  21. default_factory=PiaoquanCrawlerDatabaseConfig
  22. )
  23. growth_db: GrowthDatabaseConfig = Field(default_factory=GrowthDatabaseConfig)
  24. # ============ 外部服务配置 ============
  25. deepseek: DeepSeekConfig = Field(default_factory=DeepSeekConfig)
  26. aliyun_log: AliyunLogConfig = Field(default_factory=AliyunLogConfig)
  27. elasticsearch: ElasticsearchConfig = Field(default_factory=ElasticsearchConfig)
  28. apollo: ApolloConfig = Field(default_factory=ApolloConfig)
  29. # ============ 业务配置 ============
  30. cold_start: ColdStartConfig = Field(default_factory=ColdStartConfig)
  31. category: CategoryConfig = Field(default_factory=CategoryConfig)
  32. task_chinese_name: TaskChineseNameConfig = Field(default_factory=TaskChineseNameConfig)
  33. model_config = SettingsConfigDict(
  34. env_file=".env", env_file_encoding="utf-8", case_sensitive=False, extra="ignore"
  35. )
  36. # # ============ 全局配置实例 ============
  37. # global_settings = GlobalConfigSettings()
  38. #
  39. #
  40. # # ============ 兼容旧代码的导出 ============
  41. # # 这些变量保持向后兼容,让旧代码可以继续使用
  42. # aigc_db_config = global_settings.aigc_db.to_dict()
  43. # long_video_db_config = global_settings.long_video_db.to_dict()
  44. # long_articles_db_config = global_settings.long_articles_db.to_dict()
  45. # piaoquan_crawler_db_config = global_settings.piaoquan_crawler_db.to_dict()
  46. # growth_db_config = global_settings.growth_db.to_dict()
  47. #
  48. # deep_seek_official_api_key = global_settings.deepseek.api_key
  49. # deep_seek_official_model = global_settings.deepseek.get_model_map()
  50. #
  51. # aliyun_log_config = global_settings.aliyun_log.to_dict()
  52. #
  53. # cold_start_category_map = global_settings.cold_start.category_map
  54. # input_source_map = global_settings.cold_start.input_source_map
  55. #
  56. # CATEGORY_FEATURES = global_settings.category.features
  57. # CATEGORY_MAP = global_settings.category.category_map