Unverified Commit 939ede86 authored by Neal Vaidya's avatar Neal Vaidya Committed by GitHub
Browse files

fix: no reasoning parser by default (#2939)


Signed-off-by: default avatarNeal Vaidya <nealv@nvidia.com>
parent 8e4ae22b
...@@ -45,7 +45,7 @@ DYNAMO_ARGS: Dict[str, Dict[str, Any]] = { ...@@ -45,7 +45,7 @@ DYNAMO_ARGS: Dict[str, Dict[str, Any]] = {
"type": str, "type": str,
"default": None, "default": None,
"choices": get_reasoning_parser_names(), "choices": get_reasoning_parser_names(),
"help": "Reasoning parser name for the model.", "help": "Reasoning parser name for the model. If not specified, no reasoning parsing is performed.",
}, },
} }
......
...@@ -283,7 +283,7 @@ def cmd_line_args(): ...@@ -283,7 +283,7 @@ def cmd_line_args():
type=str, type=str,
default=None, default=None,
choices=get_reasoning_parser_names(), choices=get_reasoning_parser_names(),
help="Reasoning parser name for the model.", help="Reasoning parser name for the model. If not specified, no reasoning parsing is performed.",
) )
args = parser.parse_args() args = parser.parse_args()
......
...@@ -114,7 +114,7 @@ def parse_args() -> Config: ...@@ -114,7 +114,7 @@ def parse_args() -> Config:
type=str, type=str,
default=None, default=None,
choices=get_reasoning_parser_names(), choices=get_reasoning_parser_names(),
help="Reasoning parser name for the model.", help="Reasoning parser name for the model. If not specified, no reasoning parsing is performed.",
) )
parser.add_argument( parser.add_argument(
"--custom-jinja-template", "--custom-jinja-template",
......
...@@ -64,7 +64,8 @@ pub struct DeltaGenerator { ...@@ -64,7 +64,8 @@ pub struct DeltaGenerator {
/// Reasoning Parser object /// Reasoning Parser object
/// This is used to parse reasoning content in the response. /// This is used to parse reasoning content in the response.
reasoning_parser: ReasoningParserWrapper, /// None means no reasoning parsing will be performed.
reasoning_parser: Option<ReasoningParserWrapper>,
} }
impl DeltaGenerator { impl DeltaGenerator {
...@@ -96,17 +97,12 @@ impl DeltaGenerator { ...@@ -96,17 +97,12 @@ impl DeltaGenerator {
}; };
// Reasoning parser type // Reasoning parser type
// This is hardcoded for now, but can be made configurable later. // If no parser is specified (None), no reasoning parsing will be performed
// TODO: Make parser type configurable once front-end integration is determined let reasoning_parser = options
// Change to GptOss to test GptOSS parser .runtime_config
// Reasoning parser wrapper .reasoning_parser
let reasoning_parser = ReasoningParserType::get_reasoning_parser_from_name( .as_deref()
options .map(ReasoningParserType::get_reasoning_parser_from_name);
.runtime_config
.reasoning_parser
.as_deref()
.unwrap_or("basic"),
);
let chatcmpl_id = format!("chatcmpl-{request_id}"); let chatcmpl_id = format!("chatcmpl-{request_id}");
...@@ -202,13 +198,15 @@ impl DeltaGenerator { ...@@ -202,13 +198,15 @@ impl DeltaGenerator {
text: &Option<String>, text: &Option<String>,
token_ids: &[u32], token_ids: &[u32],
) -> Option<ParserResult> { ) -> Option<ParserResult> {
// If no reasoning parser is configured, return None
let reasoning_parser = self.reasoning_parser.as_mut()?;
let text_ref = text.as_deref().unwrap_or(""); let text_ref = text.as_deref().unwrap_or("");
if text_ref.is_empty() && token_ids.is_empty() { if text_ref.is_empty() && token_ids.is_empty() {
return None; return None;
} }
let parser_result = self let parser_result =
.reasoning_parser reasoning_parser.parse_reasoning_streaming_incremental(text_ref, token_ids);
.parse_reasoning_streaming_incremental(text_ref, token_ids);
Some(parser_result) Some(parser_result)
} }
...@@ -334,14 +332,15 @@ impl crate::protocols::openai::DeltaGeneratorExt<NvCreateChatCompletionStreamRes ...@@ -334,14 +332,15 @@ impl crate::protocols::openai::DeltaGeneratorExt<NvCreateChatCompletionStreamRes
None => None, None => None,
}; };
let reasoning_parser_result = self // Handle reasoning parsing if enabled, otherwise treat all text as normal
.create_reasoning_content(&delta.text, &delta.token_ids) let (normal_text, reasoning_content) =
.unwrap_or_default(); match self.create_reasoning_content(&delta.text, &delta.token_ids) {
Some(reasoning_parser_result) => (
let (normal_text, reasoning_content) = ( reasoning_parser_result.get_some_normal_text(),
reasoning_parser_result.get_some_normal_text(), reasoning_parser_result.get_some_reasoning(),
reasoning_parser_result.get_some_reasoning(), ),
); None => (delta.text, None),
};
// Create the streaming response. // Create the streaming response.
let index = 0; let index = 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment