| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- from pydantic import Field
- from pydantic_settings import BaseSettings, SettingsConfigDict
- from .settings import *
- class GlobalConfigSettings(BaseSettings):
- """应用全局配置"""
- # ============ 应用基础配置 ============
- app_name: str = Field(default="LongArticleTaskServer", description="应用名称")
- environment: str = Field(
- default="development", description="运行环境: development/pre/production"
- )
- debug: bool = Field(default=False, description="调试模式")
- # ============ 数据库配置 ============
- aigc_db: AigcDatabaseConfig = Field(default_factory=AigcDatabaseConfig)
- long_video_db: LongVideoDatabaseConfig = Field(
- default_factory=LongVideoDatabaseConfig
- )
- long_articles_db: LongArticlesDatabaseConfig = Field(
- default_factory=LongArticlesDatabaseConfig
- )
- piaoquan_crawler_db: PiaoquanCrawlerDatabaseConfig = Field(
- default_factory=PiaoquanCrawlerDatabaseConfig
- )
- growth_db: GrowthDatabaseConfig = Field(default_factory=GrowthDatabaseConfig)
- # ============ 外部服务配置 ============
- deepseek: DeepSeekConfig = Field(default_factory=DeepSeekConfig)
- aliyun_log: AliyunLogConfig = Field(default_factory=AliyunLogConfig)
- elasticsearch: ElasticsearchConfig = Field(default_factory=ElasticsearchConfig)
- apollo: ApolloConfig = Field(default_factory=ApolloConfig)
- # ============ 业务配置 ============
- cold_start: ColdStartConfig = Field(default_factory=ColdStartConfig)
- category: CategoryConfig = Field(default_factory=CategoryConfig)
- task_chinese_name: TaskChineseNameConfig = Field(default_factory=TaskChineseNameConfig)
- model_config = SettingsConfigDict(
- env_file=".env", env_file_encoding="utf-8", case_sensitive=False, extra="ignore"
- )
- # # ============ 全局配置实例 ============
- # global_settings = GlobalConfigSettings()
- #
- #
- # # ============ 兼容旧代码的导出 ============
- # # 这些变量保持向后兼容,让旧代码可以继续使用
- # aigc_db_config = global_settings.aigc_db.to_dict()
- # long_video_db_config = global_settings.long_video_db.to_dict()
- # long_articles_db_config = global_settings.long_articles_db.to_dict()
- # piaoquan_crawler_db_config = global_settings.piaoquan_crawler_db.to_dict()
- # growth_db_config = global_settings.growth_db.to_dict()
- #
- # deep_seek_official_api_key = global_settings.deepseek.api_key
- # deep_seek_official_model = global_settings.deepseek.get_model_map()
- #
- # aliyun_log_config = global_settings.aliyun_log.to_dict()
- #
- # cold_start_category_map = global_settings.cold_start.category_map
- # input_source_map = global_settings.cold_start.input_source_map
- #
- # CATEGORY_FEATURES = global_settings.category.features
- # CATEGORY_MAP = global_settings.category.category_map
|