From a3f90ab7351f9df475eb169bc17bf6f1081bcbc9 Mon Sep 17 00:00:00 2001 From: alisalim17 Date: Thu, 18 Apr 2024 20:49:01 +0400 Subject: [PATCH] fix: add missing tool_calls and function name to messages in mistral_api_pt --- litellm/llms/prompt_templates/factory.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/litellm/llms/prompt_templates/factory.py b/litellm/llms/prompt_templates/factory.py index 8afda252a..5c57c2369 100644 --- a/litellm/llms/prompt_templates/factory.py +++ b/litellm/llms/prompt_templates/factory.py @@ -145,6 +145,12 @@ def mistral_api_pt(messages): elif isinstance(m["content"], str): texts = m["content"] new_m = {"role": m["role"], "content": texts} + + if new_m["role"] == "tool" and m.get("name"): + new_m["name"] = m["name"] + if m.get("tool_calls"): + new_m["tool_calls"] = m["tool_calls"] + new_messages.append(new_m) return new_messages