forked from Karylab-cklius/vllm
[Tests] Add Qwen3 streaming parser delta boundary cases (#45708)
Signed-off-by: test test <2260891073@qq.com>
This commit is contained in:
@@ -1300,6 +1300,73 @@ def test_streaming_multi_param_single_chunk(qwen3_tool_parser, qwen3_tokenizer):
|
||||
assert args["unit"] == "fahrenheit"
|
||||
|
||||
|
||||
def test_streaming_complete_tool_call_single_delta(qwen3_tool_parser):
|
||||
"""Regression: one delta may contain a complete tool call."""
|
||||
request = ChatCompletionRequest(model=MODEL, messages=[])
|
||||
|
||||
from tests.tool_parsers.utils import (
|
||||
run_tool_extraction_streaming,
|
||||
)
|
||||
|
||||
reconstructor = run_tool_extraction_streaming(
|
||||
qwen3_tool_parser,
|
||||
[
|
||||
(
|
||||
"<tool_call>\n"
|
||||
"<function=get_current_weather>\n"
|
||||
"<parameter=city>\nDallas\n</parameter>\n"
|
||||
"<parameter=state>\nTX\n</parameter>\n"
|
||||
"</function>\n"
|
||||
"</tool_call>"
|
||||
)
|
||||
],
|
||||
request,
|
||||
assert_one_tool_per_delta=False,
|
||||
)
|
||||
|
||||
assert len(reconstructor.tool_calls) == 1
|
||||
assert reconstructor.tool_calls[0].function.name == "get_current_weather"
|
||||
args = json.loads(reconstructor.tool_calls[0].function.arguments)
|
||||
assert args == {"city": "Dallas", "state": "TX"}
|
||||
|
||||
|
||||
def test_streaming_next_tool_call_starts_in_close_delta(qwen3_tool_parser):
|
||||
"""Regression: a close delta may also contain the next tool call."""
|
||||
request = ChatCompletionRequest(model=MODEL, messages=[])
|
||||
|
||||
from tests.tool_parsers.utils import (
|
||||
run_tool_extraction_streaming,
|
||||
)
|
||||
|
||||
reconstructor = run_tool_extraction_streaming(
|
||||
qwen3_tool_parser,
|
||||
[
|
||||
"<tool_call>\n",
|
||||
"<function=get_current_weather>\n",
|
||||
"<parameter=city>\nDallas\n</parameter>\n",
|
||||
"<parameter=state>\nTX\n</parameter>\n",
|
||||
"</function>",
|
||||
(
|
||||
"\n</tool_call>\n"
|
||||
"<tool_call>\n"
|
||||
"<function=get_current_weather>\n"
|
||||
"<parameter=city>\nOrlando\n</parameter>\n"
|
||||
"<parameter=state>\nFL\n</parameter>\n"
|
||||
"</function>\n"
|
||||
"</tool_call>"
|
||||
),
|
||||
],
|
||||
request,
|
||||
assert_one_tool_per_delta=False,
|
||||
)
|
||||
|
||||
assert len(reconstructor.tool_calls) == 2
|
||||
first_args = json.loads(reconstructor.tool_calls[0].function.arguments)
|
||||
second_args = json.loads(reconstructor.tool_calls[1].function.arguments)
|
||||
assert first_args == {"city": "Dallas", "state": "TX"}
|
||||
assert second_args == {"city": "Orlando", "state": "FL"}
|
||||
|
||||
|
||||
def test_no_double_serialization_string_args(qwen3_tool_parser):
|
||||
"""Regression: string arguments must not be double-serialized (PR #35615)."""
|
||||
tools = [
|
||||
|
||||
Reference in New Issue
Block a user