Skip to content

Commit 573517a

Browse files
fix function_call_prompt() to handle list of dicts in message content
1 parent 063b83c commit 573517a

File tree

1 file changed

+12
-2
lines changed
  • litellm/litellm_core_utils/prompt_templates

1 file changed

+12
-2
lines changed

litellm/litellm_core_utils/prompt_templates/factory.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3809,8 +3809,18 @@ def function_call_prompt(messages: list, functions: list):
38093809
function_added_to_prompt = False
38103810
for message in messages:
38113811
if "system" in message["role"]:
3812-
message["content"] += f""" {function_prompt}"""
3813-
function_added_to_prompt = True
3812+
if isinstance(message["content"], str):
3813+
message["content"] += f""" {function_prompt}"""
3814+
function_added_to_prompt = True
3815+
elif isinstance(message["content"], list) and message["content"] and "text" in message["content"][0]:
3816+
message["content"].append({
3817+
"type": "text",
3818+
"text": function_prompt
3819+
})
3820+
function_added_to_prompt = True
3821+
3822+
if function_added_to_prompt:
3823+
break
38143824

38153825
if function_added_to_prompt is False:
38163826
messages.append({"role": "system", "content": f"""{function_prompt}"""})

0 commit comments

Comments
 (0)