vllm.tool_parsers.hermes_tool_parser
¶
Classes:
Hermes2ProToolParser
¶
Bases: ToolParser
Methods:
-
extract_tool_calls_streaming–Incrementally stream tool call deltas from accumulated output.
_compute_args_diff(index, tc_json, is_complete)
¶
Return new argument text not yet sent for tool index, or None.
_extract_content(current_text)
¶
Return unsent non-tool-call text, or None.
Holds back any suffix that could be a partial
_extract_tool_args(tc_json, is_complete)
staticmethod
¶
Extract tool arguments from the tool call JSON.
Given {"name": "f", "arguments": {"x": 1}}, returns '{"x": 1}'. When is_complete, strips the trailing '}' that closes the outer object (not the arguments). For partial JSON, returns as-is.
_extract_tool_call_jsons(text)
¶
Extract (json_text, is_complete) for each
_extract_tool_name(tc_json)
staticmethod
¶
Extract tool name, or None if the name isn't complete yet.
extract_tool_calls_streaming(previous_text, current_text, delta_text, previous_token_ids, current_token_ids, delta_token_ids, request)
¶
Incrementally stream tool call deltas from accumulated output.
On each invocation, re-parses the full current_text to find
<tool_call> regions, then diffs against previously sent state
to emit only new content, tool names, or argument fragments.
Returns a DeltaMessage containing either plain content (for
text preceding any tool call) or one or more DeltaToolCall
entries, or None if there is nothing new to send yet.