M4b:ai_provider 删除手术①-⑥——神识全面接管模型出口
- ① 后端删除 app/ai_provider/(38 文件,含 anthropic/openai 格式、billing、audio、embedding)、services/ai_provider_admin.py、core/config/model_config.py、tests/ai_provider/(21 文件) - ② 连带退役 application/agent/(旧 Agent 循环/steer/follow-up/确认注册表)、application/skill_executor.py、app/skills/(python skills 孤儿)、endpoints/audio.py、application/imports.py(ProviderManager 消费方);settings 端点收敛为生成偏好 - ③ runs.py 修剪:AgentRunRegistry/steer/follow-up/confirmations 端点退役,保留 list/get/events/cancel/stream;safety 确认改为直接落库裁决(pending→approved/denied) - ④ 前端删除:models 页、ModelGatewayView、gateway.ts、GatewayPanel(玄关)、ModelGatewayPanel/ModelStrategyForm、audio.ts/useVoiceInput、网关类型与 mock;设置页收敛为外观/语言/通知 - ⑤ 配置收敛:config/models|providers|pricing.example.yaml 归档 shenshi/config/;.env.example 删 provider keys/MODEL_ENDPOINT_POOL/MODEL_CONFIG_PATH,收敛 SHENSHI_* - ⑥ 验收:rg 审计灵台 Provider SDK import 与 ai_provider 引用归零;后端 528 passed(2 个预存失败经 HEAD 复跑验证与本手术无关)、前端 type-check+201 passed、神识 go vet+test、BFF 4 passed
This commit is contained in:
1 parent
0d383725b5
commit
462d570751
129 files changed
+81
-15867
No files matched your search
@@ -5,9 +5,6 @@
|
||||
|
||||
- ``.env`` 永远放在项目根目录(backend 父级),``Settings`` 初始化时以**绝对路径**
|
||||
通过 ``_env_file`` 传入,不使用相对路径,不依赖 ``python-dotenv``。
|
||||
- ``ai_provider/`` 只**消费**本目录的配置,不持有自己的
|
||||
``settings.py`` / ``config.py``;领域数据结构(``ModelConfig`` 等)保留在
|
||||
``ai_provider/config/models.py``。
|
||||
"""
|
||||
|
||||
from app.core.config.sandbox_config import SandboxSettings
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
"""模型网关(神识)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 本地重试最大退避(秒)
|
||||
@@ -1,7 +1,7 @@
|
||||
"""主 Settings:多继承所有子配置,统一以绝对路径 ``_env_file`` 加载 ``.env``。
|
||||
|
||||
子配置见同目录下的 ``app_config`` / ``auth_config`` / ``database_config`` / ``log_config`` /
|
||||
``runtime_config`` / ``model_config`` / ``sandbox_config``。本文件聚合字段,并承载
|
||||
``runtime_config`` / ``sandbox_config``。本文件聚合字段,并承载
|
||||
跨子配置的路径解析与计算属性。
|
||||
|
||||
配置优先级(自高到低):命令行参数 > 系统环境变量 > ``.env`` > 类属性默认值。
|
||||
@@ -18,7 +18,6 @@ from app.core.config.app_config import AppConfig
|
||||
from app.core.config.auth_config import AuthConfig
|
||||
from app.core.config.database_config import DatabaseConfig
|
||||
from app.core.config.log_config import LogConfig
|
||||
from app.core.config.model_config import ModelGatewayConfig
|
||||
from app.core.config.runtime_config import RuntimeConfig
|
||||
from app.core.config.sandbox_config import SandboxSettings
|
||||
from app.core.config.time_config import TimeConfig
|
||||
@@ -35,7 +34,6 @@ class Settings(
|
||||
DatabaseConfig,
|
||||
LogConfig,
|
||||
RuntimeConfig,
|
||||
ModelGatewayConfig,
|
||||
SandboxSettings,
|
||||
TimeConfig,
|
||||
BaseSettings,
|
||||
@@ -117,21 +115,6 @@ class Settings(
|
||||
return example
|
||||
return configured
|
||||
|
||||
@cached_property
|
||||
def resolved_model_config_path(self) -> Path:
|
||||
"""解析模型配置文件路径。
|
||||
|
||||
如果配置文件不存在,尝试使用示例配置文件。
|
||||
"""
|
||||
configured = self.resolve_from_backend(self.model_config_path)
|
||||
if configured.exists():
|
||||
return configured
|
||||
# 如果配置文件不存在,尝试使用示例配置
|
||||
example = self.project_root / "config" / "models.example.yaml"
|
||||
if example.exists():
|
||||
return example
|
||||
return configured
|
||||
|
||||
@cached_property
|
||||
def resolved_avatar_dir(self) -> Path:
|
||||
"""解析角色头像存储目录为绝对路径。"""
|
||||
|
||||
Reference in new issue
Block a user