[Bugfix] Handle None parameters in Mistral function calls. (#13786)

This commit is contained in:
Florian Greinacher 2025-02-26 12:06:21 +01:00 committed by GitHub
parent 0ecdd98031
commit 215bf150a6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 36 additions and 2 deletions

View File

@ -41,7 +41,40 @@ from vllm.transformers_utils.tokenizers.mistral import (
)
],
),
)],
),
(
{
"messages":
[{
"role": "user",
"content": "What is the current local date and time?",
}],
"tools": [{
"type": "function",
"function": {
"description": "Fetch the current local date and time.",
"name": "get_current_time",
"parameters": None,
},
}],
},
ChatCompletionRequest(
messages=[
UserMessage(
content="What is the current local date and time?")
],
tools=[
Tool(
type="function",
function=Function(
name="get_current_time",
description="Fetch the current local date and time.",
parameters={},
),
)
],
),
)],
)
def test_make_mistral_chat_completion_request(openai_request,
expected_mistral_request):

View File

@ -164,7 +164,8 @@ def make_mistral_chat_completion_request(
tool["function"] for tool in tools
if tool["type"] == "function"
]:
function.setdefault("parameters", {})
if function.get("parameters") is None:
function["parameters"] = {}
from mistral_common.protocol.instruct.request import ChatCompletionRequest
return ChatCompletionRequest(messages=messages,