mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-06 08:16:43 +00:00
fix(anthropic): don't drop text_delta when backend sends empty tool_calls
Some OpenAI-compatible backends (e.g. mlx_lm.server) always populate tool_calls:[] in every streaming delta, even for plain-text responses. The check `if choice.delta.tool_calls is not None` treats an empty list as truthy, entering the tool_calls branch and overwriting partial_json to "", which drops the actual text content. Add a length check so empty tool_calls lists are ignored, allowing text_delta events to flow through correctly. Fixes BerriAI/litellm#25172 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
39c1042258
commit
573f678690
1 changed files with 1 additions and 1 deletions
|
|
@ -1418,7 +1418,7 @@ class LiteLLMAnthropicMessagesAdapter:
|
|||
for choice in choices:
|
||||
if choice.delta.content is not None and len(choice.delta.content) > 0:
|
||||
text += choice.delta.content
|
||||
if choice.delta.tool_calls is not None:
|
||||
if choice.delta.tool_calls is not None and len(choice.delta.tool_calls) > 0:
|
||||
partial_json = ""
|
||||
for tool in choice.delta.tool_calls:
|
||||
if (
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue