vllm.parser.inkling ¶
Inkling parser: typed content blocks parsed by a single state machine.
Inkling output format (every marker is a dedicated special token)::
<|message_model|><|content_thinking|>...reasoning...<|end_message|>
<|message_model|><|content_text|>...visible text...<|end_message|>
<|message_model|><|content_invoke_tool_json|>
{"name":"get_weather","args":{"city":"SF"}}<|end_message|>
Blocks are self-describing and may repeat in any order; sampling may also end a block with the standalone <|content_model_end_sampling|> token. The tool-call payload is a single JSON object whose name is extracted by the engine's name-from-args path and whose args object is carved out of the wrapper by :func:_inkling_arg_converter.
Note the terminal labels: THINK_START/THINK_END are what the engine keys its reasoning plumbing on (is_reasoning_end, count_reasoning_tokens, initial-state seeding), so <|end_message|> is labelled THINK_END here even though it ends every block kind — the transition table, not the label, carries the semantics.
Classes:
InklingParser ¶
Bases: ParserEngine
Methods:
-
adjust_initial_state_from_prompt–Seed the initial parsing state from the prompt tail.
Source code in vllm/parser/inkling.py
298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 | |
adjust_initial_state_from_prompt(prompt_token_ids) ¶
Seed the initial parsing state from the prompt tail.
Mirrors the Rust parser's initialize(): scanning the prompt backwards, the last relevant special token decides whether generation continues inside a thinking block, a text block, a model message header, or between blocks.
Source code in vllm/parser/inkling.py
_args_value_span(raw) ¶
Extract the raw text span of the top-level "args" value from a (possibly incomplete) {"name":...,"args":{...}} wrapper.
Returns the verbatim substring (prefix-stable across growing input, 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 value is not a JSON object.
Source code in vllm/parser/inkling.py
_inkling_arg_converter(raw_args, partial) ¶
Carve the args object out of the tool-call JSON wrapper.
Why a converter at all: the engine's tool_args_json machinery treats the entire TOOL_ARGS text as the tool arguments, but Inkling's payload is the {"name":...,"args":{...}} wrapper — without a converter, _compute_arg_delta streams the wrapper verbatim into the OpenAI arguments field (converter is None -> raw delta, unconditionally; stream_arg_deltas=False does not stop it).
Why a hand-rolled scanner instead of (partial) json.loads + json.dumps: the engine diffs successive converter outputs and requires each to extend the previous one (startswith); a violation silently drops argument deltas. Re-serialization changes whitespace and closes unterminated structures differently across ticks, so the only prefix-stable output is a verbatim substring of the input. The scanner is also string/escape-aware so an "args" literal inside the name or a string value cannot mislead it, and it still recovers a partial span when EOS truncates the wrapper (where json.loads would fail).
Source code in vllm/parser/inkling.py
_scan_json_value(raw, start) ¶
Return the end index (exclusive) of the JSON object starting at raw[start], or None when the object is still unterminated.