Skip to content

Commit 866c589

Browse files
committed
qa
1 parent b43a3eb commit 866c589

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

vllm/entrypoints/openai/tool_parsers/apertus_tool_parser.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,8 @@ def _extract_json_str(self, current_text: str) -> str:
219219
Extract JSON string from the current text between tool call delimiters.
220220
221221
Extracts the content between <|tools_prefix|> and <|tools_suffix|> tokens.
222-
If the suffix is not present (incomplete streaming), returns everything after the prefix.
222+
If the suffix is not present (incomplete streaming),
223+
returns everything after the prefix.
223224
224225
Args:
225226
current_text: The accumulated model output text.
@@ -228,7 +229,8 @@ def _extract_json_str(self, current_text: str) -> str:
228229
The extracted JSON string without the delimiter tokens.
229230
230231
Example:
231-
>>> current_text = 'Some text <|tools_prefix|>[{"func": {"arg": "val"}}]<|tools_suffix|>'
232+
>>> current_text = 'Some text <|tools_prefix|>
233+
[{"func": {"arg": "val"}}]<|tools_suffix|>'
232234
>>> self._extract_json_str(current_text)
233235
'[{"func": {"arg": "val"}}]'
234236
@@ -282,10 +284,13 @@ def _parse_partial_json(self, json_str: str) -> list[dict]:
282284

283285
def _finalize_previous_tool(self) -> DeltaMessage | None:
284286
"""
285-
Finalize any remaining arguments from the previous tool before moving to the next one.
287+
Finalize any remaining arguments
288+
from the previous tool before moving to the next one.
286289
287-
When transitioning to a new tool in the array, this ensures all arguments
288-
from the current tool that haven't been streamed yet are sent in one final delta.
290+
When transitioning to a new tool in the array,
291+
this ensures all arguments
292+
from the current tool that haven't been
293+
streamed yet are sent in one final delta.
289294
290295
This is necessary because when a new tool appears, we may have parsed additional
291296
arguments for the previous tool that weren't yet sent to the client.
@@ -385,7 +390,8 @@ def _stream_arguments(
385390
as they become available. Tracks what has already been sent and only streams
386391
the difference.
387392
388-
The tool call format is expected to be: {"function_name": {"arg1": "val1", ...}}
393+
The tool call format is expected to be:
394+
{"function_name": {"arg1": "val1", ...}}
389395
390396
Args:
391397
current_tool_call: A dictionary with a single key (function name) and
@@ -470,8 +476,10 @@ def _calculate_argument_diff(
470476
- Arguments haven't changed since last iteration
471477
472478
Example:
473-
Iteration 1: args_json = '{"x": 5' -> sent = 0 -> returns '{"x": 5'
474-
Iteration 2: args_json = '{"x": 5, "y": 10}' -> sent = 7 -> returns ', "y": 10}'
479+
Iteration 1: args_json =
480+
'{"x": 5' -> sent = 0 -> returns '{"x": 5'
481+
Iteration 2: args_json =
482+
'{"x": 5, "y": 10}' -> sent = 7 -> returns ', "y": 10}'
475483
"""
476484
is_complete_call = is_complete_json(json_str)
477485

0 commit comments

Comments
 (0)