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 issues
Sameer Kankute125e11d36e46
diff --git a/litellm/integrations/websearch_interception/handler.py b/litellm/integrations/websearch_interception/handler.pyindex 7e8fa66c493..82d91d811ef 100644--- a/litellm/integrations/websearch_interception/handler.py+++ b/litellm/integrations/websearch_interception/handler.py@@ -490,7 +490,8 @@ class WebSearchInterceptionLogger(CustomLogger):)# Make follow-up request with search results- follow_up_messages = messages + [assistant_message, user_message]+ # Type cast: user_message is a Dict for Anthropic format (default response_format)+ follow_up_messages = messages + [assistant_message, cast(Dict, user_message)]verbose_logger.debug("WebSearchInterception: Making follow-up request with search results"@@ -702,10 +703,10 @@ class WebSearchInterceptionLogger(CustomLogger):# Make follow-up request with search results# For OpenAI format, tool_messages_or_user is a list of tool messagesif response_format == "openai":- follow_up_messages = messages + [assistant_message] + tool_messages_or_user+ follow_up_messages = messages + [assistant_message] + cast(List[Dict], tool_messages_or_user)else:# For Anthropic format (shouldn't happen in this method, but handle it)- follow_up_messages = messages + [assistant_message, tool_messages_or_user]+ follow_up_messages = messages + [assistant_message, cast(Dict, tool_messages_or_user)]verbose_logger.debug("WebSearchInterception: Making follow-up chat completion request with search results"diff --git a/litellm/integrations/websearch_interception/transformation.py b/litellm/integrations/websearch_interception/transformation.pyindex ad92f5d03d0..e44ec35c3a2 100644--- a/litellm/integrations/websearch_interception/transformation.py+++ b/litellm/integrations/websearch_interception/transformation.py@@ -4,7 +4,7 @@ WebSearch Tool TransformationTransforms between Anthropic/OpenAI tool_use format and LiteLLM search format."""import json-from typing import Any, Dict, List, Tuple+from typing import Any, Dict, List, Tuple, Unionfrom litellm._logging import verbose_loggerfrom litellm.constants import LITELLM_WEB_SEARCH_TOOL_NAME@@ -224,7 +224,7 @@ class WebSearchTransformation:tool_calls: List[Dict],search_results: List[str],response_format: str = "anthropic",- ) -> Tuple[Dict, Dict]:+ ) -> Tuple[Dict, Union[Dict, List[Dict]]]:"""Transform LiteLLM search results to Anthropic/OpenAI tool_result format.