From 872ff6176d506dfb4f7e2ee8d22505c98b96c6c6 Mon Sep 17 00:00:00 2001 From: Lucca Zenobio Date: Wed, 20 Mar 2024 15:22:23 -0300 Subject: [PATCH] updates --- litellm/llms/prompt_templates/factory.py | 6 +++--- litellm/utils.py | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/litellm/llms/prompt_templates/factory.py b/litellm/llms/prompt_templates/factory.py index b23f1031510..abe340e7d10 100644 --- a/litellm/llms/prompt_templates/factory.py +++ b/litellm/llms/prompt_templates/factory.py @@ -604,13 +604,13 @@ def convert_to_anthropic_tool_result(message: dict) -> str: def convert_to_anthropic_tool_invoke(tool_calls: list) -> str: invokes = "" for tool in tool_calls: - if tool["type"] != "function": + if tool.type != "function": continue - tool_name = tool["function"]["name"] + tool_name = tool.function.name parameters = "".join( f"<{param}>{val}\n" - for param, val in json.loads(tool["function"]["arguments"]).items() + for param, val in json.loads(tool.function.arguments).items() ) invokes += ( "\n" diff --git a/litellm/utils.py b/litellm/utils.py index a8c0031812e..57327473d88 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -271,7 +271,10 @@ class Message(OpenAIObject): if tool_calls is not None: self.tool_calls = [] for tool_call in tool_calls: - self.tool_calls.append(ChatCompletionMessageToolCall(**tool_call)) + if isinstance(tool_call, dict): + self.tool_calls.append(ChatCompletionMessageToolCall(**tool_call)) + else: + self.tool_calls.append(tool_call) if logprobs is not None: self._logprobs = logprobs