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

Signed-off-by: HugoMichard <hugo@harfanglab.fr>
This commit is contained in:
Michard Hugo 2025-07-28 17:03:35 +02:00 committed by GitHub
parent 0e18a5d058
commit 25708d317a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -183,7 +183,8 @@ def make_mistral_chat_completion_request(
message["content"] = content
# 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:
for function in [
tool["function"] for tool in tools
@ -191,6 +192,8 @@ def make_mistral_chat_completion_request(
]:
if function.get("parameters") is None:
function["parameters"] = {}
if function.get("description") is None:
function["description"] = ""
from mistral_common.protocol.instruct.request import ChatCompletionRequest
return ChatCompletionRequest(messages=messages,