Feat: add support for thinking mode via chat_template_kwargs.enable_t… (#5551)
Co-authored-by: shuaills <shishuaiuoe@gmail.com> Co-authored-by: Chayenne <zhaochen20@outlook.com> Co-authored-by: Lianmin Zheng <lianminzheng@gmail.com> Co-authored-by: Yineng Zhang <me@zhyncs.com>
This commit is contained in:
@@ -117,6 +117,29 @@ class DeepSeekR1Detector(BaseReasoningFormatDetector):
|
||||
# https://github.com/sgl-project/sglang/pull/3202#discussion_r1950153599
|
||||
|
||||
|
||||
class Qwen3Detector(BaseReasoningFormatDetector):
|
||||
"""
|
||||
Detector for Qwen3 model.
|
||||
Assumes reasoning format:
|
||||
(<think>)*(.*)</think>
|
||||
Returns all the text before the </think> tag as `reasoning_text`
|
||||
and the rest of the text as `normal_text`.
|
||||
|
||||
Args:
|
||||
stream_reasoning (bool): If False, accumulates reasoning content until the end tag.
|
||||
If True, streams reasoning content as it arrives.
|
||||
"""
|
||||
|
||||
def __init__(self, stream_reasoning: bool = True):
|
||||
# Qwen3 is assumed to be reasoning until `</think>` token
|
||||
super().__init__(
|
||||
"<think>",
|
||||
"</think>",
|
||||
force_reasoning=True,
|
||||
stream_reasoning=stream_reasoning,
|
||||
)
|
||||
|
||||
|
||||
class ReasoningParser:
|
||||
"""
|
||||
Parser that handles both streaming and non-streaming scenarios for extracting
|
||||
@@ -129,7 +152,8 @@ class ReasoningParser:
|
||||
"""
|
||||
|
||||
DetectorMap: Dict[str, BaseReasoningFormatDetector] = {
|
||||
"deepseek-r1": DeepSeekR1Detector
|
||||
"deepseek-r1": DeepSeekR1Detector,
|
||||
"qwen3": Qwen3Detector,
|
||||
}
|
||||
|
||||
def __init__(self, model_type: str = None, stream_reasoning: bool = True):
|
||||
|
||||
Reference in New Issue
Block a user