feat(explain): 解读双模型对比#11
Closed
bob798 wants to merge 2 commits into
Closed
Conversation
- 新增 /model (GET) 查询当前模型状态 - 新增 /model/switch (POST) 运行时切换活跃模型 - runtime_model 单例管理活跃模型,所有 service 动态读取 - MODEL_NAME_ALT 环境变量配置备选模型 - 按场景路由 get_scene_client() 预留(未启用) - MODEL_REGISTRY 注册表记录各 provider 可用模型 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
并行调用两个 LLM,用户可开关对比模式,横向查看不同模型的解读差异。 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5 tasks
Owner
Author
|
代码已在 main 中实现(runtime_model 热切换、model_router、get_scene_client 均已合入)。关闭过时 PR。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Context
用户希望在解读(Explain)页面中,能同时看到两个 LLM 对同一内容的解读结果(如 DeepSeek vs GLM),做横向对比。
设计方案
模型选择
当前 volcengine 注册表已有
deepseek-v3-250324和glm-4-7-251222,共用同一 API Key。对比模型配置:
runtime_model.model(当前全局活跃模型)MODEL_COMPARE_EXPLAIN环境变量配置,格式provider/model(如volcengine/glm-4-7-251222)改动清单
Step 1: 后端 — 支持指定模型调用
app/config.pyget_compare_model(scene)函数:读取MODEL_COMPARE_<SCENE>环境变量,返回(provider, model_name)或Noneapp/services/model_client.pyget_specific_client(provider, model_name)工厂函数:按给定 provider+model 创建客户端实例AnthropicClient/OpenAICompatibleClient,但允许覆盖 modelapp/models/db.py— ExplanationCache 表model_tag列(String, nullable=False, default="")(text_hash, kind, cefr_level, model_tag)model_tag=""视为默认模型缓存,兼容无影响app/services/explain_service.py_cache_get/_cache_set增加model_tag参数explain_text()增加可选model_tag: str = ""参数 → 非空时用get_specific_client()调用stream_sentence_explanation()同理增加model_tag参数app/routers/practice.pyExplainRequest新增可选字段model_tag: Optional[str] = NoneStreamExplainRequest同理GET /practice/explain/models接口:返回{ primary: "deepseek-v3", compare: "glm-4-7" | null },前端据此决定是否显示开关Step 2: 前端 — 双栏对比 UI
frontend/src/components/ExplanationModal.vuecompareMode(boolean,localStorage 持久化)、compareData(同data结构)、compareLoading、compareErrorfetchExplanation()改造:compareMode开启时,同时发第二个请求(model_tag=compare)Promise.all并行/practice/explain/models缓存结果不动的部分
Test plan
.env配置MODEL_COMPARE_EXPLAIN=volcengine/glm-4-7-251222uvicorn app.main:app --reloadMODEL_COMPARE_EXPLAIN时 → 开关不显示🤖 Generated with Claude Code