From 0f0af4987c9cffb93372131e1ea63ac817c9384f Mon Sep 17 00:00:00 2001 From: Daggx Date: Mon, 21 Oct 2024 15:33:03 +0200 Subject: [PATCH] add new mistral models --- edenai_apis/apis/mistral/mistral_api.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/edenai_apis/apis/mistral/mistral_api.py b/edenai_apis/apis/mistral/mistral_api.py index b0dba7d1..c8eb68b8 100644 --- a/edenai_apis/apis/mistral/mistral_api.py +++ b/edenai_apis/apis/mistral/mistral_api.py @@ -115,7 +115,7 @@ def text__chat( "content": msg.get("message"), } if msg.get("tool_calls"): - message['tool_calls'] = [ + message["tool_calls"] = [ { "id": t.get("id"), "function": { @@ -132,7 +132,9 @@ def text__chat( if tool_results: for tool in tool_results or []: - tool_call = get_tool_call_from_history_by_id(tool['id'], previous_history) + tool_call = get_tool_call_from_history_by_id( + tool["id"], previous_history + ) try: result = json.dumps(tool["result"]) except json.JSONDecodeError: @@ -141,15 +143,18 @@ def text__chat( { "role": "tool", "content": result, - "name": tool_call['name'], + "name": tool_call["name"], } ) if chatbot_global_action: messages.insert(0, {"role": "system", "content": chatbot_global_action}) + if "ministral" not in model: + model = f"{self.provider_name}-{model}" + payload = { - "model": f"{self.provider_name}-{model}", + "model": model, "messages": messages, "temperature": temperature, "max_tokens": max_tokens, @@ -157,7 +162,7 @@ def text__chat( if available_tools: payload["tools"] = convert_tools_to_openai(available_tools) - payload["tool_choice"] = 'any' if tool_choice == 'required' else tool_choice + payload["tool_choice"] = "any" if tool_choice == "required" else tool_choice if not stream: response = requests.post(