Skip to content

Commit

Permalink
fix: Workflow cannot respond to errors
Browse files Browse the repository at this point in the history
  • Loading branch information
shaohuzhang1 committed Dec 24, 2024
1 parent 0372681 commit d4da72a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions apps/application/flow/workflow_manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,6 @@ def __init__(self, flow: Flow, params, work_flow_post_handler: WorkFlowPostHandl
self.audio_list = audio_list
self.params = params
self.flow = flow
self.lock = threading.Lock()
self.context = {}
self.node_chunk_manage = NodeChunkManage(self)
self.work_flow_post_handler = work_flow_post_handler
Expand Down Expand Up @@ -391,6 +390,8 @@ def run_chain_manage(self, current_node, node_result_future):
start_node = self.get_start_node()
current_node = get_node(start_node.type)(start_node, self.params, self)
result = self.run_chain(current_node, node_result_future)
if result is None:
return
node_list = self.get_next_node_list(current_node, result)
if len(node_list) == 1:
self.run_chain_manage(node_list[0], None)
Expand Down Expand Up @@ -424,7 +425,7 @@ def run_chain(self, current_node, node_result_future=None):
return result
except Exception as e:
traceback.print_exc()
return []
return None

def hand_node_result(self, current_node, node_result_future):
try:
Expand Down Expand Up @@ -507,7 +508,6 @@ def hand_event_node_result(self, current_node, node_result_future):
# 添加节点
self.append_node(current_node)
traceback.print_exc()
self.answer += str(e)
chunk = self.base_to_response.to_stream_chunk_response(self.params['chat_id'],
self.params['chat_record_id'],
current_node.id,
Expand All @@ -524,6 +524,7 @@ def hand_event_node_result(self, current_node, node_result_future):
node_chunk.end(chunk)
current_node.get_write_error_context(e)
self.status = 500
return None

def run_node_async(self, node):
future = executor.submit(self.run_node, node)
Expand Down

0 comments on commit d4da72a

Please sign in to comment.