Skip to content

vllm_mlx.tool_parsers.poolside_v1_tool_parser

Tool parser for the Poolside v1 Laguna chat-template format.

View the complete module source at #L1-L362.

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

Tool parser for the Poolside v1 Laguna chat-template format.

vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser

PoolsideV1ToolParser(tokenizer=None)

Bases: Glm47ToolParser

Parse Laguna tool calls and stream schema-declared strings incrementally.

Source code in vllm_mlx/tool_parsers/poolside_v1_tool_parser.py
def __init__(self, tokenizer=None):
    super().__init__(tokenizer)
    self.reset()

vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser._UNCLOSED_TOOL_CALL class-attribute instance-attribute

_UNCLOSED_TOOL_CALL = re.compile('<tool_call>.*$', re.DOTALL)

vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser._START class-attribute instance-attribute

_START = '<tool_call>'

vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser._END class-attribute instance-attribute

_END = '</tool_call>'

vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser._KEY_START class-attribute instance-attribute

_KEY_START = '<arg_key>'

vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser._KEY_END class-attribute instance-attribute

_KEY_END = '</arg_key>'

vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser._VALUE_START class-attribute instance-attribute

_VALUE_START = '<arg_value>'

vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser._VALUE_END class-attribute instance-attribute

_VALUE_END = '</arg_value>'

vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser.reset

reset() -> None

Reset Laguna parser buffers and per-call argument state.

Source code in vllm_mlx/tool_parsers/poolside_v1_tool_parser.py
def reset(self) -> None:
    """Reset Laguna parser buffers and per-call argument state."""

    super().reset()
    self._buffer = ""
    self._in_tool_call = False
    self._current_tool_name: str | None = None
    self._pending_key: str | None = None
    self._streaming_string_value = False
    self._reject_current = False
    self._tool_ids: list[str] = []
    self._args_started: list[bool] = []
    self._args_closed: list[bool] = []
    self._seen_keys: list[set[str]] = []

vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser._string_argument_names staticmethod

_string_argument_names(request: dict[str, Any] | None, tool_name: str) -> set[str]
Source code in vllm_mlx/tool_parsers/poolside_v1_tool_parser.py
@staticmethod
def _string_argument_names(
    request: dict[str, Any] | None, tool_name: str
) -> set[str]:
    if request is None:
        return set()
    for tool in request.get("tools", []):
        if not isinstance(tool, dict):
            continue
        function = tool.get("function")
        if not isinstance(function, dict) or function.get("name") != tool_name:
            continue
        parameters = function.get("parameters")
        properties = (
            parameters.get("properties", {}) if isinstance(parameters, dict) else {}
        )
        return {
            name
            for name, schema in properties.items()
            if isinstance(schema, dict) and schema.get("type") == "string"
        }
    return set()

vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser._escape_string_content staticmethod

_escape_string_content(value: str) -> str
Source code in vllm_mlx/tool_parsers/poolside_v1_tool_parser.py
@staticmethod
def _escape_string_content(value: str) -> str:
    return json.dumps(value, ensure_ascii=False)[1:-1]

vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser._hold_partial_suffix staticmethod

_hold_partial_suffix(buffer: str, marker: str) -> tuple[str, str]
Source code in vllm_mlx/tool_parsers/poolside_v1_tool_parser.py
@staticmethod
def _hold_partial_suffix(buffer: str, marker: str) -> tuple[str, str]:
    for size in range(min(len(marker) - 1, len(buffer)), 0, -1):
        if buffer.endswith(marker[:size]):
            return buffer[:-size], buffer[-size:]
    return buffer, ""

vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser.extract_tool_calls

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

Extract complete Laguna tool blocks and preserve remaining content.

Source code in vllm_mlx/tool_parsers/poolside_v1_tool_parser.py
def extract_tool_calls(
    self, model_output: str, request: dict[str, Any] | None = None
) -> ExtractedToolCallInformation:
    """Extract complete Laguna tool blocks and preserve remaining content."""

    cleaned_text = self.strip_think_tags(model_output)
    valid_names = self._get_tool_names(request)
    tool_calls: list[dict[str, Any]] = []

    for match in self.FUNC_DETAIL_PATTERN.finditer(cleaned_text):
        tool_name = match.group(1).strip()
        if not tool_name or (valid_names and tool_name not in valid_names):
            continue
        string_arguments = self._string_argument_names(request, tool_name)
        arguments: dict[str, Any] = {}
        for raw_key, raw_value in self.ARG_PATTERN.findall(match.group(2) or ""):
            key = raw_key.strip()
            if not key or key in arguments:
                continue
            arguments[key] = (
                raw_value
                if key in string_arguments
                else self._deserialize(raw_value.strip())
            )
        tool_calls.append(
            {
                "id": generate_tool_id(),
                "name": tool_name,
                "arguments": json.dumps(arguments, ensure_ascii=False),
            }
        )

    marker = cleaned_text.find(self._START)
    content = cleaned_text[:marker] if marker >= 0 else cleaned_text
    content = content.strip() or None
    if tool_calls:
        return ExtractedToolCallInformation(True, tool_calls, content)

    if marker >= 0:
        content = self._UNCLOSED_TOOL_CALL.sub("", cleaned_text).strip() or None
    return ExtractedToolCallInformation(False, [], content)

vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser._begin_tool_call

_begin_tool_call() -> None
Source code in vllm_mlx/tool_parsers/poolside_v1_tool_parser.py
def _begin_tool_call(self) -> None:
    self.current_tool_id += 1
    self._tool_ids.append(generate_tool_id())
    self._args_started.append(False)
    self._args_closed.append(False)
    self._seen_keys.append(set())
    self._in_tool_call = True
    self._current_tool_name = None
    self._pending_key = None
    self._streaming_string_value = False
    self._reject_current = False

vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser._finish_tool_call

_finish_tool_call() -> None
Source code in vllm_mlx/tool_parsers/poolside_v1_tool_parser.py
def _finish_tool_call(self) -> None:
    self._in_tool_call = False
    self._current_tool_name = None
    self._pending_key = None
    self._streaming_string_value = False
    self._reject_current = False

vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser._delta

_delta(pending: dict[int, dict[str, Any]], *, name: str | None = None, arguments: str = '') -> None
Source code in vllm_mlx/tool_parsers/poolside_v1_tool_parser.py
def _delta(
    self,
    pending: dict[int, dict[str, Any]],
    *,
    name: str | None = None,
    arguments: str = "",
) -> None:
    if self._reject_current:
        return
    delta = pending.setdefault(
        self.current_tool_id,
        {
            "index": self.current_tool_id,
            "id": self._tool_ids[self.current_tool_id],
            "type": "function",
            "function": {"arguments": ""},
        },
    )
    if name is not None:
        delta["function"]["name"] = name
    delta["function"]["arguments"] += arguments

vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser._argument_prefix

_argument_prefix(key: str) -> str | None
Source code in vllm_mlx/tool_parsers/poolside_v1_tool_parser.py
def _argument_prefix(self, key: str) -> str | None:
    seen = self._seen_keys[self.current_tool_id]
    if not key or key in seen:
        return None
    seen.add(key)
    separator = "{" if not self._args_started[self.current_tool_id] else ", "
    self._args_started[self.current_tool_id] = True
    return separator + json.dumps(key, ensure_ascii=False) + ": "

vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser._close_arguments

_close_arguments() -> str
Source code in vllm_mlx/tool_parsers/poolside_v1_tool_parser.py
def _close_arguments(self) -> str:
    if self._args_closed[self.current_tool_id]:
        return ""
    self._args_closed[self.current_tool_id] = True
    return "}" if self._args_started[self.current_tool_id] else "{}"

vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser._discard_through_tool_end

_discard_through_tool_end() -> bool
Source code in vllm_mlx/tool_parsers/poolside_v1_tool_parser.py
def _discard_through_tool_end(self) -> bool:
    end = self._buffer.find(self._END)
    if end < 0:
        return False
    self._buffer = self._buffer[end + len(self._END) :]
    self._finish_tool_call()
    return True

vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser._consume_text_before_tool

_consume_text_before_tool() -> tuple[bool, str]

Consume plain text or enter the next <tool_call> state.

Source code in vllm_mlx/tool_parsers/poolside_v1_tool_parser.py
def _consume_text_before_tool(self) -> tuple[bool, str]:
    """Consume plain text or enter the next ``<tool_call>`` state."""
    start = self._buffer.find(self._START)
    if start < 0:
        emitted, self._buffer = self._hold_partial_suffix(self._buffer, self._START)
        return False, emitted

    content = self._buffer[:start]
    self._buffer = self._buffer[start + len(self._START) :]
    self._begin_tool_call()
    return True, content

vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser._consume_tool_name

_consume_tool_name(pending: dict[int, dict[str, Any]], valid_names: set[str]) -> bool

Consume a tool name, or wait for enough input to identify it.

Source code in vllm_mlx/tool_parsers/poolside_v1_tool_parser.py
def _consume_tool_name(
    self,
    pending: dict[int, dict[str, Any]],
    valid_names: set[str],
) -> bool:
    """Consume a tool name, or wait for enough input to identify it."""
    positions = [
        position
        for position in (
            self._buffer.find("\n"),
            self._buffer.find(self._KEY_START),
            self._buffer.find(self._END),
        )
        if position >= 0
    ]
    if not positions:
        return False

    cut = min(positions)
    tool_name = self._buffer[:cut].strip()
    if self._buffer.startswith("\n", cut):
        self._buffer = self._buffer[cut + 1 :]
    else:
        self._buffer = self._buffer[cut:]

    if not tool_name or (valid_names and tool_name not in valid_names):
        self._reject_current = True
        return self._discard_through_tool_end()

    self._current_tool_name = tool_name
    self._delta(pending, name=tool_name)
    return True

vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser._consume_string_value

_consume_string_value(pending: dict[int, dict[str, Any]]) -> bool

Consume a string argument value, retaining incomplete suffixes.

Source code in vllm_mlx/tool_parsers/poolside_v1_tool_parser.py
def _consume_string_value(self, pending: dict[int, dict[str, Any]]) -> bool:
    """Consume a string argument value, retaining incomplete suffixes."""
    value_end = self._buffer.find(self._VALUE_END)
    if value_end >= 0:
        fragment = self._escape_string_content(self._buffer[:value_end])
        self._buffer = self._buffer[value_end + len(self._VALUE_END) :]
        self._delta(pending, arguments=fragment + '"')
        self._streaming_string_value = False
        self._pending_key = None
        return True

    if self._END in self._buffer:
        self._reject_current = True
        return self._discard_through_tool_end()

    emitted, self._buffer = self._hold_partial_suffix(self._buffer, self._VALUE_END)
    if emitted:
        self._delta(pending, arguments=self._escape_string_content(emitted))
    return False

vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser._consume_pending_key

_consume_pending_key(pending: dict[int, dict[str, Any]], request: dict[str, Any] | None) -> bool

Consume the value for the currently buffered argument key.

Source code in vllm_mlx/tool_parsers/poolside_v1_tool_parser.py
def _consume_pending_key(
    self,
    pending: dict[int, dict[str, Any]],
    request: dict[str, Any] | None,
) -> bool:
    """Consume the value for the currently buffered argument key."""
    value_start = self._buffer.find(self._VALUE_START)
    if value_start < 0:
        if self._END in self._buffer:
            self._reject_current = True
            return self._discard_through_tool_end()
        return False

    self._buffer = self._buffer[value_start + len(self._VALUE_START) :]
    key = self._pending_key.strip() if self._pending_key is not None else ""
    prefix = self._argument_prefix(key)
    if prefix is None:
        self._pending_key = None
        return True

    string_names = self._string_argument_names(request, self._current_tool_name)
    if key in string_names:
        self._delta(pending, arguments=prefix + '"')
        self._streaming_string_value = True
        return True

    value_end = self._buffer.find(self._VALUE_END)
    if value_end < 0:
        self._buffer = self._VALUE_START + self._buffer
        return False

    raw_value = self._buffer[:value_end].strip()
    self._buffer = self._buffer[value_end + len(self._VALUE_END) :]
    self._pending_key = None
    value = json.dumps(self._deserialize(raw_value), ensure_ascii=False)
    self._delta(pending, arguments=prefix + value)
    return True

vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser._consume_tool_body

_consume_tool_body(pending: dict[int, dict[str, Any]]) -> bool

Consume an argument key or close the current tool call.

