Skip to content

vllm.tool_parsers.hy_v3_tool_parser

Classes:

HYV3ToolParser

Bases: ToolParser

_deserialize(value) staticmethod

Deserialize a string value using json.loads then safe_literal_eval.

_extract_streaming_incremental(name_delta, request)

Incremental phase-2: scan tags in buffer, emit JSON diffs.

Strategy: - Track completed args and emit each one as a JSON fragment. - For string-typed args, stream the value character-by-character. - Withhold the closing } until </tool_call> is seen.

We build JSON manually via fragments rather than using json.dumps with a cursor, because json.dumps of partial-vs-full string values produces incompatible prefixes (e.g. ""} vs "Hello"}).

_get_arg_schema(function_name, arg_key, tools) staticmethod

Look up a specific argument's property schema from the tools list.

_get_schema_options(arg_schema) staticmethod

Normalize any property schema into a list of sub-schemas. - has type (single type) → return [arg_schema] - anyOf → return the anyOf list - oneOf → return the oneOf list - fallback → [{"type": "string"}]

Note: single type has the highest priority.

_get_types(arg_schema) staticmethod

Extract normalized, non-null type set from a property schema.

_is_only_string_type(function_name, arg_key, tools) staticmethod

Return True if the parameter's type set is exactly {"string"}.

Only pure string types get partial value streaming; compound types like anyOf(string | array) do not, since the partial value might end up being a JSON array or object.

_make_args_delta(argument_diff)

Build a DeltaMessage containing only an arguments diff.

_normalize_type(raw_type) staticmethod

Map non-standard type aliases to JSON Schema standard names.

First performs exact lookup in _TYPE_ALIASES. On miss, falls back to prefix-based matching using startswith() - int/uint/long/short/unsigned → "integer" - num/float* → "number"

_parse_value(value, function_name, arg_key, tools) staticmethod

Unified argument value parser with anyOf/oneOf support.

Fallthrough chain

bool → int → number(wildcard_number) → json.loads for array/object → string → _deserialize

_reset_streaming_tool_state()

Reset the streaming state for a single tool call.

_try_parse_bool(value) staticmethod

Try to parse a string as bool; return None on failure.

_try_parse_int(value) staticmethod

Try to parse a string as int; return None on failure.

_try_parse_wildcard_number(value) staticmethod

Try to parse a string as a number (int or float).

Decision rule: if the string contains '.' or 'e'/'E' (scientific notation), parse as float; otherwise parse as int.

Examples:

"5" → int(5) "5.0" → float(5.0) "5.3" → float(5.3) "1e3" → float(1000.0) "-3" → int(-3)

Return None on failure.