mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-15 09:12:18 +00:00
refactor(proxy): take a read-only mapping for the model-id lookup
_get_model_id_from_response only reads its request payload, so a Mapping says what it needs and the two metadata hops are narrowed instead of assumed to be dicts.
This commit is contained in:
parent
2e138511ed
commit
7ac5002f8d
1 changed files with 4 additions and 4 deletions
|
|
@ -2158,13 +2158,13 @@ class ProxyBaseLLMRequestProcessing:
|
|||
return fallback_model_group
|
||||
|
||||
@staticmethod
|
||||
def _get_model_id_from_response(hidden_params: Mapping[str, object], data: dict) -> str:
|
||||
def _get_model_id_from_response(hidden_params: Mapping[str, object], data: Mapping[str, object]) -> str:
|
||||
"""Extract model_id from hidden_params with fallback to litellm_metadata."""
|
||||
model_id = hidden_params.get("model_id", None) or ""
|
||||
if not model_id:
|
||||
litellm_metadata: Final = data.get("litellm_metadata", {}) or {}
|
||||
model_info: Final = litellm_metadata.get("model_info", {}) or {}
|
||||
model_id = model_info.get("id", "") or ""
|
||||
litellm_metadata: Final = data.get("litellm_metadata")
|
||||
model_info: Final = litellm_metadata.get("model_info") if isinstance(litellm_metadata, Mapping) else None
|
||||
model_id = (model_info.get("id") or "") if isinstance(model_info, Mapping) else ""
|
||||
return str(model_id) if model_id else ""
|
||||
|
||||
def _stream_response_headers(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue