Skip to content

vllm.tool_parsers.functiongemma_tool_parser

Classes:

FunctionGemmaToolParser

Bases: ToolParser

Tool parser for Google's FunctionGemma model (google/functiongemma-270m-it).

Handles the FunctionGemma function call format: call:func_name{param:value}

_buffer_delta_text(delta_text)

Buffer incoming delta text to handle multi-token special sequences.

_close_tool_call(current_text)

Stream what is left of the current call, including its closing brace.

_parse_arguments(args_str, partial=False)

Parse a FunctionGemma argument string into a dictionary.

The chat template writes strings as <escape>text<escape> and everything else bare: true/false, numbers, [item,...] and {key:value,...} with bare keys. With partial the string is a streaming prefix: parsing stops at the first incomplete value and the complete arguments before it are returned.

_stream_arguments(args, final)

Stream the part of the arguments JSON not sent yet.

Arguments only grow by appended keys, so their JSON is prefix-stable except for the closing brace, which is held back until final.

_IncompleteValue

Bases: Exception

The argument text ends before the value does.

_MalformedValue

Bases: Exception

A delimiter appears where a value or key should start.

_parse_value(text, pos, partial)

Parse one value at pos and return it with the position after it.

Raises:

  • _IncompleteValue –

    text ends inside the value. A bare scalar at the end of a partial string counts as incomplete, since more digits or letters may still follow.

  • _MalformedValue –

    a delimiter stands where the value should start.