The #7514 tests pinned a pure namespace projection (same ids modulo zai/ -> z-ai/, same labels). #7520 intentionally serves z-ai/glm-4.5-air in the glm-4.5-flash slot because OpenRouter does not carry glm-4.5-flash. Encode that single explicit remap in the reference translation; keep order, length and every other label pinned.
This commit is contained in:
1 parent
e3c21a386c
commit
090728c41d
1 file changed
+20
-3
@@ -34,12 +34,24 @@ def _ids(provider_id: str) -> list[str]:
|
||||
|
||||
|
||||
def _expected_openrouter_id(model_id: str) -> str:
|
||||
"""Independent reference implementation of the namespace translation."""
|
||||
"""Independent reference implementation of the namespace translation.
|
||||
|
||||
One Z.AI model has no OpenRouter counterpart: ``glm-4.5-flash`` is not in
|
||||
OpenRouter's catalog, so #7520 serves Z.AI's nearest light model
|
||||
``z-ai/glm-4.5-air`` in its place (same slot, so order is unchanged).
|
||||
"""
|
||||
if model_id in _OPENROUTER_REMAPS:
|
||||
return _OPENROUTER_REMAPS[model_id]
|
||||
if model_id.startswith("zai/"):
|
||||
return "z-ai/" + model_id[len("zai/") :]
|
||||
return model_id
|
||||
|
||||
|
||||
# #7520: fallback ids that OpenRouter does not serve, mapped to the id the
|
||||
# wizard offers instead. Keep this list tiny and explicit.
|
||||
_OPENROUTER_REMAPS = {"zai/glm-4.5-flash": "z-ai/glm-4.5-air"}
|
||||
|
||||
|
||||
def test_openrouter_setup_never_serves_direct_zai_namespace():
|
||||
served = [model_id for model_id in _ids("openrouter") if model_id.startswith("zai/")]
|
||||
assert served == [], (
|
||||
@@ -66,14 +78,19 @@ def test_openrouter_setup_exposes_z_ai_models():
|
||||
|
||||
|
||||
def test_openrouter_projection_is_namespace_only():
|
||||
"""The OpenRouter list stays a 1:1, order-preserving projection."""
|
||||
"""The OpenRouter list stays a 1:1, order-preserving projection.
|
||||
|
||||
Labels are preserved for every entry except the #7520 remap slots, whose
|
||||
label names the model actually served.
|
||||
"""
|
||||
fallback = config._FALLBACK_MODELS
|
||||
openrouter = _models("openrouter")
|
||||
|
||||
assert len(openrouter) == len(fallback)
|
||||
for source, projected in zip(fallback, openrouter, strict=True):
|
||||
assert projected["label"] == source["label"]
|
||||
assert projected["id"] == _expected_openrouter_id(source["id"])
|
||||
if source["id"] not in _OPENROUTER_REMAPS:
|
||||
assert projected["label"] == source["label"]
|
||||
|
||||
|
||||
def test_direct_zai_setup_keeps_direct_provider_ids():
|
||||
|
||||
Reference in new issue
Block a user