fix(models): merge live API results with curated static catalog in generic provider path

When a provider's live /v1/models endpoint returns a stale or incomplete
list (e.g. Z.AI missing glm-5.2), the generic profile-based code path
returned only the live results, silently dropping curated models.

Generalize the kimi-coding merge pattern to all providers: live entries
come first (provider's preferred order), then curated-only entries are
appended with case-insensitive dedup. This ensures models that the live
endpoint omits still appear in /model picker.

Fixes #46850
This commit is contained in:
liuhao1024
2026-06-16 16:21:01 +08:00
parent c6b0eb4de0
commit 630b43892d
3 changed files with 125 additions and 6 deletions
+10 -5
View File
@@ -2370,11 +2370,16 @@ def provider_model_ids(provider: Optional[str], *, force_refresh: bool = False)
if api_key:
live = _p.fetch_models(api_key=api_key)
if live:
if normalized in {"kimi-coding", "kimi-coding-cn"}:
curated = list(_PROVIDER_MODELS.get(normalized, []))
merged = list(curated)
merged_lower = {m.lower() for m in curated}
for m in live:
# Merge live API results with static curated list so
# models that the live endpoint omits (stale cache,
# partial rollout) still appear in the picker.
# Live entries come first (provider's preferred order),
# then curated-only entries are appended. (#46850)
curated = list(_PROVIDER_MODELS.get(normalized, []))
if curated:
merged = list(live)
merged_lower = {m.lower() for m in live}
for m in curated:
if m.lower() not in merged_lower:
merged.append(m)
merged_lower.add(m.lower())