fix(models): _norm_model_id strips multi-segment provider prefixes (#1454)

This commit is contained in:
Hermes Bot committed 2026-05-02 16:49:55 +00:00
commit 9c893c8bc5
1 file changed
+7 -5
+7 -5
View File
@@ -1506,10 +1506,13 @@ def get_available_models() -> dict:
def _norm_model_id(model_id: str) -> str:
s = str(model_id or "").strip().lower()
# Strip @provider: prefix (e.g., @custom:jingdong:GLM-5 -> GLM-5)
if s.startswith("@") and ":" in s:
s = s.split(":", 1)[1]
# Split on all colons and take the last part
s = s.split(":")[-1]
# Strip provider/model prefix (e.g., custom:jingdong/GLM-5 -> GLM-5)
if "/" in s:
s = s.split("/", 1)[1]
s = s.split("/")[-1]
return s.replace("-", ".")
def _build_configured_model_badges() -> dict[str, dict[str, str]]:
@@ -2079,9 +2082,8 @@ def get_available_models() -> dict:
)
if default_model:
_norm = lambda mid: (mid.split("/", 1)[-1] if "/" in mid else mid).replace("-", ".")
all_ids_norm = {_norm(m["id"]) for g in groups for m in g.get("models", [])}
if _norm(default_model) not in all_ids_norm:
all_ids_norm = {_norm_model_id(m["id"]) for g in groups for m in g.get("models", [])}
if _norm_model_id(default_model) not in all_ids_norm:
label = _get_label_for_model(default_model, groups)
target_display = (
_PROVIDER_DISPLAY.get(active_provider, active_provider or "").lower()