Skip to content

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]

Merge remote-tracking branch 'origin/litellm_internal_staging' into litellm_fix_toolcall_stream_linear_assembly

mateo-berri8c7792a5cc3d
diff --cc litellm/litellm_core_utils/streaming_chunk_builder_utils.py
index 029a18d7514,b21703509cb..a2f9c80f577
--- a/litellm/litellm_core_utils/streaming_chunk_builder_utils.py
+++ b/litellm/litellm_core_utils/streaming_chunk_builder_utils.py
@@@ -1,9 -1,7 +1,9 @@@
import base64
import time
-from collections.abc import Mapping, Sequence
+from collections.abc import Iterator, Mapping, Sequence
+from itertools import groupby
+from types import MappingProxyType
- from typing import TYPE_CHECKING, Any, Union, cast
+ from typing import TYPE_CHECKING, Any, Final, Union, cast
from litellm._logging import verbose_logger
from litellm.types.llms.openai import (
@@@ -360,8 -324,6 +360,10 @@@ class ChunkProcessor
if isinstance(provider_fields, dict):
tool_call_map[index]["provider_specific_fields"].update(provider_fields)
- joined_fragments = self._join_fragments_by_index_and_field(self._iter_tool_call_fragments(tool_call_chunks))
++ joined_fragments: Final = self._join_fragments_by_index_and_field(
++ self._iter_tool_call_fragments(tool_call_chunks)
++ )
+
# Convert the map to a list of tool calls
for index in sorted(tool_call_map.keys()):
tool_call_data = tool_call_map[index]