Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions app/services/grok/services/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,25 @@ class ModelService:
ModelInfo(
model_id="grok-4.20-beta",
grok_model="grok-420",
model_mode="MODEL_MODE_GROK_420",
model_mode="MODEL_MODE_EXPERT",
tier=Tier.BASIC,
cost=Cost.LOW,
cost=Cost.HIGH,
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
cost=Cost.HIGH,
cost=Cost.LOW,

Copilot uses AI. Check for mistakes.
display_name="GROK-4.20-BETA",
is_image=False,
is_image_edit=False,
is_video=False,
),
ModelInfo(
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(
Comment on lines +167 to 177
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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(

Copilot uses AI. Check for mistakes.
model_id="grok-imagine-1.0-fast",
grok_model="grok-3",
Expand Down
12 changes: 12 additions & 0 deletions app/services/reverse/app_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@
CHAT_API = "https://grok.com/rest/app-chat/conversations/new"
_LAST_PROXY_LOG_STATE: tuple[str, str] | None = None

# grok-420 使用新的 modeId API 格式(替代 modelName/modelMode)
# 官方 web 端已将 grok-420 切换为 modeId 字段,旧的 MODEL_MODE_GROK_420 已废弃
_GROK420_MODE_ID_MAP = {
"MODEL_MODE_EXPERT": "expert",
"MODEL_MODE_FAST": "fast",
}


def _normalize_chat_proxy(proxy_url: str) -> str:
"""Normalize proxy URL for curl-cffi app-chat requests."""
Expand Down Expand Up @@ -114,6 +121,11 @@ def build_payload(
}

if model == "grok-420":
# grok-420: 使用新的 modeId 格式,移除旧的 modelName/modelMode
payload.pop("modelName", None)
payload.pop("modelMode", None)
payload["responseMetadata"] = {}
payload["modeId"] = _GROK420_MODE_ID_MAP.get(mode, "expert")
Comment on lines +124 to +128
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
payload["enable420"] = True

custom_personality = AppChatReverse._resolve_custom_personality()
Expand Down
Loading