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
fix mypy linting
yuneng-jiang2a4066646af5
diff --git a/litellm/integrations/custom_guardrail.py b/litellm/integrations/custom_guardrail.pyindex 407bc581f71..fb395366004 100644--- a/litellm/integrations/custom_guardrail.py+++ b/litellm/integrations/custom_guardrail.py@@ -624,7 +624,9 @@ class CustomGuardrail(CustomLogger):This gets logged on downsteam Langfuse, DataDog, etc."""# Convert None to empty dict to satisfy type requirements- guardrail_response = {} if response is None else response+ guardrail_response: Union[Dict[str, Any], str] = (+ {} if response is None else response+ )# For apply_guardrail functions in custom_code_guardrail scenario,# simplify the logged response to "allow", "deny", or "mask"diff --git a/litellm/llms/custom_httpx/aiohttp_transport.py b/litellm/llms/custom_httpx/aiohttp_transport.pyindex 1b03ec47643..fb98006c7e4 100644--- a/litellm/llms/custom_httpx/aiohttp_transport.py+++ b/litellm/llms/custom_httpx/aiohttp_transport.py@@ -4,7 +4,7 @@ import osimport sslimport typingimport urllib.request-from typing import Callable, Dict, Optional, Union+from typing import Any, Callable, Dict, Optional, Unionimport aiohttpimport aiohttp.client_exceptions@@ -248,26 +248,25 @@ class LiteLLMAiohttpTransport(AiohttpTransport):# Only pass ssl kwarg when explicitly configured, to avoid# overriding the session/connector defaults with None (which is# not a valid value for aiohttp's ssl parameter).- ssl_kwargs: Dict[str, Union[bool, ssl.SSLContext]] = {}- if ssl_verify is not None:- ssl_kwargs["ssl"] = ssl_verify-- response = await client_session.request(- method=request.method,- url=YarlURL(str(request.url), encoded=True),- headers=request.headers,- data=data,- allow_redirects=False,- auto_decompress=False,- timeout=ClientTimeout(+ request_kwargs: Dict[str, Any] = {+ "method": request.method,+ "url": YarlURL(str(request.url), encoded=True),+ "headers": request.headers,+ "data": data,+ "allow_redirects": False,+ "auto_decompress": False,+ "timeout": ClientTimeout(sock_connect=timeout.get("connect"),sock_read=timeout.get("read"),connect=timeout.get("pool"),),- proxy=proxy,- server_hostname=sni_hostname,- **ssl_kwargs,- ).__aenter__()+ "proxy": proxy,+ "server_hostname": sni_hostname,+ }+ if ssl_verify is not None:+ request_kwargs["ssl"] = ssl_verify++ response = await client_session.request(**request_kwargs).__aenter__()return responsediff --git a/litellm/proxy/guardrails/guardrail_hooks/model_armor/model_armor.py b/litellm/proxy/guardrails/guardrail_hooks/model_armor/model_armor.pyindex 38462094b11..2d3f048f81b 100644--- a/litellm/proxy/guardrails/guardrail_hooks/model_armor/model_armor.py+++ b/litellm/proxy/guardrails/guardrail_hooks/model_armor/model_armor.py@@ -330,6 +330,7 @@ class ModelArmorGuardrail(CustomGuardrail, VertexBase):end_time: Optional[float] = None,duration: Optional[float] = None,event_type: Optional[GuardrailEventHooks] = None,+ original_inputs: Optional[dict] = None,):"""Override to store only the Model Armor API response, not the entire data dict.