Source code in vllm_mlx/tool_parsers/poolside_v1_tool_parser.py
def _consume_tool_body(self, pending: dict[int, dict[str, Any]]) -> bool:
    """Consume an argument key or close the current tool call."""
    tool_end = self._buffer.find(self._END)
    key_start = self._buffer.find(self._KEY_START)
    if tool_end >= 0 and (key_start < 0 or tool_end < key_start):
        self._buffer = self._buffer[tool_end + len(self._END) :]
        self._delta(pending, arguments=self._close_arguments())
        self._finish_tool_call()
        return True

    if key_start < 0:
        return False

    self._buffer = self._buffer[key_start + len(self._KEY_START) :]
    key_end = self._buffer.find(self._KEY_END)
    if key_end < 0:
        self._buffer = self._KEY_START + self._buffer
        return False

    self._pending_key = self._buffer[:key_end]
    self._buffer = self._buffer[key_end + len(self._KEY_END) :]
    return True

vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser.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

Incrementally emit Laguna content and schema-aware tool arguments.

Source code in vllm_mlx/tool_parsers/poolside_v1_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:
    """Incrementally emit Laguna content and schema-aware tool arguments."""

    del previous_text, current_text, previous_token_ids, current_token_ids
    del delta_token_ids
    self._buffer += delta_text
    pending: dict[int, dict[str, Any]] = {}
    content = ""
    valid_names = self._get_tool_names(request)

    while True:
        keep_parsing, emitted = _consume_stream_state(
            self, pending, valid_names, request
        )
        content += emitted
        if not keep_parsing:
            break

    payload: dict[str, Any] = {}
    if content:
        payload["content"] = content
    if pending:
        payload["tool_calls"] = list(pending.values())
    return payload or None

vllm_mlx.tool_parsers.poolside_v1_tool_parser._consume_stream_state

_consume_stream_state(parser, pending: dict[int, dict[str, Any]], valid_names: set[str], request: dict[str, Any] | None) -> tuple[bool, str]
Source code in vllm_mlx/tool_parsers/poolside_v1_tool_parser.py
def _consume_stream_state(
    parser,
    pending: dict[int, dict[str, Any]],
    valid_names: set[str],
    request: dict[str, Any] | None,
) -> tuple[bool, str]:
    if not parser._in_tool_call:
        return parser._consume_text_before_tool()
    if parser._current_tool_name is None:
        return parser._consume_tool_name(pending, valid_names), ""
    if parser._streaming_string_value:
        return parser._consume_string_value(pending), ""
    if parser._pending_key is not None:
        return parser._consume_pending_key(pending, request), ""
    return parser._consume_tool_body(pending), ""

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.poolside_v1_tool_parser._consume_stream_state · function
vllm_mlx.tool_parsers.poolside_v1_tool_parser._consume_stream_state(parser, pending: dict[int, dict[str, Any]], valid_names: set[str], request: dict[str, Any] | None) -> tuple[bool, str]

Function _consume_stream_state calls parser._consume_text_before_tool, parser._consume_tool_name, parser._consume_string_value, parser._consume_pending_key; has 5 explicit return paths.

Parameters

Name Type Required Default Description
parser not annotated yes none Required positional or keyword input.
pending dict[int, dict[str, Any]] yes none Required positional or keyword input.
valid_names set[str] yes none Required positional or keyword input.
request dict[str, Any] \| None yes none Required positional or keyword input.

Returns

  • Type: tuple[bool, str]
  • Direct return expressions: parser._consume_text_before_tool(); (parser._consume_tool_name(pending, valid_names), ''); (parser._consume_string_value(pending), ''); (parser._consume_pending_key(pending, request), ''); (parser._consume_tool_body(pending), '')

Exceptions and behavior

Function _consume_stream_state calls parser._consume_text_before_tool, parser._consume_tool_name, parser._consume_string_value, parser._consume_pending_key; has 5 explicit return paths. No direct raise statement appears in this definition.

View source #L16-L30.

vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser · class
vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser(tokenizer = None)

Parse Laguna tool calls and stream schema-declared strings incrementally.

Parameters

Name Type Required Default Description
tokenizer not annotated no None Optional positional or keyword input; defaults to None.

Returns

  • Constructs: vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser

Exceptions and behavior

Class PoolsideV1ToolParser derives from Glm47ToolParser and declares 18 direct member(s). No direct raise statement appears in this definition.

