mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-07 08:26:10 +00:00
fix(streaming): skip empty partial_json in trigger chunk delta
Only emit the trigger chunk's input_json_delta when partial_json is non-empty. OpenAI-style providers send arguments="" in the first tool chunk, which was producing a spurious empty content_block_delta event and breaking existing test expectations.
This commit is contained in:
parent
0dc0919d39
commit
47a8d4b080
1 changed files with 11 additions and 4 deletions
|
|
@ -144,9 +144,12 @@ class AnthropicStreamWrapper(AdapterCompletionStreamWrapper):
|
|||
)
|
||||
# Also emit the trigger chunk's delta so that providers like
|
||||
# Ollama that send the complete tool call in a single chunk
|
||||
# do not lose their arguments.
|
||||
# do not lose their tool arguments. Skip empty deltas
|
||||
# (e.g. OpenAI sends arguments="" in the first tool chunk).
|
||||
if processed_chunk.get("type") == "content_block_delta":
|
||||
self.chunk_queue.append(processed_chunk)
|
||||
delta = processed_chunk.get("delta", {})
|
||||
if delta.get("partial_json"):
|
||||
self.chunk_queue.append(processed_chunk)
|
||||
self.sent_content_block_finish = False
|
||||
return self.chunk_queue.popleft()
|
||||
|
||||
|
|
@ -328,9 +331,13 @@ class AnthropicStreamWrapper(AdapterCompletionStreamWrapper):
|
|||
|
||||
# Also emit the trigger chunk's delta so that providers
|
||||
# like Ollama that send the complete tool call in a
|
||||
# single chunk do not lose their arguments.
|
||||
# single chunk do not lose their tool arguments. Skip
|
||||
# empty deltas (e.g. OpenAI sends arguments="" in the
|
||||
# first tool chunk).
|
||||
if processed_chunk.get("type") == "content_block_delta":
|
||||
self.chunk_queue.append(processed_chunk)
|
||||
delta = processed_chunk.get("delta", {})
|
||||
if delta.get("partial_json"):
|
||||
self.chunk_queue.append(processed_chunk)
|
||||
|
||||
# Reset state for new block
|
||||
self.sent_content_block_finish = False
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue