Unverified Commit 215bf150 authored by Florian Greinacher's avatar Florian Greinacher Committed by GitHub
Browse files

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

parent 0ecdd980
...@@ -41,6 +41,39 @@ from vllm.transformers_utils.tokenizers.mistral import ( ...@@ -41,6 +41,39 @@ 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, def test_make_mistral_chat_completion_request(openai_request,
......
...@@ -164,7 +164,8 @@ def make_mistral_chat_completion_request( ...@@ -164,7 +164,8 @@ def make_mistral_chat_completion_request(
tool["function"] for tool in tools tool["function"] for tool in tools
if tool["type"] == "function" if tool["type"] == "function"
]: ]:
function.setdefault("parameters", {}) if function.get("parameters") is None:
function["parameters"] = {}
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