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 errors
Sameerlite92cb34eb2545
diff --git a/litellm/proxy/pass_through_endpoints/llm_passthrough_endpoints.py b/litellm/proxy/pass_through_endpoints/llm_passthrough_endpoints.pyindex d93c9ca22a9..fb44281cadb 100644--- a/litellm/proxy/pass_through_endpoints/llm_passthrough_endpoints.py+++ b/litellm/proxy/pass_through_endpoints/llm_passthrough_endpoints.py@@ -700,7 +700,8 @@ async def bedrock_proxy_route(# Add or update query parametersfrom litellm.llms.bedrock.chat import BedrockConverseLLM- credentials: Credentials = BedrockConverseLLM().get_credentials()+ bedrock_llm = BedrockConverseLLM()+ credentials: Credentials = bedrock_llm.get_credentials() # type: ignoresigv4 = SigV4Auth(credentials, "bedrock", aws_region_name)headers = {"Content-Type": "application/json"}# Assuming the body contains JSON data, parse it@@ -1293,18 +1294,22 @@ async def vertex_ai_live_websocket_passthrough()resolved_project = vertex_project- resolved_location = vertex_location+ resolved_location: Optional[str] = vertex_locationcredentials_value: Optional[str] = Noneif vertex_credentials_config is not None:resolved_project = resolved_project or vertex_credentials_config.vertex_project- resolved_location = (+ temp_location = (resolved_location or vertex_credentials_config.vertex_location)# Ensure resolved_location is a string- if isinstance(resolved_location, dict):- resolved_location = str(resolved_location)- credentials_value = vertex_credentials_config.vertex_credentials+ if isinstance(temp_location, dict):+ resolved_location = str(temp_location)+ elif temp_location is not None:+ resolved_location = str(temp_location)+ else:+ resolved_location = None+ credentials_value = str(vertex_credentials_config.vertex_credentials) if vertex_credentials_config.vertex_credentials is not None else Nonetry:resolved_location = resolved_location or (diff --git a/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py b/litellm/proxy/pass_through_endpoints/pass_through_endpoints.pyindex 749df08d4b6..b12c2814bc0 100644--- a/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py+++ b/litellm/proxy/pass_through_endpoints/pass_through_endpoints.py@@ -506,7 +506,7 @@ class HttpPassThroughEndpointHelpers(BasePassthroughUtils):kwargs = {"litellm_params": {- **litellm_params_in_body,+ **litellm_params_in_body, # type: ignore"metadata": _metadata,"proxy_server_request": {"url": str(request.url),@@ -1126,7 +1126,7 @@ async def websocket_passthrough_request( # noqa: PLR0915# Create a dummy request object for WebSocket connections to maintain compatibility# with the existing _init_kwargs_for_pass_through_endpoint functionclass DummyRequest:- def __init__(self, url: str, method: str = "WEBSOCKET", headers: dict = None):+ def __init__(self, url: str, method: str = "WEBSOCKET", headers: Optional[dict] = None):self.url = urlself.method = methodself.headers = headers or {}@@ -1146,7 +1146,7 @@ async def websocket_passthrough_request( # noqa: PLR0915_parsed_body={}, # WebSocket doesn't have a traditional request bodypassthrough_logging_payload=passthrough_logging_payload,litellm_call_id=litellm_call_id,- request=dummy_request,+ request=dummy_request, # type: ignorelogging_obj=logging_obj,)@@ -1379,8 +1379,8 @@ async def websocket_passthrough_request( # noqa: PLR0915end_time = datetime.now()# Update passthrough logging payload with response data- passthrough_logging_payload["response_body"] = websocket_messages- passthrough_logging_payload["end_time"] = end_time+ passthrough_logging_payload["response_body"] = websocket_messages # type: ignore+ passthrough_logging_payload["end_time"] = end_time # type: ignore# Remove logging_obj from kwargs to avoid duplicate keyword argumentsuccess_kwargs = kwargs.copy()@@ -1419,9 +1419,9 @@ async def websocket_passthrough_request( # noqa: PLR0915# Use the same success handler as HTTP passthrough endpointsasyncio.create_task(pass_through_endpoint_logging.pass_through_async_success_handler(- httpx_response=mock_response, # Use mock response for WebSocket- response_body=websocket_messages,- url_route=endpoint,+ httpx_response=mock_response, # type: ignore+ response_body=websocket_messages, # type: ignore+ url_route=endpoint or "",result="websocket_connection_successful",start_time=start_time,end_time=end_time,@@ -1437,7 +1437,7 @@ async def websocket_passthrough_request( # noqa: PLR0915await proxy_logging_obj.post_call_success_hook(data={},user_api_key_dict=user_api_key_dict,- response={"status": "websocket_connection_successful"},+ response={"status": "websocket_connection_successful"}, # type: ignore)except InvalidStatus as exc: