From 8dbbdc90c7732dde1d5d4d7aec8ec538c002a36a Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Mon, 19 Oct 2026 09:38:53 -0700 Subject: [PATCH] fix(proxy): keep listed ids on /model/info alias rows and clean up test-registered models --- litellm/proxy/auth/model_checks.py | 15 +--------- tests/unit/proxy/auth/test_model_checks.py | 33 ++++++---------------- 2 files changed, 9 insertions(+), 39 deletions(-) diff --git a/litellm/proxy/auth/model_checks.py b/litellm/proxy/auth/model_checks.py index 5dde12f16bd..ef2d6610e2e 100644 --- a/litellm/proxy/auth/model_checks.py +++ b/litellm/proxy/auth/model_checks.py @@ -375,17 +375,6 @@ def get_known_models_from_wildcard(wildcard_model: str, litellm_params: LiteLLM_ return list(dict.fromkeys(suffix_appended_wildcard_models)) -def _deployment_model_serving(listed_id: str, name_pattern: str, deployment_model: str) -> str: - listed_match: Final = ( - None if name_pattern == "*" else re.fullmatch(PatternMatchRouter().pattern_to_regex(name_pattern), listed_id) - ) - if listed_match is None: - return listed_id - return PatternMatchRouter.set_deployment_model_name( - matched_pattern=listed_match, litellm_deployment_litellm_model=deployment_model - ) - - def expand_wildcard_deployments_for_model_info( deployments: list[dict[str, object]], ) -> list[dict[str, object]]: @@ -434,9 +423,7 @@ def expand_wildcard_deployments_for_model_info( row["model_name"] = name params = row.get("litellm_params") if isinstance(params, dict): - params["model"] = _deployment_model_serving( - name, name_pattern=model_name, deployment_model=litellm_model - ) + params["model"] = name expanded.append(row) return expanded diff --git a/tests/unit/proxy/auth/test_model_checks.py b/tests/unit/proxy/auth/test_model_checks.py index bf3d52d650d..36c07d62fa2 100644 --- a/tests/unit/proxy/auth/test_model_checks.py +++ b/tests/unit/proxy/auth/test_model_checks.py @@ -1211,9 +1211,11 @@ def _registered_chat_models(provider_by_model: Mapping[str, str]) -> Generator[N try: yield finally: - for model, provider in provider_by_model.items(): + provider_model_sets: Final = tuple(known for known in vars(litellm).values() if isinstance(known, set)) + for model in provider_by_model: litellm.model_cost.pop(model, None) - litellm.models_by_provider[provider].discard(model) + for provider_models in provider_model_sets: + provider_models.discard(model) litellm.add_known_models(model_cost_map={}) @@ -1339,17 +1341,16 @@ def test_every_listed_partial_wildcard_id_routes_to_the_catalog_model_it_names( infer_model_from_keys=False, llm_router=router, ) - model_info_rows: Final = tuple( - (str(row["model_name"]), TypeAdapter(LiteLLM_Params).validate_python(row["litellm_params"]).model) + model_info_names: Final = [ + str(row["model_name"]) for row in expand_wildcard_deployments_for_model_info( [dict(deployment) for deployment in router.get_model_list() or []] ) - ) + ] listed_v1_models: Final = routed_catalog_ids(v1_models) - listed_model_info_names: Final = routed_catalog_ids([name for name, _ in model_info_rows]) + listed_model_info_names: Final = routed_catalog_ids(model_info_names) assert listed_v1_models == sorted(reachable) - assert [shown_model for _, shown_model in model_info_rows] == [routed_model(name) for name, _ in model_info_rows] if key_model is None: assert listed_model_info_names == sorted(reachable) @@ -1375,21 +1376,3 @@ def test_catch_all_over_a_partial_deployment_lists_no_catalog_ids(deployment_mod assert v1_models == [] assert model_info_rows == deployments - -def test_catch_all_model_info_rows_show_the_listed_provider_model() -> None: - from pydantic import TypeAdapter - - from litellm.proxy.auth.model_checks import expand_wildcard_deployments_for_model_info - from litellm.types.router import LiteLLM_Params - - listed_id: Final = "openai/partial-route-catch-all-model" - with _registered_chat_models({listed_id.removeprefix("openai/"): "openai"}): - model_info_rows: Final = expand_wildcard_deployments_for_model_info( - [{"model_name": "*", "litellm_params": {"model": "openai/*"}}] - ) - - shown_models: Final = { - str(row["model_name"]): TypeAdapter(LiteLLM_Params).validate_python(row["litellm_params"]).model - for row in model_info_rows - } - assert shown_models[listed_id] == listed_id