View source #L34-L362.

vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser.__init__ · method
vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser.__init__(tokenizer = None) -> not annotated

Method PoolsideV1ToolParser.__init__ calls super().__init__, super, self.reset.

Parameters

Name Type Required Default Description
tokenizer not annotated no None Optional positional or keyword input; defaults to None.

Returns

  • Type: not annotated

Exceptions and behavior

Method PoolsideV1ToolParser.__init__ calls super().__init__, super, self.reset. No direct raise statement appears in this definition.

View source #L45-L47.

vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser.reset · method
vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser.reset() -> None

Reset Laguna parser buffers and per-call argument state.

Parameters

This callable has no explicit inputs.

Returns

  • Type: None

Exceptions and behavior

Method PoolsideV1ToolParser.reset updates self._buffer, self._in_tool_call, self._current_tool_name, self._pending_key; calls super().reset, super. No direct raise statement appears in this definition.

View source #L49-L62.

vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser._string_argument_names · method
vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser._string_argument_names(request: dict[str, Any] | None, tool_name: str) -> set[str]

Method PoolsideV1ToolParser._string_argument_names calls set, request.get, isinstance, tool.get; has 2 explicit return paths.

Parameters

Name Type Required Default Description
request dict[str, Any] \| None yes none Required positional or keyword input.
tool_name str yes none Required positional or keyword input.

Returns

  • Type: set[str]
  • Direct return expressions: set(); {name for name, schema in properties.items() if isinstance(schema, dict) and schema.get('type') == 'string'}

Exceptions and behavior

Method PoolsideV1ToolParser._string_argument_names calls set, request.get, isinstance, tool.get; has 2 explicit return paths. No direct raise statement appears in this definition.

View source #L65-L85.

vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser._escape_string_content · method
vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser._escape_string_content(value: str) -> str

Method PoolsideV1ToolParser._escape_string_content calls json.dumps; returns json.dumps(value, ensure_ascii=False)[1:-1].

Parameters

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

Returns

  • Type: str
  • Direct return expressions: json.dumps(value, ensure_ascii=False)[1:-1]

Exceptions and behavior

Method PoolsideV1ToolParser._escape_string_content calls json.dumps; returns json.dumps(value, ensure_ascii=False)[1:-1]. No direct raise statement appears in this definition.

View source #L88-L89.

vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser._hold_partial_suffix · method
vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser._hold_partial_suffix(buffer: str, marker: str) -> tuple[str, str]

Method PoolsideV1ToolParser._hold_partial_suffix calls range, min, len, buffer.endswith; has 2 explicit return paths.

Parameters

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

Returns

  • Type: tuple[str, str]
  • Direct return expressions: (buffer[:-size], buffer[-size:]); (buffer, '')

Exceptions and behavior

Method PoolsideV1ToolParser._hold_partial_suffix calls range, min, len, buffer.endswith; has 2 explicit return paths. No direct raise statement appears in this definition.

View source #L92-L96.

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

Extract complete Laguna tool blocks and preserve remaining content.

Parameters

Name Type Required Default Description
model_output str yes none Required positional or keyword input.
request dict[str, Any] \| None no None Optional positional or keyword input; defaults to None.

Returns

  • Type: ExtractedToolCallInformation
  • Direct return expressions: ExtractedToolCallInformation(True, tool_calls, content); ExtractedToolCallInformation(False, [], content)

Exceptions and behavior

Method PoolsideV1ToolParser.extract_tool_calls calls self.strip_think_tags, self._get_tool_names, self.FUNC_DETAIL_PATTERN.finditer, match.group(1).strip; has 2 explicit return paths. No direct raise statement appears in this definition.

View source #L98-L138.

vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser._begin_tool_call · method
vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser._begin_tool_call() -> None

Method PoolsideV1ToolParser._begin_tool_call updates self.current_tool_id, self._in_tool_call, self._current_tool_name, self._pending_key; calls self._tool_ids.append, generate_tool_id, self._args_started.append, self._args_closed.append.

Parameters

This callable has no explicit inputs.

Returns

  • Type: None

Exceptions and behavior

Method PoolsideV1ToolParser._begin_tool_call updates self.current_tool_id, self._in_tool_call, self._current_tool_name, self._pending_key; calls self._tool_ids.append, generate_tool_id, self._args_started.append, self._args_closed.append. No direct raise statement appears in this definition.

View source #L140-L150.

vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser._finish_tool_call · method
vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser._finish_tool_call() -> None

Method PoolsideV1ToolParser._finish_tool_call updates self._in_tool_call, self._current_tool_name, self._pending_key, self._streaming_string_value.

Parameters

This callable has no explicit inputs.

Returns

  • Type: None

Exceptions and behavior

Method PoolsideV1ToolParser._finish_tool_call updates self._in_tool_call, self._current_tool_name, self._pending_key, self._streaming_string_value. No direct raise statement appears in this definition.

View source #L152-L157.

vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser._delta · method
vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser._delta(pending: dict[int, dict[str, Any]], *, name: str | None = None, arguments: str = '') -> None

Method PoolsideV1ToolParser._delta calls pending.setdefault; returns None.

Parameters

Name Type Required Default Description
pending dict[int, dict[str, Any]] yes none Required positional or keyword input.
name str \| None no None Optional keyword-only input; defaults to None.
arguments str no '' Optional keyword-only input; defaults to ''.

Returns

  • Type: None
  • Direct return expressions: None

Exceptions and behavior

Method PoolsideV1ToolParser._delta calls pending.setdefault; returns None. No direct raise statement appears in this definition.

View source #L159-L179.

vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser._argument_prefix · method
vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser._argument_prefix(key: str) -> str | None

Method PoolsideV1ToolParser._argument_prefix calls seen.add, json.dumps; has 2 explicit return paths.

Parameters

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

Returns

  • Type: str | None
  • Direct return expressions: None; separator + json.dumps(key, ensure_ascii=False) + ': '

Exceptions and behavior

Method PoolsideV1ToolParser._argument_prefix calls seen.add, json.dumps; has 2 explicit return paths. No direct raise statement appears in this definition.

View source #L181-L188.

vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser._close_arguments · method
vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser._close_arguments() -> str

Method PoolsideV1ToolParser._close_arguments has 2 explicit return paths.

Parameters

This callable has no explicit inputs.

Returns

  • Type: str
  • Direct return expressions: ''; '}' if self._args_started[self.current_tool_id] else '{}'

Exceptions and behavior

Method PoolsideV1ToolParser._close_arguments has 2 explicit return paths. No direct raise statement appears in this definition.

View source #L190-L194.

vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser._discard_through_tool_end · method
vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser._discard_through_tool_end() -> bool

Method PoolsideV1ToolParser._discard_through_tool_end updates self._buffer; calls self._buffer.find, len, self._finish_tool_call; has 2 explicit return paths.

Parameters

This callable has no explicit inputs.

Returns

  • Type: bool
  • Direct return expressions: False; True

Exceptions and behavior

Method PoolsideV1ToolParser._discard_through_tool_end updates self._buffer; calls self._buffer.find, len, self._finish_tool_call; has 2 explicit return paths. No direct raise statement appears in this definition.

View source #L196-L202.

vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser._consume_text_before_tool · method
vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser._consume_text_before_tool() -> tuple[bool, str]

Consume plain text or enter the next <tool_call> state.

Parameters

This callable has no explicit inputs.

Returns

  • Type: tuple[bool, str]
  • Direct return expressions: (False, emitted); (True, content)

Exceptions and behavior

Method PoolsideV1ToolParser._consume_text_before_tool updates self._buffer; calls self._buffer.find, self._hold_partial_suffix, len, self._begin_tool_call; has 2 explicit return paths. No direct raise statement appears in this definition.

View source #L204-L214.

vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser._consume_tool_name · method
vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser._consume_tool_name(pending: dict[int, dict[str, Any]], valid_names: set[str]) -> bool

Consume a tool name, or wait for enough input to identify it.

Parameters

Name Type Required Default Description
pending dict[int, dict[str, Any]] yes none Required positional or keyword input.
valid_names set[str] yes none Required positional or keyword input.

Returns

  • Type: bool
  • Direct return expressions: False; self._discard_through_tool_end(); True

Exceptions and behavior

Method PoolsideV1ToolParser._consume_tool_name updates self._buffer, self._reject_current, self._current_tool_name; calls self._buffer.find, min, self._buffer[:cut].strip, self._buffer.startswith; has 3 explicit return paths. No direct raise statement appears in this definition.

View source #L216-L247.

vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser._consume_string_value · method
vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser._consume_string_value(pending: dict[int, dict[str, Any]]) -> bool

Consume a string argument value, retaining incomplete suffixes.

Parameters

Name Type Required Default Description
pending dict[int, dict[str, Any]] yes none Required positional or keyword input.

Returns

  • Type: bool
  • Direct return expressions: True; self._discard_through_tool_end(); False

Exceptions and behavior

Method PoolsideV1ToolParser._consume_string_value updates self._buffer, self._streaming_string_value, self._pending_key, self._reject_current; calls self._buffer.find, self._escape_string_content, len, self._delta; has 3 explicit return paths. No direct raise statement appears in this definition.

View source #L249-L267.

vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser._consume_pending_key · method
vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser._consume_pending_key(pending: dict[int, dict[str, Any]], request: dict[str, Any] | None) -> bool

Consume the value for the currently buffered argument key.

Parameters

Name Type Required Default Description
pending dict[int, dict[str, Any]] yes none Required positional or keyword input.
request dict[str, Any] \| None yes none Required positional or keyword input.

Returns

  • Type: bool
  • Direct return expressions: self._discard_through_tool_end(); False; True

Exceptions and behavior

Method PoolsideV1ToolParser._consume_pending_key updates self._reject_current, self._buffer, self._pending_key, self._streaming_string_value; calls self._buffer.find, self._discard_through_tool_end, len, self._pending_key.strip; has 3 explicit return paths. No direct raise statement appears in this definition.

View source #L269-L305.

vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser._consume_tool_body · method
vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser._consume_tool_body(pending: dict[int, dict[str, Any]]) -> bool

Consume an argument key or close the current tool call.

Parameters

Name Type Required Default Description
pending dict[int, dict[str, Any]] yes none Required positional or keyword input.

Returns

  • Type: bool
  • Direct return expressions: True; False

Exceptions and behavior

Method PoolsideV1ToolParser._consume_tool_body updates self._buffer, self._pending_key; calls self._buffer.find, len, self._delta, self._close_arguments; has 2 explicit return paths. No direct raise statement appears in this definition.

View source #L307-L328.

vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser.extract_tool_calls_streaming · method
vllm_mlx.tool_parsers.poolside_v1_tool_parser.PoolsideV1ToolParser.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

Incrementally emit Laguna content and schema-aware tool arguments.

Parameters

Name Type Required Default Description
previous_text str yes none Required positional or keyword input.
current_text str yes none Required positional or keyword input.
delta_text str yes none Required positional or keyword input.
previous_token_ids Sequence[int] \| None no None Optional positional or keyword input; defaults to None.
current_token_ids Sequence[int] \| None no None Optional positional or keyword input; defaults to None.
delta_token_ids Sequence[int] \| None no None Optional positional or keyword input; defaults to None.
request dict[str, Any] \| None no None Optional positional or keyword input; defaults to None.

Returns

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

Exceptions and behavior

Method PoolsideV1ToolParser.extract_tool_calls_streaming updates self._buffer; calls self._get_tool_names, _consume_stream_state, list, pending.values; returns payload or None. No direct raise statement appears in this definition.

View source #L330-L362.

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
_consume_stream_state function _consume_stream_state(parser, pending: dict[int, dict[str, Any]], valid_names: set[str], request: dict[str, Any] \| None) -> tuple[bool, str] Function _consume_stream_state calls parser._consume_text_before_tool, parser._consume_tool_name, parser._consume_string_value, parser._consume_pending_key; has 5 explicit return paths. #L16-L30
PoolsideV1ToolParser class PoolsideV1ToolParser(tokenizer = None) Parse Laguna tool calls and stream schema-declared strings incrementally. #L34-L362
PoolsideV1ToolParser.__init__ method PoolsideV1ToolParser.__init__(tokenizer = None) -> not annotated Method PoolsideV1ToolParser.__init__ calls super().__init__, super, self.reset. #L45-L47
PoolsideV1ToolParser.reset method PoolsideV1ToolParser.reset() -> None Reset Laguna parser buffers and per-call argument state. #L49-L62
PoolsideV1ToolParser._string_argument_names method PoolsideV1ToolParser._string_argument_names(request: dict[str, Any] \| None, tool_name: str) -> set[str] Method PoolsideV1ToolParser._string_argument_names calls set, request.get, isinstance, tool.get; has 2 explicit return paths. #L65-L85
PoolsideV1ToolParser._escape_string_content method PoolsideV1ToolParser._escape_string_content(value: str) -> str Method PoolsideV1ToolParser._escape_string_content calls json.dumps; returns json.dumps(value, ensure_ascii=False)[1:-1]. #L88-L89
PoolsideV1ToolParser._hold_partial_suffix method PoolsideV1ToolParser._hold_partial_suffix(buffer: str, marker: str) -> tuple[str, str] Method PoolsideV1ToolParser._hold_partial_suffix calls range, min, len, buffer.endswith; has 2 explicit return paths. #L92-L96
PoolsideV1ToolParser.extract_tool_calls method PoolsideV1ToolParser.extract_tool_calls(model_output: str, request: dict[str, Any] \| None = None) -> ExtractedToolCallInformation Extract complete Laguna tool blocks and preserve remaining content. #L98-L138
PoolsideV1ToolParser._begin_tool_call method PoolsideV1ToolParser._begin_tool_call() -> None Method PoolsideV1ToolParser._begin_tool_call updates self.current_tool_id, self._in_tool_call, self._current_tool_name, self._pending_key; calls self._tool_ids.append, generate_tool_id, self._args_started.append, self._args_closed.append. #L140-L150
PoolsideV1ToolParser._finish_tool_call method PoolsideV1ToolParser._finish_tool_call() -> None Method PoolsideV1ToolParser._finish_tool_call updates self._in_tool_call, self._current_tool_name, self._pending_key, self._streaming_string_value. #L152-L157
PoolsideV1ToolParser._delta method PoolsideV1ToolParser._delta(pending: dict[int, dict[str, Any]], *, name: str \| None = None, arguments: str = '') -> None Method PoolsideV1ToolParser._delta calls pending.setdefault; returns None. #L159-L179
PoolsideV1ToolParser._argument_prefix method PoolsideV1ToolParser._argument_prefix(key: str) -> str \| None Method PoolsideV1ToolParser._argument_prefix calls seen.add, json.dumps; has 2 explicit return paths. #L181-L188
PoolsideV1ToolParser._close_arguments method PoolsideV1ToolParser._close_arguments() -> str Method PoolsideV1ToolParser._close_arguments has 2 explicit return paths. #L190-L194
PoolsideV1ToolParser._discard_through_tool_end method PoolsideV1ToolParser._discard_through_tool_end() -> bool Method PoolsideV1ToolParser._discard_through_tool_end updates self._buffer; calls self._buffer.find, len, self._finish_tool_call; has 2 explicit return paths. #L196-L202
PoolsideV1ToolParser._consume_text_before_tool method PoolsideV1ToolParser._consume_text_before_tool() -> tuple[bool, str] Consume plain text or enter the next <tool_call> state. #L204-L214
PoolsideV1ToolParser._consume_tool_name method PoolsideV1ToolParser._consume_tool_name(pending: dict[int, dict[str, Any]], valid_names: set[str]) -> bool Consume a tool name, or wait for enough input to identify it. #L216-L247
PoolsideV1ToolParser._consume_string_value method PoolsideV1ToolParser._consume_string_value(pending: dict[int, dict[str, Any]]) -> bool Consume a string argument value, retaining incomplete suffixes. #L249-L267
PoolsideV1ToolParser._consume_pending_key method PoolsideV1ToolParser._consume_pending_key(pending: dict[int, dict[str, Any]], request: dict[str, Any] \| None) -> bool Consume the value for the currently buffered argument key. #L269-L305
PoolsideV1ToolParser._consume_tool_body method PoolsideV1ToolParser._consume_tool_body(pending: dict[int, dict[str, Any]]) -> bool Consume an argument key or close the current tool call. #L307-L328
PoolsideV1ToolParser.extract_tool_calls_streaming method PoolsideV1ToolParser.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 Incrementally emit Laguna content and schema-aware tool arguments. #L330-L362