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.

fix: avoid llm node result var not init issue while do retry. (#14286)

Jacky Wued5596a8f45a
diff --git a/api/core/workflow/nodes/llm/node.py b/api/core/workflow/nodes/llm/node.py
index b61b5b5cb5c..fe0ed3e5645 100644
--- a/api/core/workflow/nodes/llm/node.py
+++ b/api/core/workflow/nodes/llm/node.py
@@ -94,6 +94,9 @@ class LLMNode(BaseNode[LLMNodeData]):
def _run(self) -> Generator[NodeEvent | InNodeEvent, None, None]:
node_inputs: Optional[dict[str, Any]] = None
process_data = None
+ result_text = ""
+ usage = LLMUsage.empty_usage()
+ finish_reason = None
try:
# init messages template
@@ -178,9 +181,6 @@ class LLMNode(BaseNode[LLMNodeData]):
stop=stop,
)
- result_text = ""
- usage = LLMUsage.empty_usage()
- finish_reason = None
for event in generator:
if isinstance(event, RunStreamChunkEvent):
yield event