From d2d47d0e0e2cb3ff06b0f5c44b13a0a8437a575c Mon Sep 17 00:00:00 2001 From: takatost Date: Sat, 16 Mar 2024 15:09:47 +0800 Subject: [PATCH] fix bug --- api/core/workflow/entities/workflow_entities.py | 5 ++++- api/core/workflow/workflow_engine_manager.py | 5 ++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/api/core/workflow/entities/workflow_entities.py b/api/core/workflow/entities/workflow_entities.py index a78bf09a531c14..e1c5eb6752cdf9 100644 --- a/api/core/workflow/entities/workflow_entities.py +++ b/api/core/workflow/entities/workflow_entities.py @@ -28,7 +28,7 @@ class WorkflowRunState: total_tokens: int = 0 - workflow_nodes_and_results: list[WorkflowNodeAndResult] = [] + workflow_nodes_and_results: list[WorkflowNodeAndResult] def __init__(self, workflow: Workflow, start_at: float, @@ -44,3 +44,6 @@ def __init__(self, workflow: Workflow, self.start_at = start_at self.variable_pool = variable_pool + + self.total_tokens = 0 + self.workflow_nodes_and_results = [] diff --git a/api/core/workflow/workflow_engine_manager.py b/api/core/workflow/workflow_engine_manager.py index 99373de39355f2..143533810e2a94 100644 --- a/api/core/workflow/workflow_engine_manager.py +++ b/api/core/workflow/workflow_engine_manager.py @@ -272,7 +272,6 @@ def single_step_run_workflow_node(self, workflow: Workflow, return node_instance, node_run_result - def _workflow_run_success(self, callbacks: list[BaseWorkflowCallback] = None) -> None: """ Workflow run success @@ -337,7 +336,8 @@ def _get_next_node(self, workflow_run_state: WorkflowRunState, # fetch target node id from outgoing edges outgoing_edge = None - source_handle = predecessor_node.node_run_result.edge_source_handle + source_handle = predecessor_node.node_run_result.edge_source_handle \ + if predecessor_node.node_run_result else None if source_handle: for edge in outgoing_edges: if edge.get('source_handle') and edge.get('source_handle') == source_handle: @@ -464,7 +464,6 @@ def _run_workflow_node(self, workflow_run_state: WorkflowRunState, db.session.close() - def _append_variables_recursively(self, variable_pool: VariablePool, node_id: str, variable_key_list: list[str],