Skip to content

Commit 7148426

Browse files
nealvaidyatedzhouhk
authored andcommitted
fix: no reasoning parser by default (#2939)
Signed-off-by: Neal Vaidya <[email protected]> Signed-off-by: hongkuanz <[email protected]>
1 parent b19deaf commit 7148426

File tree

4 files changed

+25
-26
lines changed

4 files changed

+25
-26
lines changed

components/backends/sglang/src/dynamo/sglang/args.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"type": str,
4646
"default": None,
4747
"choices": get_reasoning_parser_names(),
48-
"help": "Reasoning parser name for the model.",
48+
"help": "Reasoning parser name for the model. If not specified, no reasoning parsing is performed.",
4949
},
5050
}
5151

components/backends/trtllm/src/dynamo/trtllm/utils/trtllm_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ def cmd_line_args():
291291
type=str,
292292
default=None,
293293
choices=get_reasoning_parser_names(),
294-
help="Reasoning parser name for the model.",
294+
help="Reasoning parser name for the model. If not specified, no reasoning parsing is performed.",
295295
)
296296

297297
args = parser.parse_args()

components/backends/vllm/src/dynamo/vllm/args.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def parse_args() -> Config:
114114
type=str,
115115
default=None,
116116
choices=get_reasoning_parser_names(),
117-
help="Reasoning parser name for the model.",
117+
help="Reasoning parser name for the model. If not specified, no reasoning parsing is performed.",
118118
)
119119
parser.add_argument(
120120
"--custom-jinja-template",

lib/llm/src/protocols/openai/chat_completions/delta.rs

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ pub struct DeltaGenerator {
6464

6565
/// Reasoning Parser object
6666
/// This is used to parse reasoning content in the response.
67-
reasoning_parser: ReasoningParserWrapper,
67+
/// None means no reasoning parsing will be performed.
68+
reasoning_parser: Option<ReasoningParserWrapper>,
6869
}
6970

7071
impl DeltaGenerator {
@@ -96,17 +97,12 @@ impl DeltaGenerator {
9697
};
9798

9899
// Reasoning parser type
99-
// This is hardcoded for now, but can be made configurable later.
100-
// TODO: Make parser type configurable once front-end integration is determined
101-
// Change to GptOss to test GptOSS parser
102-
// Reasoning parser wrapper
103-
let reasoning_parser = ReasoningParserType::get_reasoning_parser_from_name(
104-
options
105-
.runtime_config
106-
.reasoning_parser
107-
.as_deref()
108-
.unwrap_or("basic"),
109-
);
100+
// If no parser is specified (None), no reasoning parsing will be performed
101+
let reasoning_parser = options
102+
.runtime_config
103+
.reasoning_parser
104+
.as_deref()
105+
.map(ReasoningParserType::get_reasoning_parser_from_name);
110106

111107
let chatcmpl_id = format!("chatcmpl-{request_id}");
112108

@@ -202,13 +198,15 @@ impl DeltaGenerator {
202198
text: &Option<String>,
203199
token_ids: &[u32],
204200
) -> Option<ParserResult> {
201+
// If no reasoning parser is configured, return None
202+
let reasoning_parser = self.reasoning_parser.as_mut()?;
203+
205204
let text_ref = text.as_deref().unwrap_or("");
206205
if text_ref.is_empty() && token_ids.is_empty() {
207206
return None;
208207
}
209-
let parser_result = self
210-
.reasoning_parser
211-
.parse_reasoning_streaming_incremental(text_ref, token_ids);
208+
let parser_result =
209+
reasoning_parser.parse_reasoning_streaming_incremental(text_ref, token_ids);
212210

213211
Some(parser_result)
214212
}
@@ -334,14 +332,15 @@ impl crate::protocols::openai::DeltaGeneratorExt<NvCreateChatCompletionStreamRes
334332
None => None,
335333
};
336334

337-
let reasoning_parser_result = self
338-
.create_reasoning_content(&delta.text, &delta.token_ids)
339-
.unwrap_or_default();
340-
341-
let (normal_text, reasoning_content) = (
342-
reasoning_parser_result.get_some_normal_text(),
343-
reasoning_parser_result.get_some_reasoning(),
344-
);
335+
// Handle reasoning parsing if enabled, otherwise treat all text as normal
336+
let (normal_text, reasoning_content) =
337+
match self.create_reasoning_content(&delta.text, &delta.token_ids) {
338+
Some(reasoning_parser_result) => (
339+
reasoning_parser_result.get_some_normal_text(),
340+
reasoning_parser_result.get_some_reasoning(),
341+
),
342+
None => (delta.text, None),
343+
};
345344

346345
// Create the streaming response.
347346
let index = 0;

0 commit comments

Comments
 (0)