Unverified Commit 04f50ad9 authored by LikeSundayLikeRain's avatar LikeSundayLikeRain Committed by GitHub
Browse files

[Bugfix] deepseek_r1_reasoning_parser put reason content in wrong field in...

[Bugfix] deepseek_r1_reasoning_parser put reason content in wrong field in certain edge case (#13097)
parent 60c68df6
...@@ -24,10 +24,10 @@ COMPLETE_REASONING = { ...@@ -24,10 +24,10 @@ COMPLETE_REASONING = {
"reasoning_content": "This is a reasoning section", "reasoning_content": "This is a reasoning section",
"content": None, "content": None,
} }
NO_REASONING = { NO_CONTENT = {
"output": "This is content", "output": "This is content",
"reasoning_content": None, "reasoning_content": "This is content",
"content": "This is content", "content": None,
} }
NO_REASONING_STREAMING = { NO_REASONING_STREAMING = {
"output": "This is a reasoning section", "output": "This is a reasoning section",
...@@ -98,8 +98,8 @@ TEST_CASES = [ ...@@ -98,8 +98,8 @@ TEST_CASES = [
), ),
pytest.param( pytest.param(
False, False,
NO_REASONING, NO_CONTENT,
id="no_reasoning_token", id="no_content_token",
), ),
pytest.param( pytest.param(
True, True,
......
...@@ -128,7 +128,7 @@ class DeepSeekR1ReasoningParser(ReasoningParser): ...@@ -128,7 +128,7 @@ class DeepSeekR1ReasoningParser(ReasoningParser):
# Thus we assume the reasoning content is always at the start. # Thus we assume the reasoning content is always at the start.
# Ref https://huggingface.co/deepseek-ai/DeepSeek-R1/commit/8a58a132790c9935686eb97f042afa8013451c9f # Ref https://huggingface.co/deepseek-ai/DeepSeek-R1/commit/8a58a132790c9935686eb97f042afa8013451c9f
if self.think_end_token not in model_output: if self.think_end_token not in model_output:
return None, model_output return model_output, None
else: else:
# Add a start token if it's missing to keep compatibility. # Add a start token if it's missing to keep compatibility.
if self.think_start_token not in model_output: if self.think_start_token not in model_output:
......
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