Skip to content

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]

refactor(router): validate classifier snapshots without recursion

moe-berri33954d9cfe3e
diff --git a/litellm/litellm_core_utils/classifier_logging.py b/litellm/litellm_core_utils/classifier_logging.py
index b9cb52a190d..c0c93161099 100644
--- a/litellm/litellm_core_utils/classifier_logging.py
+++ b/litellm/litellm_core_utils/classifier_logging.py
@@ -13,13 +13,13 @@ _JSON_OBJECT: Final = TypeAdapter(dict[str, JsonValue])
def classifier_input_snapshot(value: object, *, openai_sdk: bool = False) -> Mapping[str, JsonValue] | None:
- if openai_sdk and isinstance(value, Mapping):
- body: Final = {
- key: item for key, item in value.items() if key not in ("extra_headers", "extra_query", "extra_body")
- }
- extra_body: Final = value.get("extra_body")
- return classifier_input_snapshot({**body, **extra_body} if isinstance(extra_body, Mapping) else body)
try:
+ if openai_sdk and isinstance(value, Mapping):
+ body: Final = {
+ key: item for key, item in value.items() if key not in ("extra_headers", "extra_query", "extra_body")
+ }
+ extra_body: Final = value.get("extra_body")
+ return _JSON_OBJECT.validate_python({**body, **extra_body} if isinstance(extra_body, Mapping) else body)
return (
_JSON_OBJECT.validate_json(value)
if isinstance(value, (str, bytes))