Skip to content

vllm.parser.minimax_m2

MiniMax M2 parser for XML-style tool calls.

MiniMax M2 tool call format::

<minimax:tool_call><invoke name="get_weather">
<parameter name="city">Seattle</parameter>
</invoke></minimax:tool_call>

Each <invoke> block becomes one tool call. The argument body consists of <parameter name="...">...</parameter> tags.

Classes:

  • MinimaxM2Parser

    MiniMax M2 parser backed by the declarative parser engine.

MinimaxM2Parser

Bases: ParserEngine

MiniMax M2 parser backed by the declarative parser engine.

Source code in vllm/parser/minimax_m2.py
class MinimaxM2Parser(ParserEngine):
    """MiniMax M2 parser backed by the declarative parser engine."""

    def __init__(self, tokenizer, tools=None, **kwargs) -> None:
        kwargs.setdefault("parser_engine_config", minimax_m2_config())
        super().__init__(tokenizer, tools, **kwargs)
        self._think_end_token_id = self.vocab.get(THINK_END)

    def extract_content_ids(self, input_ids: list[int]) -> list[int]:
        end_id = self._think_end_token_id
        if end_id is None:
            return []
        for i in range(len(input_ids) - 1, -1, -1):
            if input_ids[i] == end_id:
                return input_ids[i + 1 :]
        return []