From 94f4f969943ca8304b09661c86d7086a681fabb0 Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Tue, 27 Feb 2024 14:57:50 -0800 Subject: [PATCH] fix(utils.py): fix streaming issue --- litellm/utils.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/litellm/utils.py b/litellm/utils.py index d8986be6b..658ebba65 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -282,9 +282,12 @@ class Delta(OpenAIObject): if tool_calls is not None and isinstance(tool_calls, list): self.tool_calls = [] for tool_call in tool_calls: - if tool_call.get("index", None) is None: - tool_call["index"] = 0 - self.tool_calls.append(ChatCompletionDeltaToolCall(**tool_call)) + if isinstance(tool_call, dict): + if tool_call.get("index", None) is None: + tool_call["index"] = 0 + self.tool_calls.append(ChatCompletionDeltaToolCall(**tool_call)) + elif isinstance(tool_call, ChatCompletionDeltaToolCall): + self.tool_calls.append(tool_call) else: self.tool_calls = tool_calls