[Bugfix] Handle None parameters in Mistral function calls. (#13786)
This commit is contained in:
parent
0ecdd98031
commit
215bf150a6
@ -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,
|
def test_make_mistral_chat_completion_request(openai_request,
|
||||||
expected_mistral_request):
|
expected_mistral_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,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user