feat(fam-edge): 云端模型调用统计 - 新增 model_calls 表(provider/model/时间/耗时/成功/失败原因),gemini/nvidia 每次请求经 model_call_hook 记录并随 sync delta 下发;gemini 支持模型级 model_timeouts(lite 实测22.6s×4≈90s)

This commit is contained in:
ericwyuan
2026-08-21 12:21:49 +08:00
parent 1b0f62e5e9
commit b87b38b140
6 changed files with 90 additions and 3 deletions

View File

@@ -33,6 +33,21 @@ class BaseModelAdapter(ABC):
self.config = config
# 角色: vision=视觉分析, text=智能问答兜底(本地模型); 默认 vision
self.role = config.get('role', 'vision')
# 模型调用统计回调(由编排层注入):
# hook(provider, model, started_at, duration_sec, success, error)
self.model_call_hook = None
def _emit_model_call(self, model: str, started_at: str,
duration_sec: float, success: bool,
error: str = ''):
"""上报一次模型调用统计(供前端展示成功/失败/耗时/失败原因)"""
hook = self.model_call_hook
if hook is None:
return
try:
hook(self.provider_name, model, started_at, duration_sec, success, error)
except Exception:
pass # 统计失败不影响主流程
def get_role(self) -> str:
"""返回适配器角色: 'vision''text'"""