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(websearch): build the search tool lists as tuples
Yuneng Jiangc65dfd5d3785
diff --git a/litellm/integrations/websearch_interception/handler.py b/litellm/integrations/websearch_interception/handler.pyindex 3694bf70b48..dc61ee38a8c 100644--- a/litellm/integrations/websearch_interception/handler.py+++ b/litellm/integrations/websearch_interception/handler.py@@ -1633,16 +1633,18 @@ class WebSearchInterceptionLogger(CustomLogger):def _select_search_tool_from_router(self, llm_router: object) -> "_SearchToolConfig | None":if llm_router is None or not hasattr(llm_router, "search_tools"):return None- search_tools: Final = list(getattr(llm_router, "search_tools", None) or [])+ search_tools: Final = tuple(getattr(llm_router, "search_tools", None) or ())return self._select_search_tool_from_list(search_tools=search_tools, source="router")def _select_search_tool_from_list(self,- search_tools: list[_SearchToolConfig],+ search_tools: Sequence[_SearchToolConfig],source: str,) -> "_SearchToolConfig | None":if self.search_tool_name:- matching_tools = [tool for tool in search_tools if tool.get("search_tool_name") == self.search_tool_name]+ matching_tools: Final = tuple(+ tool for tool in search_tools if tool.get("search_tool_name") == self.search_tool_name+ )if matching_tools:search_provider = (matching_tools[0].get("litellm_params", {}) or {}).get("search_provider")verbose_logger.debug(