fix(anthropic.py): handle scenario where anthropic returns invalid json string for tool call while streaming

Fixes https://github.com/BerriAI/litellm/issues/5063
This commit is contained in:
Krrish Dholakia 2024-08-07 09:24:11 -07:00
parent 1008f24b16
commit 4919cc4d25
5 changed files with 105 additions and 7 deletions

View file

@ -5113,7 +5113,9 @@ def stream_chunk_builder(
prev_index = curr_index
prev_id = curr_id
combined_arguments = "".join(argument_list)
combined_arguments = (
"".join(argument_list) or "{}"
) # base case, return empty dict
tool_calls_list.append(
{
"id": id,