[Bugfix][Structured Output] Mask grammar-invalid implicit reasoning ends (#61574)
Signed-off-by: Maroon Ayoub <mayoub@redhat.com> Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Robert Shaw <114415538+robertgshaw2-redhat@users.noreply.github.com>
This commit is contained in:
co-authored by
Claude
Robert Shaw
parent
92dc3dd393
commit
4ac1f8d2ac
@@ -678,6 +678,11 @@ class ParserEngine(Parser):
|
||||
def reasoning_end_token_ids(self) -> frozenset[int]:
|
||||
return self._reasoning_end_token_ids
|
||||
|
||||
@property
|
||||
def implicit_reasoning_end_token_ids(self) -> frozenset[int]:
|
||||
"""Reasoning-end tokens that are also content, e.g. a tool-call start."""
|
||||
return self._reasoning_end_token_ids - {self._reasoning_end_token_id}
|
||||
|
||||
def find_reasoning_end(self, token_ids: Sequence[int]) -> ReasoningEnd | None:
|
||||
"""First reasoning end in `token_ids`, and if its token is content."""
|
||||
end_ids = self._reasoning_end_token_ids
|
||||
|
||||
Reference in New Issue
Block a user