| 1 | # SPDX-License-Identifier: Apache-2.0 |
| 2 | # SPDX-FileCopyrightText: Copyright contributors to the vLLM project |
| 3 | |
| 4 | from vllm.reasoning.abs_reasoning_parsers import ReasoningParser, ReasoningParserManager |
| 5 | |
| 6 | __all__ = [ |
| 7 | "ReasoningParser", |
| 8 | "ReasoningParserManager", |
| 9 | ] |
| 10 | """ |
| 11 | Register a lazy module mapping. |
| 12 | |
| 13 | Example: |
| 14 | ReasoningParserManager.register_lazy_module( |
| 15 | name="qwen3", |
| 16 | module_path="vllm.reasoning.qwen3_engine_reasoning_parser", |
| 17 | class_name="Qwen3ParserReasoningAdapter", |
| 18 | ) |
| 19 | """ |
| 20 | |
| 21 | |
| 22 | _REASONING_PARSERS_TO_REGISTER = { |
| 23 | "deepseek_r1": ( # name |
| 24 | "deepseek_r1_reasoning_parser", # filename |
| 25 | "DeepSeekR1ReasoningParser", # class_name |
| 26 | ), |
| 27 | "deepseek_v3": ( |
| 28 | "deepseek_v3_reasoning_parser", |
| 29 | "DeepSeekV3ReasoningParser", |
| 30 | ), |
| 31 | "deepseek_v4": ( |
| 32 | "deepseek_v4_engine_reasoning_parser", |
| 33 | "DeepSeekV4ParserReasoningAdapter", |
| 34 | ), |
| 35 | "deepseek_v41": ( |
| 36 | "deepseek_v41_engine_reasoning_parser", |
| 37 | "DeepSeekV41ParserReasoningAdapter", |
| 38 | ), |
| 39 | "poolside_v1": ( |
| 40 | "poolside_v1_reasoning_parser", |
| 41 | "PoolsideV1ReasoningParser", |
| 42 | ), |
| 43 | "cohere_command3": ( |
| 44 | "cohere_command_reasoning_parser", |
| 45 | "CohereCommand3ReasoningParser", |
| 46 | ), |
| 47 | "cohere_command4": ( |
| 48 | "cohere_command_reasoning_parser", |
| 49 | "CohereCommand4ReasoningParser", |
| 50 | ), |
| 51 | "ernie45": ( |
| 52 | "ernie45_reasoning_parser", |
| 53 | "Ernie45ReasoningParser", |
| 54 | ), |
| 55 | "gemma4": ( |
| 56 | "gemma4_engine_reasoning_parser", |
| 57 | "Gemma4ParserReasoningAdapter", |
| 58 | ), |
| 59 | "glm45": ( |
| 60 | "glm47_moe_reasoning_parser", |
| 61 | "Glm47MoeParserReasoningAdapter", |
| 62 | ), |
| 63 | "glm47": ( |
| 64 | "glm47_moe_reasoning_parser", |
| 65 | "Glm47MoeParserReasoningAdapter", |
| 66 | ), |
| 67 | "ling3": ( |
| 68 | "ling3_reasoning_parser", |
| 69 | "Ling3ParserReasoningAdapter", |
| 70 | ), |
| 71 | "openai_gptoss": ( |
| 72 | "gptoss_reasoning_parser", |
| 73 | "GptOssReasoningParser", |
| 74 | ), |
| 75 | "granite": ( |
| 76 | "granite_reasoning_parser", |
| 77 | "GraniteReasoningParser", |
| 78 | ), |
| 79 | "granite_thinking_parser": ( |
| 80 | "granite_thinking_engine_reasoning_parser", |
| 81 | "GraniteThinkingParserReasoningAdapter", |
| 82 | ), |
| 83 | "hf": ( |
| 84 | "response_template_reasoning_parser", |
| 85 | "ResponseTemplateReasoningParser", |
| 86 | ), |
| 87 | "holo2": ( |
| 88 | "deepseek_v3_reasoning_parser", |
| 89 | "DeepSeekV3ReasoningWithThinkingParser", |
| 90 | ), |
| 91 | "hunyuan_a13b": ( |
| 92 | "hunyuan_a13b_reasoning_parser", |
| 93 | "HunyuanA13BReasoningParser", |
| 94 | ), |
| 95 | "hy_v3": ( |
| 96 | "hy_v3_reasoning_parser", |
| 97 | "HYV3ReasoningParser", |
| 98 | ), |
| 99 | "hy_v4": ( |
| 100 | "hy_v4_reasoning_parser", |
| 101 | "HYV4ReasoningParser", |
| 102 | ), |
| 103 | "kimi_k2": ( |
| 104 | "kimi_k2_reasoning_parser", |
| 105 | "KimiK2ReasoningParser", |
| 106 | ), |
| 107 | "kimi_k3": ( |
| 108 | "kimi_k3_reasoning_parser", |
| 109 | "KimiK3ReasoningParser", |
| 110 | ), |
| 111 | "k2_horizon": ( |
| 112 | "k2_horizon_reasoning_parser", |
| 113 | "K2HorizonReasoningParser", |
| 114 | ), |
| 115 | "mimo": ( |
| 116 | "mimo_engine_reasoning_parser", |
| 117 | "MiMoParserReasoningAdapter", |
| 118 | ), |
| 119 | "minimax_m2": ( |
| 120 | "minimax_m2_reasoning_parser", |
| 121 | "MiniMaxM2ReasoningParser", |
| 122 | ), |
| 123 | "minimax_m2_append_think": ( |
| 124 | "minimax_m2_reasoning_parser", |
| 125 | "MiniMaxM2AppendThinkReasoningParser", |
| 126 | ), |
| 127 | "minimax_m3": ( |
| 128 | "minimax_m3_reasoning_parser", |
| 129 | "MiniMaxM3ReasoningParser", |
| 130 | ), |
| 131 | "mistral": ( |
| 132 | "mistral_reasoning_parser", |
| 133 | "MistralParserReasoningAdapter", |
| 134 | ), |
| 135 | "nemotron_v3": ( |
| 136 | "nemotron_v3_engine_reasoning_parser", |
| 137 | "NemotronV3ParserReasoningAdapter", |
| 138 | ), |
| 139 | "olmo3": ( |
| 140 | "olmo3_reasoning_parser", |
| 141 | "Olmo3ReasoningParser", |
| 142 | ), |
| 143 | "plamo3": ( |
| 144 | "plamo3_engine_reasoning_parser", |
| 145 | "Plamo3ParserReasoningAdapter", |
| 146 | ), |
| 147 | "muse_glimmer": ( |
| 148 | "muse_glimmer_reasoning_parser", |
| 149 | "MuseGlimmerReasoningParser", |
| 150 | ), |
| 151 | "qwen3": ( |
| 152 | "qwen3_engine_reasoning_parser", |
| 153 | "Qwen3ParserReasoningAdapter", |
| 154 | ), |
| 155 | "seed_oss": ( |
| 156 | "seed_oss_engine_reasoning_parser", |
| 157 | "SeedOssParserReasoningAdapter", |
| 158 | ), |
| 159 | "step3": ( |
| 160 | "step3_reasoning_parser", |
| 161 | "Step3ReasoningParser", |
| 162 | ), |
| 163 | "step3p5": ( |
| 164 | "step3p5_engine_reasoning_parser", |
| 165 | "Step3p5ParserReasoningAdapter", |
| 166 | ), |
| 167 | "inkling": ( |
| 168 | "inkling_reasoning_parser", |
| 169 | "InklingParserReasoningAdapter", |
| 170 | ), |
| 171 | } |
| 172 | |
| 173 | |
| 174 | def register_lazy_reasoning_parsers(): |
| 175 | for name, (file_name, class_name) in _REASONING_PARSERS_TO_REGISTER.items(): |
| 176 | module_path = f"vllm.reasoning.{file_name}" |
| 177 | ReasoningParserManager.register_lazy_module(name, module_path, class_name) |
| 178 | |
| 179 | |
| 180 | register_lazy_reasoning_parsers() |