""" 应用配置模块 使用 pydantic-settings 管理环境变量配置 """ from pydantic_settings import BaseSettings from typing import Optional class Settings(BaseSettings): """应用配置类""" # API 配置 app_name: str = "AI FastAPI Demo" app_version: str = "1.0.0" debug: bool = True # OpenAI 配置 openai_api_key: str = "your_openai_api_key_here" # 请在 .env 文件中设置 openai_base_url: Optional[str] = None openai_model: str = "gpt-3.5-turbo" # 服务器配置 host: str = "0.0.0.0" port: int = 8000 class Config: env_file = ".env" env_file_encoding = "utf-8" # 创建全局配置实例 settings = Settings()