[V1] Structured Outputs + Thinking compatibility (#16577)

Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
Co-authored-by: Russell Bryant <rbryant@redhat.com>
This commit is contained in:
Aaron Pham
2025-05-14 18:45:24 -04:00
committed by GitHub
parent d93c976a0d
commit 2fc9075b82
10 changed files with 233 additions and 75 deletions

View File

@@ -1,5 +1,7 @@
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import os
from abc import abstractmethod
from collections.abc import Sequence
@@ -33,7 +35,7 @@ class ReasoningParser:
return self.model_tokenizer.get_vocab()
@abstractmethod
def is_reasoning_end(self, input_ids: list[int]) -> bool:
def is_reasoning_end(self, input_ids: Sequence[int]) -> bool:
"""
Check if the reasoning content ends in the input_ids.
@@ -106,7 +108,7 @@ class ReasoningParserManager:
reasoning_parsers: dict[str, type] = {}
@classmethod
def get_reasoning_parser(cls, name) -> type:
def get_reasoning_parser(cls, name: str | None) -> type[ReasoningParser]:
"""
Get reasoning parser by name which is registered by `register_module`.