Add NanoV3 reasoning parser support (#15113)

This commit is contained in:
danielafrimi
2025-12-14 22:09:44 +02:00
committed by GitHub
parent 3f0482174a
commit 8102e36b5d
2 changed files with 19 additions and 2 deletions

View File

@@ -1065,8 +1065,8 @@ class OpenAIServingChat(OpenAIServingBase):
request.chat_template_kwargs is not None
and request.chat_template_kwargs.get("thinking") is True
)
if self.reasoning_parser in ["qwen3", "glm45"]:
# qwen3 and glm45 are reasoning by default
if self.reasoning_parser in ["qwen3", "glm45", "nano_v3"]:
# qwen3, glm45, and nano_v3 are reasoning by default
return (
not request.chat_template_kwargs
or request.chat_template_kwargs.get("enable_thinking", True) is True

View File

@@ -274,6 +274,22 @@ class MiniMaxAppendThinkDetector(BaseReasoningFormatDetector):
return StreamingParseResult(normal_text=self.think_start_token + text)
class NanoV3Detector(BaseReasoningFormatDetector):
"""
Detector for NanoV3 model.
Uses the same reasoning format as DeepSeek-R1: (<think>)*(.*)</think>
"""
def __init__(self, stream_reasoning: bool = True, force_reasoning: bool = False):
super().__init__(
"<think>",
"</think>",
force_reasoning=force_reasoning,
stream_reasoning=stream_reasoning,
)
class ReasoningParser:
"""
Parser that handles both streaming and non-streaming scenarios for extracting
@@ -297,6 +313,7 @@ class ReasoningParser:
"minimax": Qwen3Detector,
"minimax-append-think": MiniMaxAppendThinkDetector,
"step3": DeepSeekR1Detector,
"nano_v3": NanoV3Detector,
}
def __init__(