vllm.parser.utils
¶
Functions:
-
extract_json_member_object–Extract the raw text span of the top-level object-valued member
key -
scan_json_object_end–Return the end index (exclusive) of the JSON object starting at
extract_json_member_object(raw, key)
¶
Extract the raw text span of the top-level object-valued member key
from a (possibly incomplete) {...} JSON wrapper.
Returns the verbatim substring (prefix-stable as the input grows, which
the engine's argument-delta diffing relies on), possibly an unterminated
object prefix; None when the value has not started. Raises
ValueError when the member is present but its value is not a JSON
object. A verbatim substring (not re-serialized JSON) is required because
the engine diffs successive converter outputs and expects each to extend
the previous one; the scanner is string/escape-aware so a matching literal
inside another value cannot mislead it, and it recovers a partial span when
the wrapper is truncated (where json.loads would fail).
Source code in vllm/parser/utils.py
scan_json_object_end(raw, start)
¶
Return the end index (exclusive) of the JSON object starting at
raw[start] (which must be {), or None when it is still
unterminated. String- and escape-aware so braces inside strings do not
mislead the depth count.