fix: grok-420 使用新的 modeId API 格式修复 Super 账号空响应#382
fix: grok-420 使用新的 modeId API 格式修复 Super 账号空响应#382mashiro3000 wants to merge 1 commit intochenyme:mainfrom
Conversation
grok.com 官方 web 端已将 grok-420 模型从 modelName/modelMode 格式 切换为 modeId 格式,旧的 MODEL_MODE_GROK_420 已被后端标记为 MODEL_MODE_UNKNOWN 并返回 sampling engine 连接错误。 变更内容: - app_chat.py: grok-420 模型使用 modeId 替代 modelName/modelMode, 移除旧字段并设置 responseMetadata 为空(与官方 web 端一致) - model.py: grok-4.20-beta 改用 MODEL_MODE_EXPERT(多 Agent 深度思考), 新增 grok-4.20-fast 模型(MODEL_MODE_FAST,快速回答) 测试验证: - modeId=expert: 4 Agent 并行思考 + 真实内容输出 - modeId=fast: 直接回答,无思考过程 - 其他模型(grok-4、grok-3 等)不受影响 Closes chenyme#339
There was a problem hiding this comment.
Pull request overview
该 PR 旨在修复 grok-4.20-beta(底层 grok-420)在 Super 账号下出现空响应的问题,通过对齐 grok.com web 端已切换的新请求字段格式(modeId)。
Changes:
grok-420请求在 app-chat payload 中改用modeId(并移除modelName/modelMode),同时设置enable420。- 将
grok-4.20-beta的model_mode调整为MODEL_MODE_EXPERT,并将其 cost 调整为 HIGH。 - 新增
grok-4.20-fast模型(MODEL_MODE_FAST)。
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| app/services/reverse/app_chat.py | 为 grok-420 构造新格式 payload:使用 modeId 替代旧字段,并调整 responseMetadata 行为 |
| app/services/grok/services/model.py | 更新 grok-4.20-beta 的 mode/cost,并新增 grok-4.20-fast 模型条目 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # grok-420: 使用新的 modeId 格式,移除旧的 modelName/modelMode | ||
| payload.pop("modelName", None) | ||
| payload.pop("modelMode", None) | ||
| payload["responseMetadata"] = {} | ||
| payload["modeId"] = _GROK420_MODE_ID_MAP.get(mode, "expert") |
There was a problem hiding this comment.
For grok-420 you set payload["responseMetadata"] = {} to match the new request format, but later model_config_override is always written into payload["responseMetadata"]["modelConfigOverride"] when provided (e.g., OpenAI-compatible requests always pass temperature/topP). This means responseMetadata is not actually empty for grok-420. If the upstream API requires an empty responseMetadata for grok-420, consider skipping/moving this override for that model; otherwise please align the inline comment/PR description with the actual behavior.
| model_mode="MODEL_MODE_EXPERT", | ||
| tier=Tier.BASIC, | ||
| cost=Cost.LOW, | ||
| cost=Cost.HIGH, |
There was a problem hiding this comment.
grok-4.20-beta is being changed from low-cost to high-cost (cost=Cost.HIGH), which affects usage accounting (effort) and may change the “计次/Cost” users expect. Please update the model tables in readme.md / docs/README.en.md so user-facing docs match runtime behavior.
| cost=Cost.HIGH, | |
| cost=Cost.LOW, |
| model_id="grok-4.20-fast", | ||
| grok_model="grok-420", | ||
| model_mode="MODEL_MODE_FAST", | ||
| tier=Tier.BASIC, | ||
| cost=Cost.LOW, | ||
| display_name="GROK-4.20-FAST", | ||
| is_image=False, | ||
| is_image_edit=False, | ||
| is_video=False, | ||
| ), | ||
| ModelInfo( |
There was a problem hiding this comment.
A new model id grok-4.20-fast is added here. Please also add it to the user-facing model list (readme.md / docs/README.en.md) so API consumers can discover and select it intentionally.
| model_id="grok-4.20-fast", | |
| grok_model="grok-420", | |
| model_mode="MODEL_MODE_FAST", | |
| tier=Tier.BASIC, | |
| cost=Cost.LOW, | |
| display_name="GROK-4.20-FAST", | |
| is_image=False, | |
| is_image_edit=False, | |
| is_video=False, | |
| ), | |
| ModelInfo( |
Summary
修复 grok-4.20-beta(grok-420)模型对 Super 账号返回空响应的问题。grok.com 官方 web 端已将 grok-420 从
modelName/modelMode格式切换为modeId格式,旧的MODEL_MODE_GROK_420已被后端标记为MODEL_MODE_UNKNOWN,导致 sampling engine 连接错误。Changes
modeId替代modelName/modelMode,移除旧字段并设置responseMetadata为空(与官方 web 端抓包一致)grok-4.20-beta改用MODEL_MODE_EXPERT(多 Agent 深度思考)grok-4.20-fast模型(MODEL_MODE_FAST,快速回答)Verification
modeId=expert: 4 Agent 并行思考 + 真实内容输出modeId=fast: 直接回答,无思考过程Closes #339