Merge pull request #46857 from liuhao1024/fix/model-picker-merge-live-static

fix(models): merge live API results with curated static catalog in generic provider path
This commit is contained in:
kshitij
2026-06-16 23:30:34 +05:30
committed by GitHub
3 changed files with 227 additions and 2 deletions
+27 -2
View File
@@ -2370,8 +2370,15 @@ 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, []))
# Merge static curated list with live API results so
# models that the live endpoint omits (stale cache,
# partial rollout) still appear in the picker.
# Curated entries come first so deliberately-surfaced
# newest models (e.g. kimi-k2.7-code, #46309) stay at
# the top of the picker; live-only entries are appended
# afterwards for discovery. (#46850)
curated = list(_PROVIDER_MODELS.get(normalized, []))
if curated:
merged = list(curated)
merged_lower = {m.lower() for m in curated}
for m in live:
@@ -3934,6 +3941,24 @@ def validate_requested_model(
if suggestions:
suggestion_text = "\n Similar models: " + ", ".join(f"`{s}`" for s in suggestions)
# Model not in live /v1/models — check the curated catalog
# before rejecting. Providers may omit models from their live
# listing that are still valid (stale cache, partial rollout,
# gated previews). Use the pure-catalog helper (no extra live
# fetch) so we only accept models Hermes actually ships. (#46850)
if _model_in_provider_catalog(
requested_for_lookup.lower(), _provider_keys(normalized)
):
return {
"accepted": True,
"persist": True,
"recognized": True,
"message": (
f"Note: `{requested}` was not found in the live /v1/models listing "
f"but exists in the curated catalog — accepted."
),
}
return {
"accepted": False,
"persist": False,