vllm.parser.response_template
¶
Unified vLLM parser backed by checkpoint response_template metadata.
Classes:
-
ResponseTemplateParser–Parse reasoning, content, and tool calls with one response template.
-
ResponseTemplateReasoningParser–Reasoning end detection for a response-template parser.
-
ResponseTemplateToolParser–Selects a response-template parser as the tool parser;
Functions:
-
resolve_response_template–Return
templateif given, otherwise the tokenizer's metadata. -
response_template_parser_cls–The response-template parser that a registered reasoning or tool parser
-
validate_response_template_for_serving–Validate the template and reject semantic fields serving cannot route.
-
validate_tokenizer_response_template–Fail at startup if the tokenizer cannot serve the selected parsers,
ResponseTemplateParser
¶
Bases: Parser
Parse reasoning, content, and tool calls with one response template.
Methods:
-
count_reasoning_tokens–Count the generated tokens whose text the template parses as
ResponseTemplateReasoningParser
¶
Bases: ReasoningParser
Reasoning end detection for a response-template parser.
ResponseTemplateParser parses the output; this parser tells it and the
structured-output engine where reasoning ends.
Methods:
-
unified_parser_cls–The unified parser that selecting this reasoning parser stands for.
unified_parser_cls()
classmethod
¶
The unified parser that selecting this reasoning parser stands for.
ResponseTemplateToolParser
¶
Bases: ToolParser
Selects a response-template parser as the tool parser;
ResponseTemplateParser extracts the tool calls.
Methods:
-
unified_parser_cls–The unified parser that selecting this tool parser stands for.
unified_parser_cls()
classmethod
¶
The unified parser that selecting this tool parser stands for.
_DeltaBuilder
¶
Accumulates one DeltaMessage.
_ReasoningTokenCounter
¶
Counts the reasoning tokens of one growing generation, parsing each token once.
_ResponseStream
¶
One generation fed through ResponseParser, routed to message deltas.
_closer_rest()
¶
The rest of a closer the output stopped in after ending its region, when only the next message's start anchor is missing.
_route_tool_event(event, delta)
¶
Emit the calls of a tool region once it ends and parses; a region cut off at the end of the stream is parsed as generated. With tool parsing disabled, the region passes through as content.
_track(events)
¶
Follow the open region, and add a text field's join separator as a
chunk before each occurrence that follows a closed one.
_as_tool_dicts(tools)
¶
Responses function tools with flattened namespaces, plus chat tools.
_ends_within(token_ids, end_ids, num_new)
¶
Whether end_ids completes within the last num_new of token_ids.
_literal_ids(tokenizer, vocab, literals)
¶
Token ids of each literal, or None when one encodes to nothing.
_reasoning_end_ids(tokenizer, vocab, template)
¶
Token ids of each thinking closer, or None when they are not all
literal.
_serving_template(tokenizer, template)
¶
The validated streaming form of template or the tokenizer's metadata.
_to_tool_calls(value)
¶
(name, arguments) of each call in a tool region value, or nothing if
any call is incomplete.
_unsupported_tool_guarantee(request)
¶
The first requested tool guarantee this parser cannot enforce, with the request parameter that asked for it.
resolve_response_template(tokenizer, template=None)
¶
Return template if given, otherwise the tokenizer's metadata.
response_template_parser_cls(split_parser_cls)
¶
The response-template parser that a registered reasoning or tool parser
stands for, or None for any other parser.
validate_response_template_for_serving(template)
¶
Validate the template and reject semantic fields serving cannot route.
validate_tokenizer_response_template(tokenizer, *, reasoning_parser, tool_parser)
¶
Fail at startup if the tokenizer cannot serve the selected parsers, named as given on the command line.