mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 01:33:05 +00:00
fix: Workflow The condition setting 'any' did not take effect when the discriminator was executed (#1979)
(cherry picked from commit 00591a5b25)
This commit is contained in:
parent
e254951ea8
commit
a2eef10234
|
|
@ -10,6 +10,7 @@ import concurrent
|
|||
import json
|
||||
import threading
|
||||
import traceback
|
||||
import uuid
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
from functools import reduce
|
||||
from typing import List, Dict
|
||||
|
|
@ -575,7 +576,7 @@ class WorkflowManage:
|
|||
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):
|
||||
|
|
@ -664,9 +665,18 @@ class WorkflowManage:
|
|||
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:
|
||||
|
|
@ -676,10 +686,12 @@ class WorkflowManage:
|
|||
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]):
|
||||
|
|
|
|||
|
|
@ -121,12 +121,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
|
||||
}
|
||||
|
|
@ -144,14 +143,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,
|
||||
|
|
|
|||
Loading…
Reference in New Issue