Skip to content

Commit

Permalink
Merge pull request #277 from edenai/SD2-694-cant-add-new-mistral-models
Browse files Browse the repository at this point in the history
add new mistral models
  • Loading branch information
Daggx authored Oct 21, 2024
2 parents 289b1a2 + 0f0af49 commit c214cce
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions edenai_apis/apis/mistral/mistral_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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:
Expand All @@ -141,23 +143,26 @@ 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,
}

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(
Expand Down

0 comments on commit c214cce

Please sign in to comment.