refactor(fam-edge): 问答链路抽离到独立 ai-gateway 服务,fam-edge 改为转发客户端
原本嵌在 fam-edge 里的问答模型降级链(NVIDIA 文字模型 -> Gemini 非 flash 文字 模型 -> 本地 Ollama 兜底,含 key 轮换/熔断)跟视频分析业务无关,是通用能力, 抽成独立 ai-gateway 服务(OpenAI 兼容协议),除了 fam-edge 自己,别的项目也能 直接接入。 - qa.py 重写为 HTTP 转发客户端,调 ai-gateway 的 /v1/chat/completions,翻译回 原有 run_qa/run_qa_stream 契约,api_gateway.py 和 fam-core 调用方零改动 - 删除 model_adapters/ollama_adapter.py 及其测试(问答专用,视频分析不需要本地模型) - gemini_adapter.py / nvidia_adapter.py 移除 chat()/chat_stream() 及问答专用超时 (只保留视频分析用的 analyze_video) - app.py 移除 Ollama 预热逻辑(现在由 ai-gateway 自己负责) - config.yaml 移除 3 个问答专用 model 条目,新增 ai_gateway 客户端配置块 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -108,17 +108,3 @@ def test_rotated_keys_single_key_never_errors():
|
||||
a = GeminiAdapter(_cfg())
|
||||
for _ in range(3):
|
||||
assert a._rotated_keys() == [(0, "key-primary")]
|
||||
|
||||
|
||||
def test_chat_timeout_defaults_short_not_shared_with_video_timeout():
|
||||
"""核心诉求: 问答是交互场景,不能沿用视频分析的 600s 超时——否则一个卡住
|
||||
的 key/模型会让用户在聊天界面一直等,这正是"一直卡着"这个 bug 的根因。"""
|
||||
a = GeminiAdapter(_cfg(timeout=600))
|
||||
assert a.timeout == 600
|
||||
assert a.chat_timeout == 20
|
||||
assert a.chat_timeout != a.timeout
|
||||
|
||||
|
||||
def test_chat_timeout_configurable():
|
||||
a = GeminiAdapter(_cfg(chat_timeout=8))
|
||||
assert a.chat_timeout == 8
|
||||
|
||||
Reference in New Issue
Block a user