mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-14 23:21:35 +00:00
fix(responses): accept empty function argument deltas (#33341)
This commit is contained in:
parent
6a797f97b2
commit
265bf871bc
2 changed files with 22 additions and 1 deletions
|
|
@ -1196,7 +1196,7 @@ class OpenAiResponsesToChatCompletionStreamIterator(BaseModelResponseIterator):
|
|||
)
|
||||
elif event_type == "response.function_call_arguments.delta":
|
||||
content_part: Optional[str] = parsed_chunk.get("delta", None)
|
||||
if content_part:
|
||||
if isinstance(content_part, str):
|
||||
tool_call_index = parsed_chunk.get("output_index", 0)
|
||||
return ModelResponseStream(
|
||||
choices=[
|
||||
|
|
|
|||
|
|
@ -257,3 +257,24 @@ def test_translate_responses_chunk_passthrough_chat_completion_chunk():
|
|||
|
||||
assert result.choices[0].delta.content == "Hi! How can I help?"
|
||||
assert result.choices[0].finish_reason is None
|
||||
|
||||
|
||||
def test_translate_responses_chunk_accepts_empty_function_argument_delta():
|
||||
from litellm.completion_extras.litellm_responses_transformation.transformation import (
|
||||
OpenAiResponsesToChatCompletionStreamIterator,
|
||||
)
|
||||
|
||||
result = OpenAiResponsesToChatCompletionStreamIterator.translate_responses_chunk_to_openai_stream(
|
||||
{
|
||||
"type": "response.function_call_arguments.delta",
|
||||
"item_id": "fc_test",
|
||||
"output_index": 0,
|
||||
"delta": "",
|
||||
"sequence_number": 3,
|
||||
}
|
||||
)
|
||||
|
||||
tool_calls = result.choices[0].delta.tool_calls
|
||||
assert tool_calls is not None
|
||||
assert tool_calls[0].function is not None
|
||||
assert tool_calls[0].function.arguments == ""
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue