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(router): build the Jev client without rebinding the constructor argument
mateod7b281ce8f1f
diff --git a/litellm/router_strategy/complexity_router/complexity_router.py b/litellm/router_strategy/complexity_router/complexity_router.pyindex b98b52b25d8..c29f3b3a542 100644--- a/litellm/router_strategy/complexity_router/complexity_router.py+++ b/litellm/router_strategy/complexity_router/complexity_router.py@@ -105,6 +105,7 @@ from .config import (ComplexityRouterConfig,ComplexityTier,CustomDimension,+ JevClassifierConfig,TierDefinition,)from .jev_classifier import (@@ -1265,6 +1266,18 @@ class ComplexityRouter(CustomLogger):- Question complexity (multiple questions)"""+ @staticmethod+ def _build_jev_client(config: JevClassifierConfig) -> JevClassifierClient:+ api_key: Final = config.api_key or get_secret_str("TYPESAFE_API_KEY")+ if not api_key:+ raise ValueError("jev_classifier_config.api_key or TYPESAFE_API_KEY is required for classifier_type 'jev'")+ api_base: Final = config.api_base or get_secret_str("TYPESAFE_API_BASE") or "https://api.typesafe.ai"+ return HttpJevClassifierClient(+ api_key=api_key,+ api_base=api_base,+ http_client=get_async_httpx_client(httpxSpecialProvider.PassThroughEndpoint),+ )+def __init__(self,model_name: str,@@ -1301,19 +1314,13 @@ class ComplexityRouter(CustomLogger):self.config.default_model = default_modeljev_config: Final = self.config.jev_classifier_config- if self.config.classifier_type == "jev" and jev_client is None and jev_config is not None:- api_key: Final = jev_config.api_key or get_secret_str("TYPESAFE_API_KEY")- if not api_key:- raise ValueError(- "jev_classifier_config.api_key or TYPESAFE_API_KEY is required for classifier_type 'jev'"- )- api_base: Final = jev_config.api_base or get_secret_str("TYPESAFE_API_BASE") or "https://api.typesafe.ai"- jev_client = HttpJevClassifierClient(- api_key=api_key,- api_base=api_base,- http_client=get_async_httpx_client(httpxSpecialProvider.PassThroughEndpoint),- )- self._jev_client = jev_client+ self._jev_client: JevClassifierClient | None = (+ jev_client+ if jev_client is not None+ else self._build_jev_client(jev_config)+ if self.config.classifier_type == "jev" and jev_config is not None+ else None+ )self._tier_affinity_config = hashlib.sha256(self.config.model_dump_json(include=MappingProxyType({"tiers": True, "tier_model_configs": True})).encode()