diff --git a/litellm/integrations/websearch_interception/handler.py b/litellm/integrations/websearch_interception/handler.py index f6b40836c3a..e59ef0449d0 100644 --- a/litellm/integrations/websearch_interception/handler.py +++ b/litellm/integrations/websearch_interception/handler.py @@ -10,7 +10,7 @@ import asyncio import math import uuid from collections.abc import AsyncIterator, Mapping, Sequence -from typing import TYPE_CHECKING, Any, Final, TypedDict, TypeVar, cast +from typing import TYPE_CHECKING, Any, Final, TypedDict, cast from typing_extensions import ReadOnly @@ -106,9 +106,6 @@ class _UserAuthView(TypedDict): team_id: ReadOnly[str | None] -_ResponseT: Final = TypeVar("_ResponseT") - - class WebSearchInterceptionLogger(CustomLogger): """ CustomLogger that intercepts WebSearch tool calls for models that don't @@ -929,7 +926,7 @@ class WebSearchInterceptionLogger(CustomLogger): ) @staticmethod - def _inject_native_blocks(response: _ResponseT, native_blocks: Sequence[Mapping[str, object]]) -> _ResponseT: + def _inject_native_blocks(response: Any, native_blocks: Sequence[Mapping[str, object]]) -> Any: """Prepend native blocks to response content, dict or object form.""" if not native_blocks: return response @@ -939,7 +936,7 @@ class WebSearchInterceptionLogger(CustomLogger): return response existing = getattr(response, "content", None) or [] try: - setattr(response, "content", list(native_blocks) + list(existing)) + response.content = list(native_blocks) + list(existing) except (AttributeError, TypeError): # Object refused write — fall through and leave the response # untouched rather than crash the request.