vllm_mlx.reasoning¶
Reasoning parser module for vllm-mlx.
View the complete module source at #L1-L110.
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.reasoning
¶
Reasoning parser module for vllm-mlx.
This module provides parsers for extracting reasoning/thinking content from
model outputs. Supports models like Qwen3, DeepSeek-R1, etc. that use special
tokens (e.g.,
Usage
from vllm_mlx.reasoning import get_parser, list_parsers
Get a parser by name¶
parser = get_parser("qwen3")()
Extract reasoning from complete output¶
reasoning, content = parser.extract_reasoning(model_output)
For streaming¶
parser.reset_state() for delta in stream: msg = parser.extract_reasoning_streaming(prev, curr, delta) if msg: # msg.reasoning and/or msg.content will be populated ...
vllm_mlx.reasoning._REASONING_PARSERS
module-attribute
¶
_REASONING_PARSERS: dict[str, type[ReasoningParser]] = {}
vllm_mlx.reasoning.__all__
module-attribute
¶
__all__ = ['ReasoningParser', 'DeltaMessage', 'BaseThinkingReasoningParser', 'register_parser', 'get_parser', 'list_parsers']
vllm_mlx.reasoning.register_parser
¶
register_parser(name: str, parser_class: type[ReasoningParser]) -> None
Register a reasoning parser.
Parameters:
-
name(str) –Name to register the parser under (e.g., "qwen3").
-
parser_class(type[ReasoningParser]) –The parser class to register.
Source code in vllm_mlx/reasoning/__init__.py
vllm_mlx.reasoning.get_parser
¶
get_parser(name: str) -> type[ReasoningParser]
Get a reasoning parser class by name.
Parameters:
-
name(str) –Name of the parser (e.g., "qwen3", "deepseek_r1").
Returns:
-
type[ReasoningParser]–The parser class (not an instance).
Raises:
-
KeyError–If parser name is not found.
Source code in vllm_mlx/reasoning/__init__.py
vllm_mlx.reasoning.list_parsers
¶
List available parser names.
Returns:
-
list[str]–List of registered parser names.
vllm_mlx.reasoning._register_builtin_parsers
¶
Register built-in parsers.
Source code in vllm_mlx/reasoning/__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.reasoning.register_parser · function
Register a reasoning parser.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
name |
str |
yes |
none |
Name to register the parser under (e.g., "qwen3"). |
parser_class |
type[ReasoningParser] |
yes |
none |
The parser class to register. |
Returns
- Type:
None
Exceptions and behavior
Function register_parser contains no state mutation, call, raise, return, await, or yield.
No direct raise statement appears in this definition.
vllm_mlx.reasoning.get_parser · function
Get a reasoning parser class by name.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
name |
str |
yes |
none |
Name of the parser (e.g., "qwen3", "deepseek_r1"). |
Returns
- Type:
type[ReasoningParser] - Direct return expressions:
_REASONING_PARSERS[name]
Exceptions and behavior
Function get_parser calls list, _REASONING_PARSERS.keys, KeyError; can raise KeyError; returns _REASONING_PARSERS[name].
Directly raised exceptions: KeyError.
vllm_mlx.reasoning.list_parsers · function
List available parser names.
Parameters
This callable has no explicit inputs.
Returns
- Type:
list[str] - Direct return expressions:
list(_REASONING_PARSERS.keys())
Exceptions and behavior
Function list_parsers calls list, _REASONING_PARSERS.keys; returns list(_REASONING_PARSERS.keys()).
No direct raise statement appears in this definition.
vllm_mlx.reasoning._register_builtin_parsers · function
Register built-in parsers.
Parameters
This callable has no explicit inputs.
Returns
- Type:
not annotated
Exceptions and behavior
Function _register_builtin_parsers calls register_parser.
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 |
|---|---|---|---|---|
register_parser |
function | register_parser(name: str, parser_class: type[ReasoningParser]) -> None |
Register a reasoning parser. | #L34-L42 |
get_parser |
function | get_parser(name: str) -> type[ReasoningParser] |
Get a reasoning parser class by name. | #L45-L63 |
list_parsers |
function | list_parsers() -> list[str] |
List available parser names. | #L66-L73 |
_register_builtin_parsers |
function | _register_builtin_parsers() -> not annotated |
Register built-in parsers. | #L76-L94 |