The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
refactor(model_info): return Mapping from fill_missing matchers
kerrye366d3bd302e
diff --git a/litellm/litellm_core_utils/fallback_generalizations.py b/litellm/litellm_core_utils/fallback_generalizations.pyindex 9b5c369b56e..25ea1bff613 100644--- a/litellm/litellm_core_utils/fallback_generalizations.py+++ b/litellm/litellm_core_utils/fallback_generalizations.py@@ -53,7 +53,9 @@ O(number of rules); callers must only invoke them on a cache miss.import loggingimport re+from collections.abc import Mappingfrom dataclasses import dataclass+from types import MappingProxyTypefrom typing import Finalverbose_logger: Final = logging.getLogger("LiteLLM")@@ -209,9 +211,7 @@ class _FallbackGeneralizations:return Nonereturn {key: value for model_info in matched for key, value in model_info.items()}- def match_fill_missing(- self, model: str, provider: str- ) -> dict[str, object] | None: # mutable-ok: preserve the existing dict return contract+ def match_fill_missing(self, model: str, provider: str) -> Mapping[str, object] | None:if not model or not provider:return Nonematched = tuple(@@ -221,9 +221,9 @@ class _FallbackGeneralizations:)if not matched:return None- fill_missing: Final[dict[str, object]] = { # mutable-ok: preserve the existing dict merge input- key: value for model_info in matched for key, value in model_info.items() if key != PROVIDER_KEY- }+ fill_missing: Final[Mapping[str, object]] = MappingProxyType(+ {key: value for model_info in matched for key, value in model_info.items() if key != PROVIDER_KEY}+ )return fill_missing or None@@ -263,9 +263,7 @@ def match_capability_generalizations(model: str) -> dict | None:return _registry.match_capabilities(model)-def match_fill_missing_generalizations(- model: str, provider: str-) -> dict[str, object] | None: # mutable-ok: preserve the existing dict return contract+def match_fill_missing_generalizations(model: str, provider: str) -> Mapping[str, object] | None:"""Return flagged capability rules matching ``model`` for ``provider``.Later rules override earlier ones on key conflicts. Only rules listing