vllm.parser.response_template
¶
Unified vLLM parser backed by checkpoint response_template metadata.
Classes:
-
ResponseTemplateParser–Parse reasoning, content, and tool calls with one response template.
-
ResponseTemplateReasoningParser–Reasoning end detection for
--reasoning-parser hf. -
ResponseTemplateToolParser–Registers
--tool-call-parser hf;ResponseTemplateParserextracts the
Functions:
-
resolve_response_template–Return
templateif given, otherwise the tokenizer's metadata. -
validate_response_template_for_serving–Validate the template and reject semantic fields serving cannot route.
-
validate_tokenizer_response_template–Fail at startup if the tokenizer cannot serve the requested parsing.
ResponseTemplateParser
¶
Bases: Parser
Parse reasoning, content, and tool calls with one response template.
Source code in vllm/parser/response_template.py
501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 | |
ResponseTemplateReasoningParser
¶
Bases: ReasoningParser
Reasoning end detection for --reasoning-parser hf.
ResponseTemplateParser parses the output; this parser tells it and the
structured-output engine where reasoning ends.
Source code in vllm/parser/response_template.py
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 | |
ResponseTemplateToolParser
¶
Bases: ToolParser
Registers --tool-call-parser hf; ResponseTemplateParser extracts the
tool calls.
Source code in vllm/parser/response_template.py
_DeltaBuilder
¶
Accumulates one DeltaMessage.
Source code in vllm/parser/response_template.py
_ResponseStream
¶
One generation fed through ResponseParser, routed to message deltas.
Source code in vllm/parser/response_template.py
_route_tool_event(event, delta)
¶
Emit the calls of a tool region once it ends and parses; a region cut off at the end of the stream is parsed as generated. With tool parsing disabled, the region passes through as content.
Source code in vllm/parser/response_template.py
_as_tool_dicts(tools)
¶
Responses function tools with flattened namespaces, plus chat tools.
Source code in vllm/parser/response_template.py
_ends_within(token_ids, end_ids, num_new)
¶
Whether end_ids completes within the last num_new of token_ids.
Source code in vllm/parser/response_template.py
_literal_ids(tokenizer, vocab, literals)
¶
Token ids of each literal, or None when one encodes to nothing.
Source code in vllm/parser/response_template.py
_reasoning_end_ids(tokenizer, vocab, template)
¶
Token ids of each thinking closer, or None when they are not all
literal.
Source code in vllm/parser/response_template.py
_serving_template(tokenizer, template)
¶
The validated streaming form of template or the tokenizer's metadata.
Source code in vllm/parser/response_template.py
_to_tool_calls(value)
¶
(name, arguments) of each call in a tool region value, or nothing if
any call is incomplete.
Source code in vllm/parser/response_template.py
_unsupported_tool_guarantee(request)
¶
The first requested tool guarantee this parser cannot enforce, with the request parameter that asked for it.
Source code in vllm/parser/response_template.py
resolve_response_template(tokenizer, template=None)
¶
Return template if given, otherwise the tokenizer's metadata.
Source code in vllm/parser/response_template.py
validate_response_template_for_serving(template)
¶
Validate the template and reject semantic fields serving cannot route.
Source code in vllm/parser/response_template.py
validate_tokenizer_response_template(tokenizer, *, reasoning, tools)
¶
Fail at startup if the tokenizer cannot serve the requested parsing.