Skip to content

Commit 215bf15

Browse files
authored
[Bugfix] Handle None parameters in Mistral function calls. (#13786)
1 parent 0ecdd98 commit 215bf15

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

tests/tokenization/test_mistral_tokenizer.py

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,40 @@
4141
)
4242
],
4343
),
44-
)],
44+
),
45+
(
46+
{
47+
"messages":
48+
[{
49+
"role": "user",
50+
"content": "What is the current local date and time?",
51+
}],
52+
"tools": [{
53+
"type": "function",
54+
"function": {
55+
"description": "Fetch the current local date and time.",
56+
"name": "get_current_time",
57+
"parameters": None,
58+
},
59+
}],
60+
},
61+
ChatCompletionRequest(
62+
messages=[
63+
UserMessage(
64+
content="What is the current local date and time?")
65+
],
66+
tools=[
67+
Tool(
68+
type="function",
69+
function=Function(
70+
name="get_current_time",
71+
description="Fetch the current local date and time.",
72+
parameters={},
73+
),
74+
)
75+
],
76+
),
77+
)],
4578
)
4679
def test_make_mistral_chat_completion_request(openai_request,
4780
expected_mistral_request):

vllm/transformers_utils/tokenizers/mistral.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ def make_mistral_chat_completion_request(
164164
tool["function"] for tool in tools
165165
if tool["type"] == "function"
166166
]:
167-
function.setdefault("parameters", {})
167+
if function.get("parameters") is None:
168+
function["parameters"] = {}
168169

169170
from mistral_common.protocol.instruct.request import ChatCompletionRequest
170171
return ChatCompletionRequest(messages=messages,

0 commit comments

Comments
 (0)