[Refactor][Mistral] Extract parsing logic into MistralParser (#44596)

Signed-off-by: sfeng33 <4florafeng@gmail.com>
This commit is contained in:
Flora Feng
2026-06-10 00:12:23 +00:00
committed by GitHub
parent dac9e9a640
commit d82ac00923
7 changed files with 136 additions and 729 deletions
+10 -1
View File
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
from collections.abc import Sequence
from collections.abc import Iterable, Sequence
from functools import cached_property
from typing import TYPE_CHECKING
@@ -76,6 +76,15 @@ class MistralReasoningParser(BaseThinkingReasoningParser):
has_eot_token = True
return False
def is_reasoning_end_streaming(
self, input_ids: Sequence[int], delta_ids: Iterable[int]
) -> bool:
if self.end_token_id in delta_ids:
return True
# Grammar's think? is optional — if [THINK] was never generated,
# reasoning was skipped entirely.
return self.start_token_id not in input_ids
def extract_content_ids(self, input_ids: list[int]) -> list[int]:
"""
Extract the content