From ca3d2fea5694d0eb7cf4c3db354e12274df43ef3 Mon Sep 17 00:00:00 2001 From: Nilanjan De Date: Thu, 18 Apr 2024 22:42:32 +0400 Subject: [PATCH] fix for #2904, remove XML characters in content --- litellm/llms/prompt_templates/factory.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/litellm/llms/prompt_templates/factory.py b/litellm/llms/prompt_templates/factory.py index 7ba0ee0070..218aa77fea 100644 --- a/litellm/llms/prompt_templates/factory.py +++ b/litellm/llms/prompt_templates/factory.py @@ -594,7 +594,8 @@ def convert_to_anthropic_tool_result_xml(message: dict) -> str: """ name = message.get("name") - content = message.get("content") + content = message.get("content", "") + content = content.replace("<", "<").replace(">", ">").replace("&", "&") # We can't determine from openai message format whether it's a successful or # error call result so default to the successful result template