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(lint): update return/yield types to ModelResponseStream
Chesars43319b562a4e
diff --git a/litellm/llms/bedrock/chat/agentcore/transformation.py b/litellm/llms/bedrock/chat/agentcore/transformation.pyindex b85a0b70f76..fe7d4b194a2 100644--- a/litellm/llms/bedrock/chat/agentcore/transformation.py+++ b/litellm/llms/bedrock/chat/agentcore/transformation.py@@ -601,7 +601,7 @@ class AmazonAgentCoreConfig(BaseConfig, BaseAWSLLM):self,response: httpx.Response,model: str,- ) -> AsyncGenerator[ModelResponse, None]:+ ) -> AsyncGenerator[ModelResponseStream, None]:"""Internal async generator that parses SSE and yields ModelResponse chunks."""diff --git a/litellm/llms/langgraph/chat/sse_iterator.py b/litellm/llms/langgraph/chat/sse_iterator.pyindex 8d946c4e52f..cf81998055a 100644--- a/litellm/llms/langgraph/chat/sse_iterator.py+++ b/litellm/llms/langgraph/chat/sse_iterator.py@@ -11,7 +11,7 @@ from typing import TYPE_CHECKING, Optionalimport httpxfrom litellm._logging import verbose_logger-from litellm.types.utils import Delta, ModelResponse, ModelResponseStream, StreamingChoices+from litellm.types.utils import Delta, ModelResponseStream, StreamingChoicesif TYPE_CHECKING:pass@@ -44,7 +44,7 @@ class LangGraphSSEStreamIterator:self.async_line_iterator = self.response.aiter_lines()return self- def _parse_sse_line(self, line: str) -> Optional[ModelResponse]:+ def _parse_sse_line(self, line: str) -> Optional[ModelResponseStream]:"""Parse a single SSE line and return a ModelResponse chunk if applicable.@@ -71,7 +71,7 @@ class LangGraphSSEStreamIterator:return None- def _process_data(self, data) -> Optional[ModelResponse]:+ def _process_data(self, data) -> Optional[ModelResponseStream]:"""Process parsed data from SSE stream.@@ -101,7 +101,7 @@ class LangGraphSSEStreamIterator:return None- def _process_messages_event(self, payload) -> Optional[ModelResponse]:+ def _process_messages_event(self, payload) -> Optional[ModelResponseStream]:"""Process a messages event from the stream.@@ -128,7 +128,7 @@ class LangGraphSSEStreamIterator:return None- def _process_metadata_event(self, payload) -> Optional[ModelResponse]:+ def _process_metadata_event(self, payload) -> Optional[ModelResponseStream]:"""Process a metadata event, which may signal the end of the stream."""@@ -177,7 +177,7 @@ class LangGraphSSEStreamIterator:return chunk- def __next__(self) -> ModelResponse:+ def __next__(self) -> ModelResponseStream:"""Sync iteration - parse SSE events and yield ModelResponse chunks."""try:if self.line_iterator is None:@@ -205,7 +205,7 @@ class LangGraphSSEStreamIterator:verbose_logger.error(f"Error in LangGraph SSE stream: {str(e)}")raise StopIteration- async def __anext__(self) -> ModelResponse:+ async def __anext__(self) -> ModelResponseStream:"""Async iteration - parse SSE events and yield ModelResponse chunks."""try:if self.async_line_iterator is None:diff --git a/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py b/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.pyindex cf3461a9960..1783b5e630c 100644--- a/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py+++ b/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py@@ -2093,7 +2093,7 @@ class VertexGeminiConfig(VertexAIBaseConfig, BaseConfig):chat_completion_logprobs=chat_completion_logprobs,image_response=image_response,)- model_response.choices.append(choice)+ model_response.choices.append(choice) # type: ignore[arg-type]elif isinstance(model_response, ModelResponse):choice = litellm.Choices(finish_reason=VertexGeminiConfig._check_finish_reason(