vllm.tool_parsers
¶
Modules:
-
abstract_tool_parser– -
apertus_tool_parser–Tool call parser for Apertus models.
-
beam_tool_parser– -
dots_tool_parser– -
ernie45_tool_parser– -
functiongemma_tool_parser– -
gemma4_engine_tool_parser– -
gemma4_utils–Gemma4 tool call parsing utilities for offline inference.
-
gptoss_tool_parser– -
granite_20b_fc_tool_parser– -
hermes_tool_parser– -
hunyuan_a13b_tool_parser– -
hy_v3_tool_parser– -
hy_v4_tool_parser– -
k2_horizon_tool_parser– -
kimi_k3_tool_parser–Tool-call parser for the Kimi K3 (XTML) chat format.
-
lfm2_tool_parser– -
llama4_pythonic_tool_parser– -
minicpm5xml_tool_parser– -
mistral_tool_parser– -
muse_glimmer_tool_parser–Compatibility entry point for the Muse Glimmer tool parser.
-
muse_tool_parser–ATEM tool-call parser for Muse (Muse Spark and Muse Glimmer).
-
olmo3_tool_parser– -
phi4mini_tool_parser– -
poolside_v1_tool_parser–GLM-4 Tool Call Parser with incremental string streaming support.
-
pythonic_tool_parser– -
response_template_tool_parser– -
schema_types–JSON types admitted by tool parameter schemas.
-
step3_tool_parser– -
step5_tool_parser– -
streaming– -
structural_tag_registry– -
tool_strict_level– -
utils– -
xlam_tool_parser–
Classes:
-
ToolParser–Abstract ToolParser class that should not be used directly. Provided
-
ToolParserManager–Central registry for ToolParser implementations.
__all__ = ['ToolParser', 'ToolParserManager']
module-attribute
¶
Register a lazy module mapping.
Example
ToolParserManager.register_lazy_module( name="kimi_k2", module_path="vllm.tool_parsers.kimi_k2_tool_parser", class_name="KimiK2ToolParser", )
ToolParser
¶
Abstract ToolParser class that should not be used directly. Provided properties and methods should be used in derived classes.
Methods:
-
extract_tool_calls–Static method that should be implemented for extracting tool calls from
-
extract_tool_calls_streaming–Instance method that should be implemented for extracting tool calls
-
get_remaining_unstreamed_args–Return tool call arguments parsed but not yet streamed.
extract_tool_calls(model_output, request)
¶
Static method that should be implemented for extracting tool calls from a complete model-generated string. Used for non-streaming responses where we have the entire model response available before sending to the client. Static because it's stateless.
extract_tool_calls_streaming(previous_text, current_text, delta_text, previous_token_ids, current_token_ids, delta_token_ids, request)
¶
Instance method that should be implemented for extracting tool calls from an incomplete response; for use when handling tool calls and streaming. Has to be an instance method because it requires state - the current tokens/diffs, but also the information about what has previously been parsed and extracted (see constructor)
get_remaining_unstreamed_args()
¶
Return tool call arguments parsed but not yet streamed.
ToolParserManager
¶
Central registry for ToolParser implementations.
Supports two modes
- Eager (immediate) registration via
register_module - Lazy registration via
register_lazy_module
Methods:
-
get_tool_parser–Retrieve a registered or lazily registered ToolParser class.
-
import_tool_parser–Import a user-defined tool parser.
-
list_registered–Return names of all eagerly and lazily registered tool parsers.
-
register_lazy_module–Register a lazy module mapping.
-
register_module–Register module immediately or lazily (as a decorator).
_load_lazy_parser(name)
classmethod
¶
Import and register a lazily loaded parser.
_register_module(module, module_name=None, force=True)
classmethod
¶
Register a ToolParser class immediately.
get_tool_parser(name)
classmethod
¶
Retrieve a registered or lazily registered ToolParser class.
If the parser is lazily registered, it will be imported and cached on first access. Raises KeyError if not found.
import_tool_parser(plugin_path)
classmethod
¶
Import a user-defined tool parser.
list_registered()
classmethod
¶
Return names of all eagerly and lazily registered tool parsers.
register_lazy_module(name, module_path, class_name)
classmethod
¶
Register a lazy module mapping.
Example
ToolParserManager.register_lazy_module( name="kimi_k2", module_path="vllm.tool_parsers.kimi_k2_parser", class_name="KimiK2ToolParser", )
register_module(name=None, force=True, module=None)
classmethod
¶
Register module immediately or lazily (as a decorator).
Usage
@ToolParserManager.register_module("kimi_k2") class KimiK2ToolParser(ToolParser): ...
Or
ToolParserManager.register_module(module=SomeToolParser)