diff --git a/litellm/integrations/custom_guardrail.py b/litellm/integrations/custom_guardrail.py index 407bc581f7..fb39536600 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.py index 1b03ec4764..fb98006c7e 100644 --- a/litellm/llms/custom_httpx/aiohttp_transport.py +++ b/litellm/llms/custom_httpx/aiohttp_transport.py @@ -4,7 +4,7 @@ import os import ssl import typing import urllib.request -from typing import Callable, Dict, Optional, Union +from typing import Any, Callable, Dict, Optional, Union import aiohttp import 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 response diff --git a/litellm/proxy/guardrails/guardrail_hooks/model_armor/model_armor.py b/litellm/proxy/guardrails/guardrail_hooks/model_armor/model_armor.py index 38462094b1..2d3f048f81 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.