""" 应用配置管理 使用 pydantic-settings 从环境变量读取配置 """ from pydantic_settings import BaseSettings from functools import lru_cache class Settings(BaseSettings): """应用配置""" DATABASE_URL: str = "mysql+pymysql://root:password@localhost:3306/yuzong" SECRET_KEY: str = "your-secret-key-change-this" ALGORITHM: str = "HS256" ACCESS_TOKEN_EXPIRE_MINUTES: int = 1440 UPLOAD_DIR: str = "uploads" # AI 生图配置 SILICONFLOW_API_KEY: str = "" SILICONFLOW_BASE_URL: str = "https://api.siliconflow.cn/v1" VOLCENGINE_API_KEY: str = "" VOLCENGINE_BASE_URL: str = "https://ark.cn-beijing.volces.com/api/v3" AI_IMAGE_MODEL: str = "flux-dev" # flux-dev 或 seedream-5.0 AI_IMAGE_SIZE: int = 1024 class Config: env_file = ".env" env_file_encoding = "utf-8" @lru_cache() def get_settings() -> Settings: """获取配置单例""" return Settings() settings = get_settings()