Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ def _wrap_thinking_by_reasoning_content(self, delta: dict, is_reasoning: bool) -
"""

content = delta.get("content") or ""
reasoning_content = delta.get("reasoning_content")
reasoning_content = delta.get("reasoning_content") or delta.get("reasoning")
Comment thread
lockdown56 marked this conversation as resolved.
output = content
if reasoning_content:
if not is_reasoning:
Expand Down
2 changes: 1 addition & 1 deletion python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "dify_plugin"
version = "0.7.4"
version = "0.7.5"
description = "Dify Plugin SDK"
authors = [{ name = "langgenius", email = "hello@dify.ai" }]
dependencies = [
Expand Down
30 changes: 30 additions & 0 deletions python/tests/interfaces/model/test_wrap_think.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,33 @@ def test_standard_reasoning_flow(self):
full_output += output

assert full_output == "<think>\nThinking.\n</think>Hello world."

def test_reasoning_key_fallback(self):
"""
Test that delta.get("reasoning") is used when reasoning_content is absent.
Line 538: reasoning_content = delta.get("reasoning_content") or delta.get("reasoning")
"""
chunks = [
{"reasoning": "Using reasoning key.", "content": ""},
{"reasoning": None, "content": "Response text."},
]

is_reasoning = False
full_output = ""
for chunk in chunks:
output, is_reasoning = self.llm._wrap_thinking_by_reasoning_content(chunk, is_reasoning)
full_output += output

assert full_output == "<think>\nUsing reasoning key.\n</think>Response text."

def test_reasoning_content_takes_precedence_over_reasoning(self):
"""
Test that reasoning_content takes precedence when both keys exist.
Line 538: reasoning_content = delta.get("reasoning_content") or delta.get("reasoning")
"""
chunk = {"reasoning_content": "Primary.", "reasoning": "Fallback.", "content": ""}
output, is_reasoning = self.llm._wrap_thinking_by_reasoning_content(chunk, False)

assert "Primary." in output
assert "Fallback." not in output
assert is_reasoning is True