"""模型网关(神识)env 配置:各 provider 的 API Key / Base URL 与 endpoint 池策略。 注意区分**配置字段**与**领域数据结构**: - 本文件只承载「从 env 读的开关 / 参数 / 密钥」。 - 领域数据结构(``ModelConfig`` / ``ModelEndpointConfig``,从 ``config/models.yaml`` 加载) 保留在 ``ai_provider/config/models.py``,不外迁到 ``core/config``。 """ from __future__ import annotations from pydantic_settings import BaseSettings class ModelGatewayConfig(BaseSettings): """模型网关 env 配置。""" # ==================== 模型配置文件 ==================== model_config_path: str = "../config/models.yaml" # 模型配置文件路径(相对 backend) # ==================== provider API Key / Base URL ==================== openai_api_key: str = "" # OpenAI API Key openai_base_url: str = "https://api.openai.com/v1" # OpenAI API 地址 deepseek_api_key: str = "" # DeepSeek API Key deepseek_base_url: str = "https://api.deepseek.com" # DeepSeek API 地址(OpenAI 兼容) xiaomi_mimo_api_key: str = "" # 小米 MiMo API Key xiaomi_mimo_base_url: str = "https://api.xiaomimimo.com/v1" # 小米 MiMo API 地址 anthropic_api_key: str = "" # Anthropic API Key anthropic_base_url: str = "https://api.anthropic.com" # Anthropic API 地址 volcengine_ark_api_key: str = "" # 火山方舟 / 豆包 API Key volcengine_ark_base_url: str = "https://ark.cn-beijing.volces.com/api/v3" # 火山方舟 API 地址 custom_llm_api_key: str = "" # 自定义 LLM API Key custom_llm_base_url: str = "" # 自定义 LLM API 地址 yuanqi_api_key: str = "" # 元炁本地推理引擎 API Key yuanqi_base_url: str = "http://localhost:11434" # 元炁本地推理引擎 API 地址 # ==================== endpoint 池配置 ==================== # 物理 endpoint 池路由、failover 与重试策略(见 ai_provider/pool.py 与 resilience.py) model_endpoint_pool_enabled: bool = True # 是否启用 endpoint 池路由(False 时走逻辑模型直连) model_endpoint_pool_dry_run_selection: bool = False # dry-run:只预选并记录,不实际路由 model_endpoint_pool_expose_debug_headers: bool = False # 是否在响应头暴露 endpoint 路由调试信息 model_endpoint_pool_agent_failover_enabled: bool = ( False # Agent 调用是否允许跨 endpoint failover ) model_endpoint_pool_per_endpoint_max_retries: int = 1 # 单 endpoint 失败时的本地重试次数 model_endpoint_pool_retry_base_delay_seconds: float = 0.25 # endpoint 本地重试基础退避(秒) model_endpoint_pool_retry_max_delay_seconds: float = 2.0 # endpoint 本地重试最大退避(秒)