mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-10 22:41:41 +00:00
fix(factory.py): support mistral ai prefix:true in messages
Fixes https://github.com/BerriAI/litellm/issues/4882
This commit is contained in:
parent
e3a94ac013
commit
e0f3cd580c
1 changed files with 8 additions and 1 deletions
|
|
@ -235,6 +235,12 @@ def mistral_api_pt(messages):
|
|||
"""
|
||||
new_messages = []
|
||||
for m in messages:
|
||||
special_keys = ["role", "content", "tool_calls"]
|
||||
extra_args = {}
|
||||
if isinstance(m, dict):
|
||||
for k, v in m.items():
|
||||
if k not in special_keys:
|
||||
extra_args[k] = v
|
||||
texts = ""
|
||||
if isinstance(m["content"], list):
|
||||
for c in m["content"]:
|
||||
|
|
@ -244,7 +250,8 @@ def mistral_api_pt(messages):
|
|||
texts += c["text"]
|
||||
elif isinstance(m["content"], str):
|
||||
texts = m["content"]
|
||||
new_m = {"role": m["role"], "content": texts}
|
||||
|
||||
new_m = {"role": m["role"], "content": texts, **extra_args}
|
||||
|
||||
if new_m["role"] == "tool" and m.get("name"):
|
||||
new_m["name"] = m["name"]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue