Skip to content

Commit 95c0f92

Browse files
roikoren755khluu
authored andcommitted
[NemotronH] Small fix reasoning parser (#36635)
Signed-off-by: Roi Koren <roik@nvidia.com> (cherry picked from commit e661b9e)
1 parent c9b1e97 commit 95c0f92

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

tests/reasoning/test_nemotron_v3_reasoning_parser.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,28 @@ def test_nemotron_v3_without_thinking_returns_content(
128128
assert content == "This is plain content"
129129

130130

131+
def test_nemotron_v3_force_nonempty_content_returns_content(
132+
tokenizer: FakeNemotronTokenizer,
133+
):
134+
parser_cls = ReasoningParserManager.get_reasoning_parser(parser_name)
135+
parser = parser_cls(tokenizer)
136+
request = ChatCompletionRequest(
137+
model="test-model",
138+
messages=[],
139+
chat_template_kwargs={"force_nonempty_content": True},
140+
)
141+
142+
reasoning, content = run_reasoning_extraction(
143+
parser,
144+
["<think>This is plain content"],
145+
request=request,
146+
streaming=False,
147+
)
148+
149+
assert reasoning is None
150+
assert content == "This is plain content"
151+
152+
131153
def test_nemotron_v3_with_thinking_keeps_truncated_reasoning(
132154
tokenizer: FakeNemotronTokenizer,
133155
):

vllm/reasoning/nemotron_v3_reasoning_parser.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ def extract_reasoning(
2424

2525
if (
2626
chat_template_kwargs
27-
and chat_template_kwargs.get("enable_thinking") is False
27+
and (
28+
chat_template_kwargs.get("enable_thinking") is False
29+
or chat_template_kwargs.get("force_nonempty_content") is True
30+
)
2831
and final_content is None
2932
):
3033
reasoning_content, final_content = final_content, reasoning_content

0 commit comments

Comments
 (0)