This commit is contained in:
openclaww-xz 2026-08-14 09:27:25 -04:00 committed by GitHub
commit 753d3e2fc0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 31 additions and 16 deletions

View File

@ -481,13 +481,16 @@ DEFAULT_CONTEXT_LENGTHS = {
# https://platform.minimax.io/docs/api-reference/text-chat-openai
"minimax-m3": 1000000,
"minimax": 204800,
# GLM — GLM-5.2 ships with a 1M context window (verified empirically:
# needle-in-a-haystack retrieval at 789K prompt tokens succeeded with
# zero errors on api.z.ai/api/coding/paas/v4). Older GLM models
# (5, 5.1, 5-turbo) are ~202K. Longest-key-first substring matching
# ensures "glm-5.2" resolves to 1M while older variants still hit the
# generic 202K fallback.
# GLM — GLM-5.2 and GLM-5.3 ship with a 1M context window. GLM-5.2 was
# verified empirically (needle-in-a-haystack retrieval at 789K prompt
# tokens succeeded with zero errors on api.z.ai/api/coding/paas/v4).
# GLM-5.3 uses the same base model (all gains are post-training) with
# 1M context / 128K max output per docs.z.ai/guides/llm/glm-5.3
# (verified 2026-08-14). Older GLM models (5, 5.1, 5-turbo) are ~202K.
# Longest-key-first substring matching ensures "glm-5.2"/"glm-5.3"
# resolve to 1M while older variants still hit the generic 202K fallback.
"glm-5.2": 1_048_576,
"glm-5.3": 1_048_576,
"glm": 202752,
# xAI Grok — xAI /v1/models does not return context_length metadata,
# so these hardcoded fallbacks prevent Hermes from probing-down to

View File

@ -724,8 +724,8 @@ ZAI_ENDPOINTS = [
# (id, base_url, probe_models, label)
("global", "https://api.z.ai/api/paas/v4", ["glm-5"], "Global"),
("cn", "https://open.bigmodel.cn/api/paas/v4", ["glm-5"], "China"),
("coding-global", "https://api.z.ai/api/coding/paas/v4", ["glm-5.2", "glm-5.1", "glm-5v-turbo", "glm-4.7"], "Global (Coding Plan)"),
("coding-cn", "https://open.bigmodel.cn/api/coding/paas/v4", ["glm-5.2", "glm-5.1", "glm-5v-turbo", "glm-4.7"], "China (Coding Plan)"),
("coding-global", "https://api.z.ai/api/coding/paas/v4", ["glm-5.3", "glm-5.2", "glm-5.1", "glm-5v-turbo", "glm-4.7"], "Global (Coding Plan)"),
("coding-cn", "https://open.bigmodel.cn/api/coding/paas/v4", ["glm-5.3", "glm-5.2", "glm-5.1", "glm-5v-turbo", "glm-4.7"], "China (Coding Plan)"),
]

View File

@ -81,7 +81,8 @@ OPENROUTER_MODELS: list[tuple[str, str]] = [
# MiniMax
("minimax/minimax-m3", ""),
# Z-AI
("z-ai/glm-5.2", "default"),
("z-ai/glm-5.3", "default"),
("z-ai/glm-5.2", ""),
("z-ai/glm-5.1", ""),
# Xiaomi
("xiaomi/mimo-v2.5-pro", ""),
@ -254,6 +255,7 @@ _PROVIDER_MODELS: dict[str, list[str]] = {
# MiniMax
"minimax/minimax-m3",
# Z-AI
"z-ai/glm-5.3",
"z-ai/glm-5.2",
"z-ai/glm-5.1",
# Xiaomi
@ -328,6 +330,7 @@ _PROVIDER_MODELS: dict[str, list[str]] = {
"gemini-3.1-flash-lite-preview",
],
"zai": [
"glm-5.3",
"glm-5.2",
"glm-5.1",
"glm-5",
@ -345,6 +348,7 @@ _PROVIDER_MODELS: dict[str, list[str]] = {
"nvidia/nemotron-3-nano-omni-30b-a3b-reasoning",
# Third-party agentic models hosted on build.nvidia.com
# (map to OpenRouter defaults — users get familiar picks on NIM)
"z-ai/glm-5.3",
"z-ai/glm-5.2",
"moonshotai/kimi-k2.6",
"minimaxai/minimax-m3",
@ -480,6 +484,7 @@ _PROVIDER_MODELS: dict[str, list[str]] = {
"minimax-m3",
"minimax-m2.7",
"minimax-m2.5",
"glm-5.3",
"glm-5.2",
"glm-5.1",
"glm-5",
@ -501,6 +506,7 @@ _PROVIDER_MODELS: dict[str, list[str]] = {
"kimi-k2.7-code",
"kimi-k2.6",
"kimi-k2.5",
"glm-5.3",
"glm-5.2",
"glm-5.1",
"glm-5",

View File

@ -47,22 +47,28 @@ def _model_supports_thinking(model: str | None) -> bool:
def _is_glm_5_2(model: str | None) -> bool:
"""Detect GLM-5.2 across the alias spellings providers use.
"""Detect GLM-5.2/5.3 (reasoning_effort-capable) across alias spellings.
Covers the canonical ``glm-5.2`` plus the ``glm-5-2`` / ``glm-5p2``
variants seen on relays (Fireworks ``glm-5p2``, etc.) and any
vendor-prefixed form (``z-ai/glm-5.2``, ``zai-org-glm-5-2``).
Covers the canonical ``glm-5.2``/``glm-5.3`` plus the ``glm-5-2`` /
``glm-5p2`` variants seen on relays (Fireworks ``glm-5p2``, etc.) and any
vendor-prefixed form (``z-ai/glm-5.2``, ``zai-org-glm-5-2``). GLM-5.3
uses the same base model as 5.2 (post-training gains only) and exposes
the same ``reasoning_effort`` knob (verified live 2026-08-14: the
coding-plan endpoint accepts ``reasoning_effort: high`` for glm-5.3).
"""
m = (model or "").strip().lower()
if not m:
return False
return any(token in m for token in ("glm-5.2", "glm-5-2", "glm-5p2"))
return any(
token in m
for token in ("glm-5.2", "glm-5-2", "glm-5p2", "glm-5.3", "glm-5-3", "glm-5p3")
)
def _glm_5_2_reasoning_effort(reasoning_config: dict | None) -> str | None:
"""Map Hermes reasoning effort onto GLM-5.2's native ``high``/``max``.
"""Map Hermes reasoning effort onto GLM-5.2/5.3's native ``high``/``max``.
GLM-5.2 only supports two enabled effort levels. ``xhigh``/``max``/``ultra``
These models only support two enabled effort levels. ``xhigh``/``max``/``ultra``
request the top tier; everything else that is enabled requests ``high``
(its minimum thinking level). When reasoning is explicitly disabled, or
no effort preference is supplied, the server default is left untouched.