Add pydocstyle to the ruff rules (#52136)
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com> Signed-off-by: Harry Mellor <hej.mellor@gmail.com> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
804e5377aa
commit
8c1557a79c
@@ -49,6 +49,7 @@ class ToolParserTestConfig:
|
||||
Special flags:
|
||||
allow_empty_or_json_empty_args: True if "" or "{}" both valid for empty args
|
||||
supports_typed_arguments: True if the parser supports typed function arguments
|
||||
|
||||
"""
|
||||
|
||||
# Parser identification
|
||||
@@ -110,6 +111,7 @@ class ToolParserTests:
|
||||
def test_mistral_specific_feature(self, tool_parser):
|
||||
# Custom test logic
|
||||
pass
|
||||
|
||||
"""
|
||||
|
||||
@pytest.fixture
|
||||
|
||||
@@ -341,7 +341,8 @@ class TestStreamingExtraction:
|
||||
|
||||
def test_mtp_streaming_massive_chunk(self, parser, mock_request):
|
||||
"""Simulates MTP predicting text, tool calls,
|
||||
and trailing text all in a single chunk."""
|
||||
and trailing text all in a single chunk.
|
||||
"""
|
||||
chunks = [
|
||||
"Sure! "
|
||||
'<|tools_prefix|>[{"get_weather": {"location": "London"}}]<|tools_suffix|>'
|
||||
@@ -374,7 +375,8 @@ class TestStreamingExtraction:
|
||||
|
||||
def test_mtp_streaming_skip_and_catch_up(self, parser, mock_request):
|
||||
"""Simulates MTP chunks that jump over entire tools
|
||||
(e.g., from middle of tool 1 to middle of tool 3)."""
|
||||
(e.g., from middle of tool 1 to middle of tool 3).
|
||||
"""
|
||||
chunks = [
|
||||
'<|tools_prefix|>[{"t1": {"a": 1}',
|
||||
'}, {"t2": {"b": 2}}, {"t3": {"c": 3',
|
||||
@@ -393,7 +395,8 @@ class TestStreamingExtraction:
|
||||
|
||||
def test_vllm_streaming_character_by_character(self, parser, mock_request):
|
||||
"""Simulates worst-case vLLM fragmentation where
|
||||
chunks arrive character-by-character."""
|
||||
chunks arrive character-by-character.
|
||||
"""
|
||||
text = (
|
||||
'Hi <|tools_prefix|>[{"get_weather": '
|
||||
'{"location": "London"}}]<|tools_suffix|> '
|
||||
@@ -411,7 +414,8 @@ class TestStreamingExtraction:
|
||||
|
||||
def test_vllm_streaming_empty_deltas(self, parser, mock_request):
|
||||
"""Simulates vLLM stream producing empty string chunks
|
||||
(e.g., hidden tokens or artifacts)."""
|
||||
(e.g., hidden tokens or artifacts).
|
||||
"""
|
||||
chunks = [
|
||||
"Wait",
|
||||
"",
|
||||
|
||||
@@ -173,7 +173,8 @@ class TestExtractToolCalls:
|
||||
|
||||
def test_string_attr_true_coerced_by_schema(self):
|
||||
"""string="true" delivers a string, but the engine's schema-aware
|
||||
type fixer coerces it to the schema type (integer)."""
|
||||
type fixer coerces it to the schema type (integer).
|
||||
"""
|
||||
tool = ChatCompletionToolsParam(
|
||||
function=FunctionDefinition(
|
||||
name="score",
|
||||
@@ -287,7 +288,8 @@ class TestExtractToolCalls:
|
||||
|
||||
def test_string_attr_true_coerced_by_composed_schema(self):
|
||||
"""string="true" delivers a JSON string, but the engine's schema-aware
|
||||
type fixer coerces it to the composed schema type (object)."""
|
||||
type fixer coerces it to the composed schema type (object).
|
||||
"""
|
||||
tool = ChatCompletionToolsParam(
|
||||
function=FunctionDefinition(
|
||||
name="set_timer",
|
||||
@@ -321,7 +323,8 @@ class TestExtractToolCalls:
|
||||
|
||||
def test_arguments_wrapper_repaired(self):
|
||||
"""A single 'arguments' wrapper parameter must be unwrapped when it
|
||||
is not part of the tool schema and the inner object matches schema fields."""
|
||||
is not part of the tool schema and the inner object matches schema fields.
|
||||
"""
|
||||
tool = ChatCompletionToolsParam(
|
||||
function=FunctionDefinition(
|
||||
name="get_weather",
|
||||
@@ -492,7 +495,8 @@ class TestExtractToolCalls:
|
||||
|
||||
def test_null_coerced_back_to_string_by_schema(self):
|
||||
"""string="false" with 'null' is json-parsed to None, but the
|
||||
engine's schema fixer coerces it back to "null" for string schemas."""
|
||||
engine's schema fixer coerces it back to "null" for string schemas.
|
||||
"""
|
||||
tool = ChatCompletionToolsParam(
|
||||
function=FunctionDefinition(
|
||||
name="echo",
|
||||
@@ -655,7 +659,8 @@ class TestExtractToolCallsStreaming:
|
||||
|
||||
def test_string_attr_true_coerced_by_schema_streaming(self):
|
||||
"""Streaming: string='true' delivers a string but the engine's
|
||||
schema fixer coerces it to the schema type (integer)."""
|
||||
schema fixer coerces it to the schema type (integer).
|
||||
"""
|
||||
tool = ChatCompletionToolsParam(
|
||||
function=FunctionDefinition(
|
||||
name="score",
|
||||
@@ -971,7 +976,8 @@ class TestExtractToolCallsStreaming:
|
||||
|
||||
def test_no_marker_leak_chunked(self, parser):
|
||||
"""Chunked streaming must NOT leak DSML start-marker fragments
|
||||
as content (GitHub #40801)."""
|
||||
as content (GitHub #40801).
|
||||
"""
|
||||
full_text = build_tool_call("fn", {"k": "v"})
|
||||
deltas = self._stream_chunked(parser, full_text, chunk_size=5)
|
||||
content = "".join(d.content for d in deltas if d.content is not None)
|
||||
@@ -981,7 +987,8 @@ class TestExtractToolCallsStreaming:
|
||||
|
||||
def test_no_marker_leak_with_prefix_chunked(self, parser):
|
||||
"""Content before a tool call must not include start-marker
|
||||
fragments when chunked (GitHub #40801)."""
|
||||
fragments when chunked (GitHub #40801).
|
||||
"""
|
||||
full_text = "Hello!" + build_tool_call("fn", {"a": "b"})
|
||||
deltas = self._stream_chunked(parser, full_text, chunk_size=5)
|
||||
content = "".join(d.content for d in deltas if d.content is not None)
|
||||
@@ -993,7 +1000,8 @@ class TestExtractToolCallsStreaming:
|
||||
|
||||
def test_no_marker_leak_char_by_char(self, parser):
|
||||
"""Character-by-character streaming must not leak marker
|
||||
fragments (GitHub #40801)."""
|
||||
fragments (GitHub #40801).
|
||||
"""
|
||||
full_text = build_tool_call("fn", {"k": "v"})
|
||||
deltas = self._stream_chunked(parser, full_text, chunk_size=1)
|
||||
content = "".join(d.content for d in deltas if d.content is not None)
|
||||
@@ -1003,7 +1011,8 @@ class TestExtractToolCallsStreaming:
|
||||
|
||||
def test_no_marker_leak_all_split_points(self, parser):
|
||||
"""Start token split at every possible boundary must not
|
||||
leak (GitHub #40801)."""
|
||||
leak (GitHub #40801).
|
||||
"""
|
||||
for chunk_size in range(1, len(FC_START) + 2):
|
||||
p = make_parser()
|
||||
full_text = build_tool_call("fn", {"k": "v"})
|
||||
@@ -1015,7 +1024,8 @@ class TestExtractToolCallsStreaming:
|
||||
|
||||
def test_false_partial_marker_emitted(self, parser):
|
||||
"""Text ending with a prefix of the start token that turns out
|
||||
NOT to be a marker must still be emitted as content."""
|
||||
NOT to be a marker must still be emitted as content.
|
||||
"""
|
||||
full_text = "<|DSM some regular text"
|
||||
deltas = self._stream_chunked(parser, full_text, chunk_size=3)
|
||||
content = "".join(d.content for d in deltas if d.content is not None)
|
||||
|
||||
@@ -124,7 +124,8 @@ def mock_request():
|
||||
|
||||
class TestParseGemma4Args:
|
||||
"""Values are returned as strings; type coercion to proper JSON types
|
||||
happens at the engine layer."""
|
||||
happens at the engine layer.
|
||||
"""
|
||||
|
||||
def test_empty_string(self):
|
||||
assert _parse_gemma4_args("") == {}
|
||||
|
||||
@@ -18,7 +18,8 @@ from vllm.tool_parsers import ToolParser, ToolParserManager
|
||||
@pytest.fixture(scope="function")
|
||||
def default_tokenizer() -> TokenizerLike:
|
||||
"""Override module-scoped default_tokenizer because gigachat tests
|
||||
mutate the tokenizer via ``add_tokens``."""
|
||||
mutate the tokenizer via ``add_tokens``.
|
||||
"""
|
||||
return AutoTokenizer.from_pretrained("openai-community/gpt2")
|
||||
|
||||
|
||||
@@ -333,9 +334,7 @@ def test_streaming_tool_call_with_large_steps(
|
||||
model_output_deltas: list[str],
|
||||
gigachat_tokenizer: TokenizerLike,
|
||||
):
|
||||
"""
|
||||
Test that the closing braces are streamed correctly.
|
||||
"""
|
||||
"""Test that the closing braces are streamed correctly."""
|
||||
tool_parser: ToolParser = ToolParserManager.get_tool_parser("gigachat3")(
|
||||
gigachat_tokenizer
|
||||
)
|
||||
|
||||
@@ -18,7 +18,6 @@ class TestInternLM2ToolParser(ToolParserTests):
|
||||
@pytest.fixture
|
||||
def tokenizer(self, default_tokenizer: TokenizerLike) -> TokenizerLike:
|
||||
"""Add some internlm2 specific tokens to the default vocab."""
|
||||
|
||||
tokenizer_vocab = default_tokenizer.get_vocab()
|
||||
default_tokenizer.get_vocab = MagicMock()
|
||||
tokenizer_vocab.update(
|
||||
|
||||
@@ -218,6 +218,7 @@ def _split_tool_output_to_deltas(
|
||||
Args:
|
||||
content: text before tool section
|
||||
tool_strs: list of (tool_id, args_json)
|
||||
|
||||
"""
|
||||
deltas = [content, SECTION_BEGIN]
|
||||
for tool_id, args_json in tool_strs:
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||
"""Named tool choice for Kimi K3: allowed when the XTML structural tag is
|
||||
attached (strict tool calling), rejected otherwise."""
|
||||
attached (strict tool calling), rejected otherwise.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@@ -416,7 +416,8 @@ def test_tool_call(
|
||||
def test_empty_tool_call_block(body: str, lfm2_tokenizer: TokenizerLike):
|
||||
"""An empty block ([] or [ ]) means the model called no tools; it must
|
||||
not report tools_called=True with zero tool calls (the invariant
|
||||
run_tool_extraction asserts)."""
|
||||
run_tool_extraction asserts).
|
||||
"""
|
||||
cls = ToolParserManager.get_tool_parser("lfm2")
|
||||
model_output = f"{TOOL_CALL_START}[{body}]{TOOL_CALL_END}"
|
||||
|
||||
@@ -436,7 +437,8 @@ def test_whitespace_after_start_token(lfm2_tokenizer: TokenizerLike):
|
||||
not break parsing. The streaming path used to feed the indented text to
|
||||
ast.parse verbatim, so every completion candidate raised
|
||||
IndentationError and the call was silently dropped (non-streaming
|
||||
stripped it and succeeded)."""
|
||||
stripped it and succeeded).
|
||||
"""
|
||||
cls = ToolParserManager.get_tool_parser("lfm2")
|
||||
model_output = f"{TOOL_CALL_START} [{SIMPLE_FUNCTION_OUTPUT}]{TOOL_CALL_END}"
|
||||
|
||||
@@ -476,7 +478,8 @@ def test_streaming_full_block_and_trailing_in_single_delta(
|
||||
):
|
||||
"""The entire <|tool_call_start|>[...]<|tool_call_end|> block plus
|
||||
trailing assistant text arrive in one delta. Trailing content must
|
||||
still be emitted — not silently dropped."""
|
||||
still be emitted — not silently dropped.
|
||||
"""
|
||||
tool_parser: ToolParser = ToolParserManager.get_tool_parser("lfm2")(lfm2_tokenizer)
|
||||
full_text = f"{TOOL_CALL_START}[{SIMPLE_FUNCTION_OUTPUT}]{TOOL_CALL_END}\nDone."
|
||||
|
||||
@@ -491,7 +494,8 @@ def test_streaming_leading_content_and_full_block_in_single_delta(
|
||||
lfm2_tokenizer: TokenizerLike,
|
||||
):
|
||||
"""Leading assistant text plus the entire tool block arrive in one
|
||||
delta. Leading content must be emitted — not silently dropped."""
|
||||
delta. Leading content must be emitted — not silently dropped.
|
||||
"""
|
||||
tool_parser: ToolParser = ToolParserManager.get_tool_parser("lfm2")(lfm2_tokenizer)
|
||||
full_text = (
|
||||
f"Let me check. {TOOL_CALL_START}[{SIMPLE_FUNCTION_OUTPUT}]{TOOL_CALL_END}"
|
||||
@@ -508,7 +512,8 @@ def test_streaming_leading_block_and_trailing_in_single_delta(
|
||||
lfm2_tokenizer: TokenizerLike,
|
||||
):
|
||||
"""Leading text + complete tool block + trailing text in one delta.
|
||||
Both leading and trailing content must be preserved."""
|
||||
Both leading and trailing content must be preserved.
|
||||
"""
|
||||
tool_parser: ToolParser = ToolParserManager.get_tool_parser("lfm2")(lfm2_tokenizer)
|
||||
full_text = (
|
||||
"Let me check. "
|
||||
@@ -529,7 +534,8 @@ def test_echoed_tool_call_body_not_leaked_to_content(
|
||||
"""LFM2 sometimes emits the tool call body again after the first
|
||||
<|tool_call_end|>, capped with a second <|tool_call_end|>. The
|
||||
echoed body must not surface as assistant content — neither in
|
||||
streaming nor non-streaming paths."""
|
||||
streaming nor non-streaming paths.
|
||||
"""
|
||||
tool_parser: ToolParser = ToolParserManager.get_tool_parser("lfm2")(lfm2_tokenizer)
|
||||
body = (
|
||||
"[grocery.orderIngredients("
|
||||
@@ -564,7 +570,8 @@ def test_streaming_char_by_char_multi_dict_list(lfm2_tokenizer: TokenizerLike):
|
||||
character at a time. Every prefix lands in some partial-parse state
|
||||
(mid-key, mid-value, open quote inside dict, empty dict, etc.). The
|
||||
parser must not raise — incomplete prefixes should silently wait for
|
||||
more text instead of logging exceptions."""
|
||||
more text instead of logging exceptions.
|
||||
"""
|
||||
tool_parser: ToolParser = ToolParserManager.get_tool_parser("lfm2")(lfm2_tokenizer)
|
||||
full_text = (
|
||||
f"{TOOL_CALL_START}[grocery.orderIngredients("
|
||||
@@ -595,7 +602,8 @@ def test_streaming_char_by_char_multi_dict_list(lfm2_tokenizer: TokenizerLike):
|
||||
def test_streaming_dotted_name_in_single_delta(lfm2_tokenizer: TokenizerLike):
|
||||
"""A pythonic call with a dotted/attribute function name (e.g.
|
||||
``domain.method(arg=...)``) must be parsed correctly in streaming mode
|
||||
just as in non-streaming mode."""
|
||||
just as in non-streaming mode.
|
||||
"""
|
||||
tool_parser: ToolParser = ToolParserManager.get_tool_parser("lfm2")(lfm2_tokenizer)
|
||||
full_text = f"{TOOL_CALL_START}[{DOTTED_NAME_FUNCTION_OUTPUT}]{TOOL_CALL_END}"
|
||||
|
||||
@@ -611,7 +619,8 @@ def test_adjust_request_disables_skip_special_tokens(
|
||||
"""When tools are present, the parser must force
|
||||
``skip_special_tokens=False`` so the engine does not strip the
|
||||
<|tool_call_start|>/<|tool_call_end|> sentinels before they reach the
|
||||
parser."""
|
||||
parser.
|
||||
"""
|
||||
from vllm.entrypoints.openai.chat_completion.protocol import (
|
||||
ChatCompletionRequest,
|
||||
)
|
||||
|
||||
@@ -252,7 +252,7 @@ def test_extract_tool_calls_missing_parameters_and_arguments_key(parser):
|
||||
|
||||
|
||||
def test_regex_timeout_handling(parser):
|
||||
"""Test regex timeout is handled gracefully"""
|
||||
"""Test regex timeout is handled gracefully."""
|
||||
fake_problematic_input = "{hello world[A(A=" + "\t)A(A=,\t" * 2
|
||||
|
||||
# create a mock regex that raises TimeoutError
|
||||
|
||||
@@ -247,7 +247,7 @@ def test_streaming_tool_call_with_large_steps(default_tokenizer: TokenizerLike):
|
||||
|
||||
@pytest.mark.parametrize("streaming", [False])
|
||||
def test_regex_timeout_handling(streaming: bool, default_tokenizer: TokenizerLike):
|
||||
"""test regex timeout is handled gracefully"""
|
||||
"""Test regex timeout is handled gracefully."""
|
||||
tool_parser: ToolParser = ToolParserManager.get_tool_parser("llama4_pythonic")(
|
||||
default_tokenizer
|
||||
)
|
||||
|
||||
@@ -229,7 +229,7 @@ def test_streaming_tool_call_with_large_steps(default_tokenizer: TokenizerLike):
|
||||
|
||||
@pytest.mark.parametrize("streaming", [False])
|
||||
def test_regex_timeout_handling(streaming: bool, default_tokenizer: TokenizerLike):
|
||||
"""test regex timeout is handled gracefully"""
|
||||
"""Test regex timeout is handled gracefully."""
|
||||
tool_parser: ToolParser = ToolParserManager.get_tool_parser("olmo3")(
|
||||
default_tokenizer
|
||||
)
|
||||
|
||||
@@ -16,7 +16,6 @@ class TestPhi4MiniToolParser(ToolParserTests):
|
||||
@pytest.fixture
|
||||
def tokenizer(self, default_tokenizer: TokenizerLike) -> TokenizerLike:
|
||||
"""Add some phi4mini specific tokens to the default vocab."""
|
||||
|
||||
tokenizer = default_tokenizer
|
||||
tokenizer_vocab = tokenizer.get_vocab()
|
||||
tokenizer.get_vocab = MagicMock()
|
||||
|
||||
@@ -209,7 +209,7 @@ def test_streaming_tool_call_with_large_steps(default_tokenizer: TokenizerLike):
|
||||
|
||||
@pytest.mark.parametrize("streaming", [False])
|
||||
def test_regex_timeout_handling(streaming: bool, default_tokenizer: TokenizerLike):
|
||||
"""test regex timeout is handled gracefully"""
|
||||
"""Test regex timeout is handled gracefully."""
|
||||
tool_parser: ToolParser = ToolParserManager.get_tool_parser("pythonic")(
|
||||
default_tokenizer
|
||||
)
|
||||
|
||||
@@ -423,7 +423,7 @@ def test_extract_tool_calls(
|
||||
def test_extract_tool_calls_fallback_no_tags(
|
||||
qwen3_tool_parser,
|
||||
):
|
||||
"""Test fallback parsing when XML tags are missing"""
|
||||
"""Test fallback parsing when XML tags are missing."""
|
||||
model_output = """<function=get_current_weather>
|
||||
<parameter=city>
|
||||
Dallas
|
||||
@@ -444,7 +444,7 @@ TX
|
||||
|
||||
|
||||
def test_extract_tool_calls_type_conversion(qwen3_tokenizer):
|
||||
"""Test parameter type conversion based on tool schema"""
|
||||
"""Test parameter type conversion based on tool schema."""
|
||||
tools = [
|
||||
ChatCompletionToolsParam(
|
||||
type="function",
|
||||
@@ -862,7 +862,7 @@ def test_extract_tool_calls_streaming(
|
||||
expected_tool_calls,
|
||||
expected_content,
|
||||
):
|
||||
"""Test incremental streaming behavior including typed parameters"""
|
||||
"""Test incremental streaming behavior including typed parameters."""
|
||||
request = ChatCompletionRequest(model=MODEL, messages=[])
|
||||
|
||||
other_content = ""
|
||||
@@ -932,7 +932,7 @@ def test_extract_tool_calls_streaming(
|
||||
def test_extract_tool_calls_missing_closing_parameter_tag(
|
||||
qwen3_tool_parser,
|
||||
):
|
||||
"""Test handling of missing closing </parameter> tag"""
|
||||
"""Test handling of missing closing </parameter> tag."""
|
||||
# Using get_current_weather from sample_tools but with malformed XML
|
||||
model_output = """Let me check the weather for you:
|
||||
<tool_call>
|
||||
@@ -974,7 +974,7 @@ fahrenheit
|
||||
def test_extract_tool_calls_streaming_missing_closing_tag(
|
||||
qwen3_tool_parser, qwen3_tokenizer
|
||||
):
|
||||
"""Test streaming with missing closing </parameter> tag"""
|
||||
"""Test streaming with missing closing </parameter> tag."""
|
||||
# Using get_current_weather from sample_tools but with malformed XML
|
||||
model_output = """Let me check the weather for you:
|
||||
<tool_call>
|
||||
@@ -1046,7 +1046,7 @@ fahrenheit
|
||||
|
||||
|
||||
def test_extract_tool_calls_streaming_incremental(qwen3_tool_parser, qwen3_tokenizer):
|
||||
"""Test that streaming is truly incremental"""
|
||||
"""Test that streaming is truly incremental."""
|
||||
model_output = """I'll check the weather.<tool_call>
|
||||
<function=get_current_weather>
|
||||
<parameter=city>
|
||||
@@ -1106,7 +1106,7 @@ TX
|
||||
def test_extract_tool_calls_streaming_missing_opening_tag(
|
||||
qwen3_tool_parser, qwen3_tokenizer
|
||||
):
|
||||
"""Test streaming with missing opening <tool_call> tag
|
||||
"""Test streaming with missing opening <tool_call> tag.
|
||||
|
||||
This tests that the streaming parser correctly handles
|
||||
tool calls that start directly with <function=...>
|
||||
|
||||
@@ -366,7 +366,7 @@ def test_extract_tool_calls(
|
||||
|
||||
|
||||
def test_extract_tool_calls_fallback_no_tags(step3p5_tool_parser, sample_tools):
|
||||
"""Test fallback parsing when XML tags are missing"""
|
||||
"""Test fallback parsing when XML tags are missing."""
|
||||
model_output = """<function=get_current_weather>
|
||||
<parameter=city>
|
||||
Dallas
|
||||
@@ -387,7 +387,7 @@ TX
|
||||
|
||||
|
||||
def test_extract_tool_calls_type_conversion(step3p5_tokenizer):
|
||||
"""Test parameter type conversion based on tool schema"""
|
||||
"""Test parameter type conversion based on tool schema."""
|
||||
tools = [
|
||||
ChatCompletionToolsParam(
|
||||
type="function",
|
||||
@@ -622,7 +622,7 @@ def test_extract_tool_calls_streaming(
|
||||
expected_tool_calls,
|
||||
expected_content,
|
||||
):
|
||||
"""Test incremental streaming behavior including typed parameters"""
|
||||
"""Test incremental streaming behavior including typed parameters."""
|
||||
request = ChatCompletionRequest(model=MODEL, messages=[], tools=sample_tools)
|
||||
|
||||
other_content = ""
|
||||
@@ -692,7 +692,7 @@ def test_extract_tool_calls_streaming(
|
||||
def test_extract_tool_calls_missing_closing_parameter_tag(
|
||||
step3p5_tool_parser, sample_tools
|
||||
):
|
||||
"""Test handling of missing closing </parameter> tag"""
|
||||
"""Test handling of missing closing </parameter> tag."""
|
||||
# Using get_current_weather from sample_tools but with malformed XML
|
||||
model_output = """Let me check the weather for you:
|
||||
<tool_call>
|
||||
@@ -734,7 +734,7 @@ fahrenheit
|
||||
def test_extract_tool_calls_streaming_missing_closing_tag(
|
||||
step3p5_tool_parser, step3p5_tokenizer, sample_tools
|
||||
):
|
||||
"""Test streaming with missing closing </parameter> tag"""
|
||||
"""Test streaming with missing closing </parameter> tag."""
|
||||
# Using get_current_weather from sample_tools but with malformed XML
|
||||
model_output = """Let me check the weather for you:
|
||||
<tool_call>
|
||||
@@ -808,7 +808,7 @@ fahrenheit
|
||||
def test_extract_tool_calls_streaming_incremental(
|
||||
step3p5_tool_parser, step3p5_tokenizer, sample_tools
|
||||
):
|
||||
"""Test that streaming is truly incremental"""
|
||||
"""Test that streaming is truly incremental."""
|
||||
model_output = """I'll check the weather.<tool_call>
|
||||
<function=get_current_weather>
|
||||
<parameter=city>
|
||||
@@ -864,7 +864,7 @@ TX
|
||||
|
||||
|
||||
def test_extract_tool_calls_complex_type_with_single_quote(step3p5_tokenizer):
|
||||
"""Test parameter type conversion based on tool schema"""
|
||||
"""Test parameter type conversion based on tool schema."""
|
||||
tools = [
|
||||
ChatCompletionToolsParam(
|
||||
type="function",
|
||||
|
||||
Reference in New Issue
Block a user