Skip to content

Commit a2eef10

Browse files
committed
fix: Workflow The condition setting 'any' did not take effect when the discriminator was executed (#1979)
(cherry picked from commit 00591a5)
1 parent e254951 commit a2eef10

File tree

2 files changed

+24
-14
lines changed

2 files changed

+24
-14
lines changed

Diff for: apps/application/flow/workflow_manage.py

+17-5
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]):

Diff for: ui/src/api/type/application.ts

+7-9
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,11 @@ export class ChatRecordManage {
121121

122122
this.chat.answer_text = this.chat.answer_text + chunk_answer
123123
}
124-
get_current_up_node() {
125-
for (let i = this.node_list.length - 2; i >= 0; i--) {
126-
const n = this.node_list[i]
127-
if (n.content.length > 0) {
128-
return n
129-
}
124+
get_current_up_node(run_node: any) {
125+
const index = this.node_list.findIndex((item) => item == run_node)
126+
if (index > 0) {
127+
const n = this.node_list[index - 1]
128+
return n
130129
}
131130
return undefined
132131
}
@@ -144,14 +143,13 @@ export class ChatRecordManage {
144143
const index = this.node_list.indexOf(run_node)
145144
let current_up_node = undefined
146145
if (index > 0) {
147-
current_up_node = this.get_current_up_node()
146+
current_up_node = this.get_current_up_node(run_node)
148147
}
149148
let answer_text_list_index = 0
150-
151149
if (
152150
current_up_node == undefined ||
153151
run_node.view_type == 'single_view' ||
154-
(run_node.view_type == 'many_view' && current_up_node.view_type == 'single_view')
152+
current_up_node.view_type == 'single_view'
155153
) {
156154
const none_index = this.findIndex(
157155
this.chat.answer_text_list,

0 commit comments

Comments
 (0)