Skip to content

vllm.parser.glm47_moe

GLM-4.7 parser for reasoning and tool calls.

GLM-4.7 uses XML-like tool calls::

<tool_call>func_name<arg_key>key</arg_key><arg_value>value</arg_value></tool_call>

The function name can be followed directly by the first <arg_key> tag, and tool calls may have no arguments.

Classes:

  • Glm47MoeParser –

    GLM-4.7 parser backed by the declarative parser engine.

Glm47MoeParser

Bases: ParserEngine

GLM-4.7 parser backed by the declarative parser engine.

_ClosedArgs

Closed key/value pairs of a raw argument text, reused by longer texts.

Raw arguments only grow while a call streams, so a parse of a text that extends text resumes after its last closed value.

_closed_args(text, pos)

Yield (start, key, value, end) for each closed argument from pos.

_find_arg(text, pos)

Locate the first argument whose key starts at or after pos.

Returns the start and end of the key and the start of the value. The key runs to the first </arg_key> that is followed by <arg_value>. When the first <arg_key> has no such end, no later one has either, so each call scans the text once.

_glm47_parse_args(raw_args, partial, closed=None)

Return the arguments and the key of the open trailing value, if any.