mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-05 02:41:56 +00:00
fix(realtime): add response.output_item.done to complete tool-call sequence
- Emit response.output_item.done between function_call_arguments.done and conversation.item.created - Required by OpenAI Realtime spec to finalize function-call items - Update test to verify complete event sequence Made-with: Cursor
This commit is contained in:
parent
77571e811d
commit
4fb0833670
2 changed files with 24 additions and 3 deletions
|
|
@ -1122,6 +1122,22 @@ class GeminiRealtimeConfig(BaseRealtimeConfig):
|
|||
})
|
||||
# response.function_call_arguments.done
|
||||
returned_message.append(tool_call)
|
||||
# response.output_item.done
|
||||
returned_message.append({
|
||||
"type": "response.output_item.done",
|
||||
"event_id": f"event_{uuid.uuid4()}",
|
||||
"response_id": current_response_id,
|
||||
"output_index": idx,
|
||||
"item": {
|
||||
"id": item_id,
|
||||
"object": "realtime.item",
|
||||
"type": "function_call",
|
||||
"status": "completed",
|
||||
"call_id": tool_call["call_id"],
|
||||
"name": tool_call["name"],
|
||||
"arguments": tool_call["arguments"],
|
||||
},
|
||||
})
|
||||
# conversation.item.created
|
||||
returned_message.append({
|
||||
"type": "conversation.item.created",
|
||||
|
|
|
|||
|
|
@ -655,13 +655,18 @@ def test_gemini_tool_call_emits_response_created_preamble():
|
|||
)
|
||||
|
||||
responses = result["response"]
|
||||
# Should have: response.created, output_item.added, function_call_arguments.done, conversation.item.created
|
||||
assert len(responses) >= 4
|
||||
# Should have: response.created, output_item.added, function_call_arguments.done, output_item.done, conversation.item.created
|
||||
assert len(responses) >= 5
|
||||
assert responses[0]["type"] == "response.created"
|
||||
assert "response" in responses[0]
|
||||
assert responses[0]["response"]["status"] == "in_progress"
|
||||
assert responses[1]["type"] == "response.output_item.added"
|
||||
assert responses[1]["item"]["type"] == "function_call"
|
||||
assert responses[1]["item"]["status"] == "in_progress"
|
||||
assert responses[2]["type"] == "response.function_call_arguments.done"
|
||||
assert responses[3]["type"] == "conversation.item.created"
|
||||
assert responses[3]["type"] == "response.output_item.done"
|
||||
assert responses[3]["item"]["type"] == "function_call"
|
||||
assert responses[3]["item"]["status"] == "completed"
|
||||
assert responses[4]["type"] == "conversation.item.created"
|
||||
assert responses[4]["item"]["type"] == "function_call"
|
||||
assert responses[4]["item"]["status"] == "completed"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue