@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / 215bf150a6
Fork 0

A high-throughput and memory-efficient inference and serving engine for LLMs

Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git

Synced Nov 15, 22:15 UTC

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

Florian Greinacher committed Feb 26, 2025 at 12:06 UTC 215bf150a61ed3aafba35df65c95f63c82cc94b2
2 files changed +36 -2
tests/tokenization/test_mistral_tokenizer.py
+34 -1
@@ -41,7 +41,40 @@ from vllm.transformers_utils.tokenizers.mistral import (
41 )
42 ],
43 ),
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 + )],
78 )
79 def test_make_mistral_chat_completion_request(openai_request,
80 expected_mistral_request):
vllm/transformers_utils/tokenizers/mistral.py
+2 -1
@@ -164,7 +164,8 @@ def make_mistral_chat_completion_request(
164 tool["function"] for tool in tools
165 if tool["type"] == "function"
166 ]:
167 - function.setdefault("parameters", {})
167 + if function.get("parameters") is None:
168 + function["parameters"] = {}
169
170 from mistral_common.protocol.instruct.request import ChatCompletionRequest
171 return ChatCompletionRequest(messages=messages,