Skip to content

Commit de3b0ef

Browse files
committed
fix: Workflow The condition setting 'any' did not take effect when the discriminator was executed
1 parent 301c60e commit de3b0ef

File tree

2 files changed

+24
-14
lines changed

2 files changed

+24
-14
lines changed

apps/application/flow/workflow_manage.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import json
1111
import threading
1212
import traceback
13+
import uuid
1314
from concurrent.futures import ThreadPoolExecutor
1415
from functools import reduce
1516
from typing import List, Dict
@@ -575,7 +576,7 @@ def get_runtime_details(self):
575576
details['node_id'] = node.id
576577
details['up_node_id_list'] = node.up_node_id_list
577578
details['runtime_node_id'] = node.runtime_node_id
578-
details_result[node.runtime_node_id] = details
579+
details_result[str(uuid.uuid1())] = details
579580
return details_result
580581

581582
def get_answer_text_list(self):
@@ -664,9 +665,18 @@ def get_next_node_list(self, current_node, current_node_result):
664665
for edge in self.flow.edges:
665666
if (edge.sourceNodeId == current_node.id and
666667
f"{edge.sourceNodeId}_{current_node_result.node_variable.get('branch_id')}_right" == edge.sourceAnchorId):
667-
if self.dependent_node_been_executed(edge.targetNodeId):
668+
next_node = [node for node in self.flow.nodes if node.id == edge.targetNodeId]
669+
if len(next_node) == 0:
670+
continue
671+
if next_node[0].properties.get('condition', "AND") == 'AND':
672+
if self.dependent_node_been_executed(edge.targetNodeId):
673+
node_list.append(
674+
self.get_node_cls_by_id(edge.targetNodeId,
675+
[*current_node.up_node_id_list, current_node.node.id]))
676+
else:
668677
node_list.append(
669-
self.get_node_cls_by_id(edge.targetNodeId, self.get_up_node_id_list(edge.targetNodeId)))
678+
self.get_node_cls_by_id(edge.targetNodeId,
679+
[*current_node.up_node_id_list, current_node.node.id]))
670680
else:
671681
for edge in self.flow.edges:
672682
if edge.sourceNodeId == current_node.id:
@@ -676,10 +686,12 @@ def get_next_node_list(self, current_node, current_node_result):
676686
if next_node[0].properties.get('condition', "AND") == 'AND':
677687
if self.dependent_node_been_executed(edge.targetNodeId):
678688
node_list.append(
679-
self.get_node_cls_by_id(edge.targetNodeId, self.get_up_node_id_list(edge.targetNodeId)))
689+
self.get_node_cls_by_id(edge.targetNodeId,
690+
[*current_node.up_node_id_list, current_node.node.id]))
680691
else:
681692
node_list.append(
682-
self.get_node_cls_by_id(edge.targetNodeId, [current_node.node.id]))
693+
self.get_node_cls_by_id(edge.targetNodeId,
694+
[*current_node.up_node_id_list, current_node.node.id]))
683695
return node_list
684696

685697
def get_reference_field(self, node_id: str, fields: List[str]):

ui/src/api/type/application.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,11 @@ export class ChatRecordManage {
122122

123123
this.chat.answer_text = this.chat.answer_text + chunk_answer
124124
}
125-
get_current_up_node() {
126-
for (let i = this.node_list.length - 2; i >= 0; i--) {
127-
const n = this.node_list[i]
128-
if (n.content.length > 0) {
129-
return n
130-
}
125+
get_current_up_node(run_node: any) {
126+
const index = this.node_list.findIndex((item) => item == run_node)
127+
if (index > 0) {
128+
const n = this.node_list[index - 1]
129+
return n
131130
}
132131
return undefined
133132
}
@@ -145,14 +144,13 @@ export class ChatRecordManage {
145144
const index = this.node_list.indexOf(run_node)
146145
let current_up_node = undefined
147146
if (index > 0) {
148-
current_up_node = this.get_current_up_node()
147+
current_up_node = this.get_current_up_node(run_node)
149148
}
150149
let answer_text_list_index = 0
151-
152150
if (
153151
current_up_node == undefined ||
154152
run_node.view_type == 'single_view' ||
155-
(run_node.view_type == 'many_view' && current_up_node.view_type == 'single_view')
153+
current_up_node.view_type == 'single_view'
156154
) {
157155
const none_index = this.findIndex(
158156
this.chat.answer_text_list,

0 commit comments

Comments
 (0)