[WIP] support MiniMax M2 model (#12129)
Signed-off-by: Xinyuan Tong <xinyuantong.cs@gmail.com> Signed-off-by: xuebi <xuebi@minimaxi.com> Co-authored-by: Xinyuan Tong <xinyuantong.cs@gmail.com> Co-authored-by: Xinyuan Tong <115166877+JustinTong0323@users.noreply.github.com> Co-authored-by: Roger Young <42564206+rogeryoungh@users.noreply.github.com> Co-authored-by: xuebi <xuebi@minimaxi.com>
This commit is contained in:
@@ -249,6 +249,31 @@ class GptOssDetector(BaseReasoningFormatDetector):
|
||||
)
|
||||
|
||||
|
||||
class MiniMaxAppendThinkDetector(BaseReasoningFormatDetector):
|
||||
"""
|
||||
Append `<think>` token to the beginning of the text.
|
||||
"""
|
||||
|
||||
def __init__(self, stream_reasoning: bool = True, force_reasoning: bool = False):
|
||||
# scheduler.py need `reasoning_parser.detector.think_end_token`
|
||||
super().__init__(
|
||||
"<think>",
|
||||
"</think>",
|
||||
force_reasoning=force_reasoning,
|
||||
stream_reasoning=stream_reasoning,
|
||||
)
|
||||
self.is_first_chunk = False
|
||||
|
||||
def parse_streaming_increment(self, new_text: str) -> StreamingParseResult:
|
||||
if not self.is_first_chunk:
|
||||
self.is_first_chunk = True
|
||||
new_text = self.think_start_token + new_text
|
||||
return StreamingParseResult(normal_text=new_text)
|
||||
|
||||
def detect_and_parse(self, text: str) -> StreamingParseResult:
|
||||
return StreamingParseResult(normal_text=self.think_start_token + text)
|
||||
|
||||
|
||||
class ReasoningParser:
|
||||
"""
|
||||
Parser that handles both streaming and non-streaming scenarios for extracting
|
||||
@@ -268,6 +293,8 @@ class ReasoningParser:
|
||||
"kimi": KimiDetector,
|
||||
"qwen3": Qwen3Detector,
|
||||
"qwen3-thinking": Qwen3Detector,
|
||||
"minimax": Qwen3Detector,
|
||||
"minimax-append-think": MiniMaxAppendThinkDetector,
|
||||
"step3": DeepSeekR1Detector,
|
||||
}
|
||||
|
||||
@@ -285,7 +312,7 @@ class ReasoningParser:
|
||||
raise ValueError(f"Unsupported model type: {model_type}")
|
||||
|
||||
# Special cases where we override force_reasoning
|
||||
if model_type.lower() in {"qwen3-thinking", "gpt-oss"}:
|
||||
if model_type.lower() in {"qwen3-thinking", "gpt-oss", "minimax"}:
|
||||
force_reasoning = True
|
||||
|
||||
# Only pass force_reasoning if explicitly set, let detectors use their defaults
|
||||
|
||||
Reference in New Issue
Block a user