diff --git a/litellm/llms/anthropic/experimental_pass_through/adapters/handler.py b/litellm/llms/anthropic/experimental_pass_through/adapters/handler.py index 87bb3c4ed25..06446de1ff1 100644 --- a/litellm/llms/anthropic/experimental_pass_through/adapters/handler.py +++ b/litellm/llms/anthropic/experimental_pass_through/adapters/handler.py @@ -319,7 +319,7 @@ ANTHROPIC_ADAPTER: Final = AnthropicAdapter() class LiteLLMMessagesToCompletionTransformationHandler: @staticmethod - def _is_thinking_disabled(thinking: dict | None) -> bool: + def _is_thinking_disabled(thinking: Mapping | None) -> bool: """Return True when the client's thinking param is absent or explicitly disabled.""" return thinking is None or (isinstance(thinking, dict) and thinking.get("type") == "disabled") diff --git a/litellm/llms/anthropic/experimental_pass_through/adapters/streaming_iterator.py b/litellm/llms/anthropic/experimental_pass_through/adapters/streaming_iterator.py index 2efa9157575..0c77fd495e8 100644 --- a/litellm/llms/anthropic/experimental_pass_through/adapters/streaming_iterator.py +++ b/litellm/llms/anthropic/experimental_pass_through/adapters/streaming_iterator.py @@ -1169,7 +1169,7 @@ class AnthropicStreamWrapper(AdapterCompletionStreamWrapper): return ( LiteLLMAnthropicMessagesAdapter._classify_streaming_chunk( - choices=chunk.choices, # type: ignore + choices=chunk.choices, thinking_disabled=thinking_disabled, ) != "skip" @@ -1232,7 +1232,7 @@ class AnthropicStreamWrapper(AdapterCompletionStreamWrapper): block_type, content_block_start, ) = LiteLLMAnthropicMessagesAdapter()._translate_streaming_openai_chunk_to_anthropic_content_block( - choices=chunk.choices, # type: ignore + choices=chunk.choices, thinking_disabled=self.thinking_disabled, ) diff --git a/litellm/llms/anthropic/experimental_pass_through/adapters/transformation.py b/litellm/llms/anthropic/experimental_pass_through/adapters/transformation.py index 546ae55ec29..2bc925c6c83 100644 --- a/litellm/llms/anthropic/experimental_pass_through/adapters/transformation.py +++ b/litellm/llms/anthropic/experimental_pass_through/adapters/transformation.py @@ -1562,7 +1562,7 @@ class LiteLLMAnthropicMessagesAdapter: @staticmethod def _classify_streaming_chunk( - choices: list["OpenAIStreamingChoice | StreamingChoices"], + choices: Sequence["OpenAIStreamingChoice | StreamingChoices"], thinking_disabled: bool = False, ) -> Literal["thinking", "redacted_thinking", "tool_use", "text", "skip"]: """ @@ -1667,7 +1667,7 @@ class LiteLLMAnthropicMessagesAdapter: def _translate_streaming_openai_chunk_to_anthropic_content_block( self, - choices: list[OpenAIStreamingChoice | StreamingChoices], + choices: Sequence["OpenAIStreamingChoice | StreamingChoices | Choices"], thinking_disabled: bool = False, ) -> tuple[ Literal["text", "tool_use", "thinking", "redacted_thinking"], @@ -1732,7 +1732,7 @@ class LiteLLMAnthropicMessagesAdapter: def _translate_streaming_openai_chunk_to_anthropic( self, - choices: list[OpenAIStreamingChoice | StreamingChoices], + choices: Sequence["OpenAIStreamingChoice | StreamingChoices | Choices"], thinking_disabled: bool = False, ) -> tuple[ StreamingContentBlockDeltaType, @@ -1757,7 +1757,7 @@ class LiteLLMAnthropicMessagesAdapter: def _accumulate_streaming_chunk_payloads( self, - choices: list[OpenAIStreamingChoice | StreamingChoices], + choices: Sequence["OpenAIStreamingChoice | StreamingChoices"], thinking_disabled: bool = False, ) -> tuple[str, str, str, str | None]: """Fold a chunk's choices into (text, reasoning_content, reasoning_signature, partial_json). @@ -1838,7 +1838,7 @@ class LiteLLMAnthropicMessagesAdapter: type_of_content, content_block_delta, ) = self._translate_streaming_openai_chunk_to_anthropic( - choices=response.choices, # type: ignore + choices=response.choices, thinking_disabled=thinking_disabled, ) return ContentBlockDelta(