Unverified Commit 25708d31 authored by Michard Hugo's avatar Michard Hugo Committed by GitHub
Browse files

[Bugfix] Mistral crashes on tool with no description (#21167)


Signed-off-by: default avatarHugoMichard <hugo@harfanglab.fr>
parent 0e18a5d0
...@@ -183,7 +183,8 @@ def make_mistral_chat_completion_request( ...@@ -183,7 +183,8 @@ def make_mistral_chat_completion_request(
message["content"] = content message["content"] = content
# The Mistral client, in comparison to the OpenAI client, requires the # The Mistral client, in comparison to the OpenAI client, requires the
# "parameters" dict to be present, even if it's empty. # "parameters" dict and the "description" string to be present
# even if they are empty.
if tools: if tools:
for function in [ for function in [
tool["function"] for tool in tools tool["function"] for tool in tools
...@@ -191,6 +192,8 @@ def make_mistral_chat_completion_request( ...@@ -191,6 +192,8 @@ def make_mistral_chat_completion_request(
]: ]:
if function.get("parameters") is None: if function.get("parameters") is None:
function["parameters"] = {} function["parameters"] = {}
if function.get("description") is None:
function["description"] = ""
from mistral_common.protocol.instruct.request import ChatCompletionRequest from mistral_common.protocol.instruct.request import ChatCompletionRequest
return ChatCompletionRequest(messages=messages, return ChatCompletionRequest(messages=messages,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment