Skip to content

vllm_mlx.tool_parsers.abstract_tool_parser

Abstract tool parser base class and manager for vllm-mlx.

View the complete module source at #L1-L286.

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.abstract_tool_parser

Abstract tool parser base class and manager for vllm-mlx.

Inspired by vLLM's tool parser architecture but simplified for MLX backend.

vllm_mlx.tool_parsers.abstract_tool_parser.THINK_TAG_PATTERN module-attribute

THINK_TAG_PATTERN = re.compile('<think>.*?</think>', re.DOTALL)

vllm_mlx.tool_parsers.abstract_tool_parser.IMPLICIT_THINK_PATTERN module-attribute

IMPLICIT_THINK_PATTERN = re.compile('^.*?</think>', re.DOTALL)

vllm_mlx.tool_parsers.abstract_tool_parser.ExtractedToolCallInformation dataclass

ExtractedToolCallInformation(tools_called: bool, tool_calls: list[dict[str, Any]], content: str | None = None)

Information extracted from model output about tool calls.

vllm_mlx.tool_parsers.abstract_tool_parser.ExtractedToolCallInformation.tools_called instance-attribute

tools_called: bool

Whether any tool calls were detected.

vllm_mlx.tool_parsers.abstract_tool_parser.ExtractedToolCallInformation.tool_calls instance-attribute

tool_calls: list[dict[str, Any]]

List of tool calls with 'name' and 'arguments' fields.

vllm_mlx.tool_parsers.abstract_tool_parser.ExtractedToolCallInformation.content class-attribute instance-attribute

content: str | None = None

Any content that wasn't part of tool calls.

vllm_mlx.tool_parsers.abstract_tool_parser.ToolParser

ToolParser(tokenizer: PreTrainedTokenizerBase | None = None)

Bases: ABC

Abstract base class for tool call parsers.

Each parser implementation handles a specific model's tool calling format.

Initialize the tool parser.

Parameters:

  • tokenizer (PreTrainedTokenizerBase | None, default: None ) –

    The tokenizer for the model (optional, some parsers need it)

Source code in vllm_mlx/tool_parsers/abstract_tool_parser.py
def __init__(self, tokenizer: PreTrainedTokenizerBase | None = None):
    """
    Initialize the tool parser.

    Args:
        tokenizer: The tokenizer for the model (optional, some parsers need it)
    """
    self.model_tokenizer = tokenizer
    # State for streaming parsing
    self.current_tool_id: int = -1
    self.prev_tool_call_arr: list[dict] = []

vllm_mlx.tool_parsers.abstract_tool_parser.ToolParser.SUPPORTS_NATIVE_TOOL_FORMAT class-attribute instance-attribute

SUPPORTS_NATIVE_TOOL_FORMAT: bool = False

vllm_mlx.tool_parsers.abstract_tool_parser.ToolParser.extra_stop_tokens class-attribute instance-attribute

extra_stop_tokens: list[str] = []

vllm_mlx.tool_parsers.abstract_tool_parser.ToolParser.model_tokenizer instance-attribute

model_tokenizer = tokenizer

vllm_mlx.tool_parsers.abstract_tool_parser.ToolParser.current_tool_id instance-attribute

current_tool_id: int = -1

vllm_mlx.tool_parsers.abstract_tool_parser.ToolParser.prev_tool_call_arr instance-attribute

prev_tool_call_arr: list[dict] = []

vllm_mlx.tool_parsers.abstract_tool_parser.ToolParser.vocab cached property

vocab: dict[str, int]

Get the tokenizer vocabulary.

vllm_mlx.tool_parsers.abstract_tool_parser.ToolParser.supports_native_format classmethod

supports_native_format() -> bool

Check if this parser supports native tool message format.

Native format means the parser's corresponding model chat template can handle: - role="tool" messages directly (not converted to role="user") - tool_calls field on assistant messages (not converted to text)

Returns:

  • bool

    True if native format is supported

Source code in vllm_mlx/tool_parsers/abstract_tool_parser.py
@classmethod
def supports_native_format(cls) -> bool:
    """
    Check if this parser supports native tool message format.

    Native format means the parser's corresponding model chat template
    can handle:
    - role="tool" messages directly (not converted to role="user")
    - tool_calls field on assistant messages (not converted to text)

    Returns:
        True if native format is supported
    """
    return cls.SUPPORTS_NATIVE_TOOL_FORMAT

vllm_mlx.tool_parsers.abstract_tool_parser.ToolParser.strip_think_tags staticmethod

strip_think_tags(text: str) -> str

Strip think tags from text.

Handles two scenarios: 1. Full tags: ... in output 2. Only closing tag: ... when was in prompt

Used as fallback when no reasoning parser is configured but the model produces thinking tags. This prevents tool parsing failures with models that use thinking tags (e.g., Ring-Mini-Linear-2.0 with hermes).

Parameters:

  • text (str) –

    Model output that may contain think tags

Returns:

  • str

    Text with think tags removed

Source code in vllm_mlx/tool_parsers/abstract_tool_parser.py
@staticmethod
def strip_think_tags(text: str) -> str:
    """
    Strip think tags from text.

    Handles two scenarios:
    1. Full tags: <think>...</think> in output
    2. Only closing tag: ...</think> when <think> was in prompt

    Used as fallback when no reasoning parser is configured but the model
    produces thinking tags. This prevents tool parsing failures with
    models that use thinking tags (e.g., Ring-Mini-Linear-2.0 with hermes).

    Args:
        text: Model output that may contain think tags

    Returns:
        Text with think tags removed
    """
    # First try to strip full tags
    result = THINK_TAG_PATTERN.sub("", text)

    # If no full tags found but </think> exists, strip implicit think
    # (when <think> was injected in the prompt)
    if result == text and "</think>" in text:
        result = IMPLICIT_THINK_PATTERN.sub("", text)

    return result.strip()

vllm_mlx.tool_parsers.abstract_tool_parser.ToolParser.extract_tool_calls abstractmethod

extract_tool_calls(model_output: str, request: dict[str, Any] | None = None) -> ExtractedToolCallInformation

Extract tool calls from a complete model response.

Parameters:

  • model_output (str) –

    The complete model output string

  • request (dict[str, Any] | None, default: None ) –

    Optional request context (for tool definitions, etc.)

Returns:

Source code in vllm_mlx/tool_parsers/abstract_tool_parser.py
@abstractmethod
def extract_tool_calls(
    self, model_output: str, request: dict[str, Any] | None = None
) -> ExtractedToolCallInformation:
    """
    Extract tool calls from a complete model response.

    Args:
        model_output: The complete model output string
        request: Optional request context (for tool definitions, etc.)

    Returns:
        ExtractedToolCallInformation with parsed tool calls
    """
    raise NotImplementedError

vllm_mlx.tool_parsers.abstract_tool_parser.ToolParser.extract_tool_calls_streaming

extract_tool_calls_streaming(previous_text: str, current_text: str, delta_text: str, previous_token_ids: Sequence[int] | None = None, current_token_ids: Sequence[int] | None = None, delta_token_ids: Sequence[int] | None = None, request: dict[str, Any] | None = None) -> dict[str, Any] | None

Extract tool calls from streaming model output.

Override this method for streaming support. Default implementation returns None (no streaming support).

Parameters:

  • previous_text (str) –

    Text before this delta

  • current_text (str) –

    Complete text so far

  • delta_text (str) –

    New text in this chunk

  • previous_token_ids (Sequence[int] | None, default: None ) –

    Token IDs before this delta

  • current_token_ids (Sequence[int] | None, default: None ) –

    All token IDs so far

  • delta_token_ids (Sequence[int] | None, default: None ) –

    New token IDs in this chunk

  • request (dict[str, Any] | None, default: None ) –

    Optional request context

Returns:

  • dict[str, Any] | None

    Delta message dict with content and/or tool_calls, or None

Source code in vllm_mlx/tool_parsers/abstract_tool_parser.py
def extract_tool_calls_streaming(
    self,
    previous_text: str,
    current_text: str,
    delta_text: str,
    previous_token_ids: Sequence[int] | None = None,
    current_token_ids: Sequence[int] | None = None,
    delta_token_ids: Sequence[int] | None = None,
    request: dict[str, Any] | None = None,
) -> dict[str, Any] | None:
    """
    Extract tool calls from streaming model output.

    Override this method for streaming support. Default implementation
    returns None (no streaming support).

    Args:
        previous_text: Text before this delta
        current_text: Complete text so far
        delta_text: New text in this chunk
        previous_token_ids: Token IDs before this delta
        current_token_ids: All token IDs so far
        delta_token_ids: New token IDs in this chunk
        request: Optional request context

    Returns:
        Delta message dict with content and/or tool_calls, or None
    """
    return None

vllm_mlx.tool_parsers.abstract_tool_parser.ToolParser.reset

reset() -> None

Reset parser state for a new request.

Source code in vllm_mlx/tool_parsers/abstract_tool_parser.py
def reset(self) -> None:
    """Reset parser state for a new request."""
    self.current_tool_id = -1
    self.prev_tool_call_arr = []

vllm_mlx.tool_parsers.abstract_tool_parser.ToolParserManager

Central registry for ToolParser implementations.

Supports both eager and lazy registration of tool parsers.

vllm_mlx.tool_parsers.abstract_tool_parser.ToolParserManager.tool_parsers class-attribute instance-attribute

tool_parsers: dict[str, type[ToolParser]] = {}

vllm_mlx.tool_parsers.abstract_tool_parser.ToolParserManager.lazy_parsers class-attribute instance-attribute

lazy_parsers: dict[str, tuple[str, str]] = {}

vllm_mlx.tool_parsers.abstract_tool_parser.ToolParserManager.get_tool_parser classmethod

get_tool_parser(name: str) -> type[ToolParser]

Retrieve a registered ToolParser class by name.

Parameters:

  • name (str) –

    Parser name (e.g., 'mistral', 'qwen', 'llama')

Returns:

Raises:

  • KeyError

    If parser not found

Source code in vllm_mlx/tool_parsers/abstract_tool_parser.py
@classmethod
def get_tool_parser(cls, name: str) -> type[ToolParser]:
    """
    Retrieve a registered ToolParser class by name.

    Args:
        name: Parser name (e.g., 'mistral', 'qwen', 'llama')

    Returns:
        The ToolParser class

    Raises:
        KeyError: If parser not found
    """
    if name in cls.tool_parsers:
        return cls.tool_parsers[name]

    if name in cls.lazy_parsers:
        return cls._load_lazy_parser(name)

    raise KeyError(
        f"Tool parser '{name}' not found. "
        f"Available parsers: {cls.list_registered()}"
    )

vllm_mlx.tool_parsers.abstract_tool_parser.ToolParserManager._load_lazy_parser classmethod

_load_lazy_parser(name: str) -> type[ToolParser]

Import and register a lazily loaded parser.

Source code in vllm_mlx/tool_parsers/abstract_tool_parser.py
@classmethod
def _load_lazy_parser(cls, name: str) -> type[ToolParser]:
    """Import and register a lazily loaded parser."""
    module_path, class_name = cls.lazy_parsers[name]
    try:
        mod = importlib.import_module(module_path)
        parser_cls = getattr(mod, class_name)
        if not issubclass(parser_cls, ToolParser):
            raise TypeError(
                f"{class_name} in {module_path} is not a ToolParser subclass."
            )
        cls.tool_parsers[name] = parser_cls
        return parser_cls
    except Exception as e:
        raise ImportError(
            f"Failed to import tool parser '{name}' from {module_path}: {e}"
        ) from e

vllm_mlx.tool_parsers.abstract_tool_parser.ToolParserManager.register_module classmethod

register_module(name: str | list[str], module: type[ToolParser] | None = None, force: bool = True) -> type[ToolParser] | None

Register a ToolParser class.

Can be used as a decorator or direct call.

Usage

@ToolParserManager.register_module("my_parser") class MyToolParser(ToolParser): ...

Or direct registration:

ToolParserManager.register_module("my_parser", MyToolParser)

Source code in vllm_mlx/tool_parsers/abstract_tool_parser.py
@classmethod
def register_module(
    cls,
    name: str | list[str],
    module: type[ToolParser] | None = None,
    force: bool = True,
) -> type[ToolParser] | None:
    """
    Register a ToolParser class.

    Can be used as a decorator or direct call.

    Usage:
        @ToolParserManager.register_module("my_parser")
        class MyToolParser(ToolParser):
            ...

        # Or direct registration:
        ToolParserManager.register_module("my_parser", MyToolParser)
    """
    names = [name] if isinstance(name, str) else name

    if module is not None:
        # Direct registration
        if not issubclass(module, ToolParser):
            raise TypeError(
                f"module must be subclass of ToolParser, got {type(module)}"
            )
        for n in names:
            if not force and n in cls.tool_parsers:
                raise KeyError(f"Parser '{n}' is already registered")
            cls.tool_parsers[n] = module
        return module

    # Decorator usage
    def decorator(parser_cls: type[ToolParser]) -> type[ToolParser]:
        for n in names:
            if not force and n in cls.tool_parsers:
                raise KeyError(f"Parser '{n}' is already registered")
            cls.tool_parsers[n] = parser_cls
        return parser_cls

    return decorator  # type: ignore

vllm_mlx.tool_parsers.abstract_tool_parser.ToolParserManager.register_lazy_module classmethod

register_lazy_module(name: str, module_path: str, class_name: str) -> None

Register a lazy module mapping for deferred loading.

Parameters:

  • name (str) –

    Parser name to register

  • module_path (str) –

    Full module path (e.g., 'vllm_mlx.tool_parsers.mistral')

  • class_name (str) –

    Class name within the module

Source code in vllm_mlx/tool_parsers/abstract_tool_parser.py
@classmethod
def register_lazy_module(cls, name: str, module_path: str, class_name: str) -> None:
    """
    Register a lazy module mapping for deferred loading.

    Args:
        name: Parser name to register
        module_path: Full module path (e.g., 'vllm_mlx.tool_parsers.mistral')
        class_name: Class name within the module
    """
    cls.lazy_parsers[name] = (module_path, class_name)

vllm_mlx.tool_parsers.abstract_tool_parser.ToolParserManager.list_registered classmethod

list_registered() -> list[str]

Return names of all registered tool parsers.

Source code in vllm_mlx/tool_parsers/abstract_tool_parser.py
@classmethod
def list_registered(cls) -> list[str]:
    """Return names of all registered tool parsers."""
    return sorted(set(cls.tool_parsers.keys()) | set(cls.lazy_parsers.keys()))

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.abstract_tool_parser.ExtractedToolCallInformation · class
vllm_mlx.tool_parsers.abstract_tool_parser.ExtractedToolCallInformation(tools_called: bool, tool_calls: list[dict[str, Any]], content: str | None = None)

Information extracted from model output about tool calls.

Parameters

Name Type Required Default Description
tools_called bool yes none Required constructor field.
tool_calls list[dict[str, Any]] yes none Required constructor field.
content str \| None no None Optional constructor field; defaults to None.

Returns

  • Constructs: vllm_mlx.tool_parsers.abstract_tool_parser.ExtractedToolCallInformation

Exceptions and behavior

Class ExtractedToolCallInformation declares 0 direct member(s). No direct raise statement appears in this definition.

View source #L27-L37.

vllm_mlx.tool_parsers.abstract_tool_parser.ToolParser · class
vllm_mlx.tool_parsers.abstract_tool_parser.ToolParser(tokenizer: PreTrainedTokenizerBase | None = None)

Abstract base class for tool call parsers.

Parameters

Name Type Required Default Description
tokenizer PreTrainedTokenizerBase \| None no None The tokenizer for the model (optional, some parsers need it)

Returns

  • Constructs: vllm_mlx.tool_parsers.abstract_tool_parser.ToolParser

Exceptions and behavior

Class ToolParser derives from ABC and declares 7 direct member(s). No direct raise statement appears in this definition.

View source #L40-L171.

vllm_mlx.tool_parsers.abstract_tool_parser.ToolParser.supports_native_format · method
vllm_mlx.tool_parsers.abstract_tool_parser.ToolParser.supports_native_format() -> bool

Check if this parser supports native tool message format.

Parameters

This callable has no explicit inputs.

Returns

  • Type: bool
  • Direct return expressions: cls.SUPPORTS_NATIVE_TOOL_FORMAT

Exceptions and behavior

Method ToolParser.supports_native_format returns cls.SUPPORTS_NATIVE_TOOL_FORMAT. No direct raise statement appears in this definition.

View source #L60-L72.

vllm_mlx.tool_parsers.abstract_tool_parser.ToolParser.strip_think_tags · method
vllm_mlx.tool_parsers.abstract_tool_parser.ToolParser.strip_think_tags(text: str) -> str

Strip think tags from text.

Parameters

Name Type Required Default Description
text str yes none Model output that may contain think tags

Returns

  • Type: str
  • Direct return expressions: result.strip()

Exceptions and behavior

Method ToolParser.strip_think_tags calls THINK_TAG_PATTERN.sub, IMPLICIT_THINK_PATTERN.sub, result.strip; returns result.strip(). No direct raise statement appears in this definition.

View source #L75-L101.

vllm_mlx.tool_parsers.abstract_tool_parser.ToolParser.__init__ · method
vllm_mlx.tool_parsers.abstract_tool_parser.ToolParser.__init__(tokenizer: PreTrainedTokenizerBase | None = None) -> not annotated

Initialize the tool parser.

Parameters

Name Type Required Default Description
tokenizer PreTrainedTokenizerBase \| None no None The tokenizer for the model (optional, some parsers need it)

Returns

  • Type: not annotated

Exceptions and behavior

Method ToolParser.__init__ updates self.model_tokenizer, self.current_tool_id, self.prev_tool_call_arr. No direct raise statement appears in this definition.

View source #L103-L113.

vllm_mlx.tool_parsers.abstract_tool_parser.ToolParser.vocab · method
vllm_mlx.tool_parsers.abstract_tool_parser.ToolParser.vocab() -> dict[str, int]

Get the tokenizer vocabulary.

Parameters

This callable has no explicit inputs.

Returns

  • Type: dict[str, int]
  • Direct return expressions: {}; self.model_tokenizer.get_vocab()

Exceptions and behavior

Method ToolParser.vocab calls self.model_tokenizer.get_vocab; has 2 explicit return paths. No direct raise statement appears in this definition.

View source #L116-L120.

vllm_mlx.tool_parsers.abstract_tool_parser.ToolParser.extract_tool_calls · method
vllm_mlx.tool_parsers.abstract_tool_parser.ToolParser.extract_tool_calls(model_output: str, request: dict[str, Any] | None = None) -> ExtractedToolCallInformation

Extract tool calls from a complete model response.

Parameters

Name Type Required Default Description
model_output str yes none The complete model output string
request dict[str, Any] \| None no None Optional request context (for tool definitions, etc.)

Returns

  • Type: ExtractedToolCallInformation

Exceptions and behavior

Method ToolParser.extract_tool_calls can raise NotImplementedError. Directly raised exceptions: NotImplementedError.

View source #L123-L136.

vllm_mlx.tool_parsers.abstract_tool_parser.ToolParser.extract_tool_calls_streaming · method
vllm_mlx.tool_parsers.abstract_tool_parser.ToolParser.extract_tool_calls_streaming(previous_text: str, current_text: str, delta_text: str, previous_token_ids: Sequence[int] | None = None, current_token_ids: Sequence[int] | None = None, delta_token_ids: Sequence[int] | None = None, request: dict[str, Any] | None = None) -> dict[str, Any] | None

Extract tool calls from streaming model output.

Parameters

Name Type Required Default Description
previous_text str yes none Text before this delta
current_text str yes none Complete text so far
delta_text str yes none New text in this chunk
previous_token_ids Sequence[int] \| None no None Token IDs before this delta
current_token_ids Sequence[int] \| None no None All token IDs so far
delta_token_ids Sequence[int] \| None no None New token IDs in this chunk
request dict[str, Any] \| None no None Optional request context

Returns

  • Type: dict[str, Any] | None
  • Direct return expressions: None

Exceptions and behavior

Method ToolParser.extract_tool_calls_streaming returns None. No direct raise statement appears in this definition.

View source #L138-L166.

vllm_mlx.tool_parsers.abstract_tool_parser.ToolParser.reset · method
vllm_mlx.tool_parsers.abstract_tool_parser.ToolParser.reset() -> None

Reset parser state for a new request.

Parameters

This callable has no explicit inputs.

Returns

  • Type: None

Exceptions and behavior

Method ToolParser.reset updates self.current_tool_id, self.prev_tool_call_arr. No direct raise statement appears in this definition.

View source #L168-L171.

vllm_mlx.tool_parsers.abstract_tool_parser.ToolParserManager · class
vllm_mlx.tool_parsers.abstract_tool_parser.ToolParserManager()

Central registry for ToolParser implementations.

Parameters

This callable has no explicit inputs.

Returns

  • Constructs: vllm_mlx.tool_parsers.abstract_tool_parser.ToolParserManager

Exceptions and behavior

Class ToolParserManager declares 5 direct member(s). No direct raise statement appears in this definition.

View source #L174-L286.

vllm_mlx.tool_parsers.abstract_tool_parser.ToolParserManager.get_tool_parser · method
vllm_mlx.tool_parsers.abstract_tool_parser.ToolParserManager.get_tool_parser(name: str) -> type[ToolParser]

Retrieve a registered ToolParser class by name.

Parameters

Name Type Required Default Description
name str yes none Parser name (e.g., 'mistral', 'qwen', 'llama')

Returns

  • Type: type[ToolParser]
  • Direct return expressions: cls.tool_parsers[name]; cls._load_lazy_parser(name)

Exceptions and behavior

Method ToolParserManager.get_tool_parser calls cls._load_lazy_parser, KeyError, cls.list_registered; can raise KeyError; has 2 explicit return paths. Directly raised exceptions: KeyError.

View source #L185-L207.

vllm_mlx.tool_parsers.abstract_tool_parser.ToolParserManager._load_lazy_parser · method
vllm_mlx.tool_parsers.abstract_tool_parser.ToolParserManager._load_lazy_parser(name: str) -> type[ToolParser]

Import and register a lazily loaded parser.

Parameters

Name Type Required Default Description
name str yes none Required positional or keyword input.

Returns

  • Type: type[ToolParser]
  • Direct return expressions: parser_cls

Exceptions and behavior

Method ToolParserManager._load_lazy_parser calls importlib.import_module, getattr, issubclass, TypeError; can raise TypeError, ImportError; returns parser_cls. Directly raised exceptions: TypeError, ImportError.

View source #L210-L225.

vllm_mlx.tool_parsers.abstract_tool_parser.ToolParserManager.register_module · method
vllm_mlx.tool_parsers.abstract_tool_parser.ToolParserManager.register_module(name: str | list[str], module: type[ToolParser] | None = None, force: bool = True) -> type[ToolParser] | None

Register a ToolParser class.

Parameters

Name Type Required Default Description
name str \| list[str] yes none Required positional or keyword input.
module type[ToolParser] \| None no None Optional positional or keyword input; defaults to None.
force bool no True Optional positional or keyword input; defaults to True.

Returns

  • Type: type[ToolParser] | None
  • Direct return expressions: module; decorator

Exceptions and behavior

Method ToolParserManager.register_module calls isinstance, issubclass, TypeError, type; can raise TypeError, KeyError; has 2 explicit return paths. Directly raised exceptions: TypeError, KeyError.

View source #L228-L269.

vllm_mlx.tool_parsers.abstract_tool_parser.ToolParserManager.register_module.decorator · nested function
vllm_mlx.tool_parsers.abstract_tool_parser.ToolParserManager.register_module.decorator(parser_cls: type[ToolParser]) -> type[ToolParser]

Nested Function ToolParserManager.register_module.decorator calls KeyError; can raise KeyError; returns parser_cls.

Parameters

Name Type Required Default Description
parser_cls type[ToolParser] yes none Required positional or keyword input.

Returns

  • Type: type[ToolParser]
  • Direct return expressions: parser_cls

Exceptions and behavior

Nested Function ToolParserManager.register_module.decorator calls KeyError; can raise KeyError; returns parser_cls. Directly raised exceptions: KeyError.

View source #L262-L267.

vllm_mlx.tool_parsers.abstract_tool_parser.ToolParserManager.register_lazy_module · method
vllm_mlx.tool_parsers.abstract_tool_parser.ToolParserManager.register_lazy_module(name: str, module_path: str, class_name: str) -> None

Register a lazy module mapping for deferred loading.

Parameters

Name Type Required Default Description
name str yes none Parser name to register
module_path str yes none Full module path (e.g., 'vllm_mlx.tool_parsers.mistral')
class_name str yes none Class name within the module

Returns

  • Type: None

Exceptions and behavior

Method ToolParserManager.register_lazy_module contains no state mutation, call, raise, return, await, or yield. No direct raise statement appears in this definition.

View source #L272-L281.

vllm_mlx.tool_parsers.abstract_tool_parser.ToolParserManager.list_registered · method
vllm_mlx.tool_parsers.abstract_tool_parser.ToolParserManager.list_registered() -> list[str]

Return names of all registered tool parsers.

Parameters

This callable has no explicit inputs.

Returns

  • Type: list[str]
  • Direct return expressions: sorted(set(cls.tool_parsers.keys()) | set(cls.lazy_parsers.keys()))

Exceptions and behavior

Method ToolParserManager.list_registered calls sorted, set, cls.tool_parsers.keys, cls.lazy_parsers.keys; returns sorted(set(cls.tool_parsers.keys()) | set(cls.lazy_parsers.keys())). No direct raise statement appears in this definition.

View source #L284-L286.

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
ExtractedToolCallInformation class ExtractedToolCallInformation(tools_called: bool, tool_calls: list[dict[str, Any]], content: str \| None = None) Information extracted from model output about tool calls. #L27-L37
ToolParser class ToolParser(tokenizer: PreTrainedTokenizerBase \| None = None) Abstract base class for tool call parsers. #L40-L171
ToolParser.supports_native_format method ToolParser.supports_native_format() -> bool Check if this parser supports native tool message format. #L60-L72
ToolParser.strip_think_tags method ToolParser.strip_think_tags(text: str) -> str Strip think tags from text. #L75-L101
ToolParser.__init__ method ToolParser.__init__(tokenizer: PreTrainedTokenizerBase \| None = None) -> not annotated Initialize the tool parser. #L103-L113
ToolParser.vocab method ToolParser.vocab() -> dict[str, int] Get the tokenizer vocabulary. #L116-L120
ToolParser.extract_tool_calls method ToolParser.extract_tool_calls(model_output: str, request: dict[str, Any] \| None = None) -> ExtractedToolCallInformation Extract tool calls from a complete model response. #L123-L136
ToolParser.extract_tool_calls_streaming method ToolParser.extract_tool_calls_streaming(previous_text: str, current_text: str, delta_text: str, previous_token_ids: Sequence[int] \| None = None, current_token_ids: Sequence[int] \| None = None, delta_token_ids: Sequence[int] \| None = None, request: dict[str, Any] \| None = None) -> dict[str, Any] \| None Extract tool calls from streaming model output. #L138-L166
ToolParser.reset method ToolParser.reset() -> None Reset parser state for a new request. #L168-L171
ToolParserManager class ToolParserManager() Central registry for ToolParser implementations. #L174-L286
ToolParserManager.get_tool_parser method ToolParserManager.get_tool_parser(name: str) -> type[ToolParser] Retrieve a registered ToolParser class by name. #L185-L207
ToolParserManager._load_lazy_parser method ToolParserManager._load_lazy_parser(name: str) -> type[ToolParser] Import and register a lazily loaded parser. #L210-L225
ToolParserManager.register_module method ToolParserManager.register_module(name: str \| list[str], module: type[ToolParser] \| None = None, force: bool = True) -> type[ToolParser] \| None Register a ToolParser class. #L228-L269
ToolParserManager.register_module.decorator nested function ToolParserManager.register_module.decorator(parser_cls: type[ToolParser]) -> type[ToolParser] Nested Function ToolParserManager.register_module.decorator calls KeyError; can raise KeyError; returns parser_cls. #L262-L267
ToolParserManager.register_lazy_module method ToolParserManager.register_lazy_module(name: str, module_path: str, class_name: str) -> None Register a lazy module mapping for deferred loading. #L272-L281
ToolParserManager.list_registered method ToolParserManager.list_registered() -> list[str] Return names of all registered tool parsers. #L284-L286