mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-07 02:59:05 +00:00
Fix tool call index assignment in Delta class
- Update tool call index logic to assign sequential indices when missing - Replace default index=0 behavior with proper sequential assignment - Maintain OpenAI API compatibility with correct tool call indexing - Preserve existing behavior for tool calls with explicit indices - Universal fix benefiting all providers using Delta class
This commit is contained in:
parent
c5ca2afec3
commit
802f7011e2
1 changed files with 3 additions and 1 deletions
|
|
@ -754,10 +754,12 @@ class Delta(OpenAIObject):
|
|||
self.function_call = function_call
|
||||
if tool_calls is not None and isinstance(tool_calls, list):
|
||||
self.tool_calls = []
|
||||
current_index = 0
|
||||
for tool_call in tool_calls:
|
||||
if isinstance(tool_call, dict):
|
||||
if tool_call.get("index", None) is None:
|
||||
tool_call["index"] = 0
|
||||
tool_call["index"] = current_index
|
||||
current_index += 1
|
||||
self.tool_calls.append(ChatCompletionDeltaToolCall(**tool_call))
|
||||
elif isinstance(tool_call, ChatCompletionDeltaToolCall):
|
||||
self.tool_calls.append(tool_call)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue