nano_v3_reasoning_parser.py
798 B · 19 lines · python Raw
1 from vllm.reasoning.abs_reasoning_parsers import ReasoningParserManager
2 from vllm.reasoning.deepseek_r1_reasoning_parser import DeepSeekR1ReasoningParser
3
4
5 @ReasoningParserManager.register_module("nano_v3")
6 class NanoV3ReasoningParser(DeepSeekR1ReasoningParser):
7 def extract_reasoning(self, model_output, request):
8 reasoning_content, final_content = super().extract_reasoning(
9 model_output, request
10 )
11 if (
12 hasattr(request, "chat_template_kwargs")
13 and request.chat_template_kwargs
14 and request.chat_template_kwargs.get("enable_thinking") is False
15 and final_content is None
16 ):
17 reasoning_content, final_content = final_content, reasoning_content
18
19 return reasoning_content, final_content