From 19b6927320a5fc5608f426dfc37d098b611c1e73 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Tue, 25 Feb 2025 12:42:15 +0800 Subject: [PATCH] fix workflow process --- app/chain/workflow.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/chain/workflow.py b/app/chain/workflow.py index 0e49f140..50facaf2 100644 --- a/app/chain/workflow.py +++ b/app/chain/workflow.py @@ -28,6 +28,8 @@ class WorkflowChain(ChainBase): :param from_begin: 是否从头开始,默认为True """ + _init_action = None + def __get_next_action(_workflow: Workflow, _action: str) -> List[Action]: """ 获取下一个动作 @@ -42,7 +44,7 @@ class WorkflowChain(ChainBase): actions.append(Action(**act)) return actions else: - if _action == _workflow.current_action: + if _action == _init_action: # 返回当前动作 action_ids = _action.split(',') return [Action(**act) for act in _workflow.actions if act.id in action_ids] @@ -67,6 +69,7 @@ class WorkflowChain(ChainBase): # 启用上下文 if not from_begin and workflow.current_action: + _init_action = workflow.current_action context = ActionContext(**workflow.context) else: context = ActionContext() @@ -74,7 +77,7 @@ class WorkflowChain(ChainBase): if from_begin: current_action = None else: - current_action = workflow.current_action + current_action = _init_action # 循环执行 while next_actions := __get_next_action(workflow, current_action):