Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

Non-Streaming Models Do Not Return Results Properly in _handle_invoke_result (#13571)

Vasu Negi8a0aa91ed7d0
diff --git a/api/core/workflow/nodes/llm/node.py b/api/core/workflow/nodes/llm/node.py
index 7e28aa7a3ff..9f30048fe61 100644
--- a/api/core/workflow/nodes/llm/node.py
+++ b/api/core/workflow/nodes/llm/node.py
@@ -247,6 +247,24 @@ class LLMNode(BaseNode[LLMNodeData]):
def _handle_invoke_result(self, invoke_result: LLMResult | Generator) -> Generator[NodeEvent, None, None]:
if isinstance(invoke_result, LLMResult):
+ content = invoke_result.message.content
+ if content is None:
+ message_text = ""
+ elif isinstance(content, str):
+ message_text = content
+ elif isinstance(content, list):
+ # Assuming the list contains PromptMessageContent objects with a "data" attribute
+ message_text = "".join(
+ item.data if hasattr(item, "data") and isinstance(item.data, str) else str(item) for item in content
+ )
+ else:
+ message_text = str(content)
+
+ yield ModelInvokeCompletedEvent(
+ text=message_text,
+ usage=invoke_result.usage,
+ finish_reason=None,
+ )
return
model = None