Skip to content

Commit

Permalink
fix: Workflow The condition setting 'any' did not take effect when th…
Browse files Browse the repository at this point in the history
…e discriminator was executed (#1979)
  • Loading branch information
shaohuzhang1 authored Jan 6, 2025
1 parent c307f6b commit 00591a5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
22 changes: 17 additions & 5 deletions apps/application/flow/workflow_manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import json
import threading
import traceback
import uuid
from concurrent.futures import ThreadPoolExecutor
from functools import reduce
from typing import List, Dict
Expand Down Expand Up @@ -575,7 +576,7 @@ def get_runtime_details(self):
details['node_id'] = node.id
details['up_node_id_list'] = node.up_node_id_list
details['runtime_node_id'] = node.runtime_node_id
details_result[node.runtime_node_id] = details
details_result[str(uuid.uuid1())] = details
return details_result

def get_answer_text_list(self):
Expand Down Expand Up @@ -664,9 +665,18 @@ def get_next_node_list(self, current_node, current_node_result):
for edge in self.flow.edges:
if (edge.sourceNodeId == current_node.id and
f"{edge.sourceNodeId}_{current_node_result.node_variable.get('branch_id')}_right" == edge.sourceAnchorId):
if self.dependent_node_been_executed(edge.targetNodeId):
next_node = [node for node in self.flow.nodes if node.id == edge.targetNodeId]
if len(next_node) == 0:
continue
if next_node[0].properties.get('condition', "AND") == 'AND':
if self.dependent_node_been_executed(edge.targetNodeId):
node_list.append(
self.get_node_cls_by_id(edge.targetNodeId,
[*current_node.up_node_id_list, current_node.node.id]))
else:
node_list.append(
self.get_node_cls_by_id(edge.targetNodeId, self.get_up_node_id_list(edge.targetNodeId)))
self.get_node_cls_by_id(edge.targetNodeId,
[*current_node.up_node_id_list, current_node.node.id]))
else:
for edge in self.flow.edges:
if edge.sourceNodeId == current_node.id:
Expand All @@ -676,10 +686,12 @@ def get_next_node_list(self, current_node, current_node_result):
if next_node[0].properties.get('condition', "AND") == 'AND':
if self.dependent_node_been_executed(edge.targetNodeId):
node_list.append(
self.get_node_cls_by_id(edge.targetNodeId, self.get_up_node_id_list(edge.targetNodeId)))
self.get_node_cls_by_id(edge.targetNodeId,
[*current_node.up_node_id_list, current_node.node.id]))
else:
node_list.append(
self.get_node_cls_by_id(edge.targetNodeId, [current_node.node.id]))
self.get_node_cls_by_id(edge.targetNodeId,
[*current_node.up_node_id_list, current_node.node.id]))
return node_list

def get_reference_field(self, node_id: str, fields: List[str]):
Expand Down
16 changes: 7 additions & 9 deletions ui/src/api/type/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,11 @@ export class ChatRecordManage {

this.chat.answer_text = this.chat.answer_text + chunk_answer
}
get_current_up_node() {
for (let i = this.node_list.length - 2; i >= 0; i--) {
const n = this.node_list[i]
if (n.content.length > 0) {
return n
}
get_current_up_node(run_node: any) {
const index = this.node_list.findIndex((item) => item == run_node)
if (index > 0) {
const n = this.node_list[index - 1]
return n
}
return undefined
}
Expand All @@ -146,14 +145,13 @@ export class ChatRecordManage {
const index = this.node_list.indexOf(run_node)
let current_up_node = undefined
if (index > 0) {
current_up_node = this.get_current_up_node()
current_up_node = this.get_current_up_node(run_node)
}
let answer_text_list_index = 0

if (
current_up_node == undefined ||
run_node.view_type == 'single_view' ||
(run_node.view_type == 'many_view' && current_up_node.view_type == 'single_view')
current_up_node.view_type == 'single_view'
) {
const none_index = this.findIndex(
this.chat.answer_text_list,
Expand Down

0 comments on commit 00591a5

Please sign in to comment.