From ce235facd0aa2ce70cc4adaf8418f96d5b1df0e4 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Thu, 14 Nov 2024 12:45:37 -0800 Subject: [PATCH] fix _convert_tool_response_to_message --- litellm/llms/anthropic/chat/handler.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/litellm/llms/anthropic/chat/handler.py b/litellm/llms/anthropic/chat/handler.py index 6976ea0e5..ac4123df3 100644 --- a/litellm/llms/anthropic/chat/handler.py +++ b/litellm/llms/anthropic/chat/handler.py @@ -339,8 +339,10 @@ class AnthropicChatCompletion(BaseLLM): try: if json_mode_content_str is not None: args = json.loads(json_mode_content_str) - values: Optional[dict] = args.get("values") - if values is not None: + if ( + isinstance(args, dict) + and (values := args.get("values")) is not None + ): _message = litellm.Message(content=json.dumps(values)) return _message else: