From 3adfb70fc9d8f08332a77060a5eadf641f4ff2a0 Mon Sep 17 00:00:00 2001 From: Michael Struwig Date: Fri, 22 Mar 2024 15:05:29 +0200 Subject: [PATCH] Fix XML function calling args parsing. --- litellm/llms/prompt_templates/factory.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/litellm/llms/prompt_templates/factory.py b/litellm/llms/prompt_templates/factory.py index 62a387e0b3..c4f2d163c1 100644 --- a/litellm/llms/prompt_templates/factory.py +++ b/litellm/llms/prompt_templates/factory.py @@ -727,10 +727,14 @@ def parse_xml_params(xml_content): root = ET.fromstring(xml_content) params = {} for child in root.findall(".//parameters/*"): - params[child.tag] = child.text + try: + # Attempt to decode the element's text as JSON + params[child.tag] = json.loads(child.text) + except json.JSONDecodeError: + # If JSON decoding fails, use the original text + params[child.tag] = child.text return params - ###