Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add new mistral models #277

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading