vllm_mlx.tool_parsers¶
Tool call parsers for vllm-mlx.
View the complete module source at #L1-L116.
API details¶
Each callable below includes its exact signature, type annotations, inputs, defaults, return contract, documented exceptions, implementation source, and parsed docstring sections when the source provides them.
vllm_mlx.tool_parsers
¶
Tool call parsers for vllm-mlx.
This module provides tool call parsing functionality for various model formats. Inspired by vLLM's tool parser architecture but simplified for MLX backend.
Available parsers:
- auto: Auto-detecting parser that tries all formats (default)
- mistral: Mistral models ([TOOL_CALLS] format)
- qwen/qwen3: Qwen models (
Usage
from vllm_mlx.tool_parsers import ToolParserManager
Get a parser by name¶
parser_cls = ToolParserManager.get_tool_parser("mistral") parser = parser_cls(tokenizer)
Parse tool calls¶
result = parser.extract_tool_calls(model_output) if result.tools_called: for tc in result.tool_calls: print(f"Tool: {tc['name']}, Args: {tc['arguments']}")
List available parsers¶
print(ToolParserManager.list_registered())
vllm_mlx.tool_parsers.__all__
module-attribute
¶
__all__ = ['ToolParser', 'ToolParserManager', 'ExtractedToolCallInformation', 'get_parser_stop_tokens', 'AutoToolParser', 'Gemma4ToolParser', 'MistralToolParser', 'QwenToolParser', 'PoolsideV1ToolParser', 'Qwen3XMLToolParser', 'LlamaToolParser', 'HermesToolParser', 'DeepSeekToolParser', 'KimiToolParser', 'GraniteToolParser', 'NemotronToolParser', 'xLAMToolParser', 'FunctionaryToolParser', 'Glm47ToolParser', 'HarmonyToolParser', 'MiniMaxToolParser']
vllm_mlx.tool_parsers.get_parser_stop_tokens
¶
Merge user-supplied stops with parser-declared extras (deduped).
Some models declare end-of-generation tokens beyond the tokenizer's default
eos set — e.g. Gemma 4's <|tool_response> which signals the runtime's
turn after a tool call. Parsers expose those via extra_stop_tokens.
Source code in vllm_mlx/tool_parsers/__init__.py
Complete contract reference¶
Expand any definition for its exact inputs, annotations, defaults, return contract, directly raised exceptions, source-grounded behavior, and immutable line link. This section includes private and nested definitions that ordinary API generators omit.
vllm_mlx.tool_parsers.get_parser_stop_tokens · function
vllm_mlx.tool_parsers.get_parser_stop_tokens(parser_name: str | None, user_stops: list[str] | None) -> list[str]
Merge user-supplied stops with parser-declared extras (deduped).
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
parser_name |
str \| None |
yes |
none |
Required positional or keyword input. |
user_stops |
list[str] \| None |
yes |
none |
Required positional or keyword input. |
Returns
- Type:
list[str] - Direct return expressions:
stops
Exceptions and behavior
Function get_parser_stop_tokens calls list, ToolParserManager.get_tool_parser, getattr, stops.append; returns stops.
No direct raise statement appears in this definition.
Complete symbol map¶
This map also includes private definitions and nested helpers. The signature column exposes every explicit input even when an internal helper has no dedicated parameter prose.
| Symbol | Kind | Signature and inputs | What it does | Source |
|---|---|---|---|---|
get_parser_stop_tokens |
function | get_parser_stop_tokens(parser_name: str \| None, user_stops: list[str] \| None) -> list[str] |
Merge user-supplied stops with parser-declared extras (deduped). | #L68-L88 |