From 0eb67e50a174c3c52eeabab26bb7c16e3afb31ee Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Tue, 5 Mar 2024 16:48:37 -0800 Subject: [PATCH] fix(utils.py): handle none in tool call for mistral tool calling --- litellm/utils.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/litellm/utils.py b/litellm/utils.py index fa3457143..33f4f1c3d 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -225,9 +225,25 @@ class ChatCompletionDeltaToolCall(OpenAIObject): class ChatCompletionMessageToolCall(OpenAIObject): - id: str - function: Function - type: str + def __init__( + self, + function: Function, + id: Optional[str] = None, + type: Optional[str] = None, + **params, + ): + super(ChatCompletionMessageToolCall, self).__init__(**params) + self.function = function + + if id is not None: + self.id = id + else: + self.id = f"{uuid.uuid4()}" + + if type is not None: + self.type = type + else: + self.type = "function" class Message(OpenAIObject): @@ -6232,7 +6248,7 @@ def convert_to_model_response_object( return model_response_object except Exception as e: - raise Exception(f"Invalid response object {e}") + raise Exception(f"Invalid response object {traceback.format_exc()}") def acreate(*args, **kwargs): ## Thin client to handle the acreate langchain call