From c85018c780529579206ce2428db7a2bfa053923c Mon Sep 17 00:00:00 2001 From: Nilanjan De Date: Thu, 18 Apr 2024 18:13:20 +0400 Subject: [PATCH] update factory.py --- litellm/llms/prompt_templates/factory.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/litellm/llms/prompt_templates/factory.py b/litellm/llms/prompt_templates/factory.py index 6658671f8e6..5b8fc9a6f45 100644 --- a/litellm/llms/prompt_templates/factory.py +++ b/litellm/llms/prompt_templates/factory.py @@ -695,6 +695,8 @@ def anthropic_messages_pt_xml(messages: list): assistant_text = ( messages[msg_i].get("content") or "" ) # either string or none + if assistant_text: + assistant_content.append({"type": "text", "text": assistant_text}) if messages[msg_i].get( "tool_calls", [] ): # support assistant tool invoke convertion @@ -703,8 +705,6 @@ def anthropic_messages_pt_xml(messages: list): messages[msg_i]["tool_calls"] ) ) - - assistant_content.append({"type": "text", "text": assistant_text}) msg_i += 1 if assistant_content: