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 tool call coalescing
Joe Cheng33f4411f17b7
diff --git a/litellm/main.py b/litellm/main.pyindex 989e0b11063..36267aec1d6 100644--- a/litellm/main.py+++ b/litellm/main.py@@ -5094,7 +5094,7 @@ def stream_chunk_builder(name = Nonetype = Nonetool_calls_list = []- prev_index = 0+ prev_index = Noneprev_id = Nonecurr_id = Nonecurr_index = 0@@ -5120,6 +5120,8 @@ def stream_chunk_builder(name = tool_calls[0].function.nameif tool_calls[0].type:type = tool_calls[0].type+ if prev_index is None:+ prev_index = curr_indexif curr_index != prev_index: # new tool callcombined_arguments = "".join(argument_list)tool_calls_list.append(@@ -5138,6 +5140,7 @@ def stream_chunk_builder(tool_calls_list.append({"id": id,+ "index": curr_index,"function": {"arguments": combined_arguments, "name": name},"type": type,}