""" 应用配置:从 backend/.env 读取,含数据库、JWT、Neo4j、大模型与语音相关项。 """ from pathlib import Path from pydantic_settings import BaseSettings, SettingsConfigDict _BACKEND_DIR = Path(__file__).resolve().parents[2] _ENV_FILE = _BACKEND_DIR / ".env" class Settings(BaseSettings): model_config = SettingsConfigDict(env_file=str(_ENV_FILE), env_file_encoding="utf-8") app_name: str = "KnowMathBot API" #项目名 api_v1_prefix: str = "/api/v1" #接口前缀 #JWT登录认证 jwt_secret_key: str = "CHANGE_ME_IN_ENV" jwt_algorithm: str = "HS256" access_token_exp_minutes: int = 60 * 24 #令牌有效期 1 天 #数据库配置 database_url: str = "sqlite:///./knowmathbot.db" #Neo4j知识图谱配置 neo4j_uri: str = "neo4j://127.0.0.1:7687" neo4j_user: str = "neo4j" neo4j_password: str = "please_change_me" neo4j_database: str = "neo4j" #TTS语音合成配置 local_tts_enabled: bool = False local_tts_model_dir: str = str(_BACKEND_DIR / "storage" / "tts") local_tts_ckpt_path: str = "" local_tts_pth_path: str = "" local_tts_provider: str = "pyttsx3" local_tts_api_url: str = "" local_tts_api_timeout_seconds: int = 60 local_tts_ref_wav_path: str = "" local_tts_prompt_text: str = "" local_tts_prompt_lang: str = "zh" local_tts_text_lang: str = "zh" #外部大模型 API deepseek_api_key: str = "" deepseek_base_url: str = "https://api.deepseek.com" deepseek_model: str = "deepseek-chat" llm_request_timeout_seconds: int = 30 voice_assets_dir: str = str(_BACKEND_DIR / "storage" / "voice_assets") settings = Settings()