From b96931873c595fa327d247d76e0de6ecf1c7e6d5 Mon Sep 17 00:00:00 2001 From: shaohuzhang1 Date: Mon, 21 Oct 2024 16:03:48 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=B7=A5=E4=BD=9C?= =?UTF-8?q?=E6=B5=81=E8=8A=82=E7=82=B9=E9=94=99=E8=AF=AF=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E5=9C=A8=E8=AF=A6=E6=83=85=E9=87=8C=E9=9D=A2=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/application/flow/workflow_manage.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/apps/application/flow/workflow_manage.py b/apps/application/flow/workflow_manage.py index 070c86525..1234688f5 100644 --- a/apps/application/flow/workflow_manage.py +++ b/apps/application/flow/workflow_manage.py @@ -194,6 +194,9 @@ class NodeChunkManage: def add_node_chunk(self, node_chunk): self.node_chunk_list.append(node_chunk) + def contains(self, node_chunk): + return self.node_chunk_list.__contains__(node_chunk) + def pop(self): if self.current_node_chunk is None: try: @@ -354,12 +357,12 @@ class WorkflowManage: self.answer += str(e) def hand_event_node_result(self, current_node, node_result_future): + node_chunk = NodeChunk() try: current_result = node_result_future.result() result = current_result.write_context(current_node, self) if result is not None: if self.is_result(current_node, current_result): - node_chunk = NodeChunk() self.node_chunk_manage.add_node_chunk(node_chunk) for r in result: chunk = self.base_to_response.to_stream_chunk_response(self.params['chat_id'], @@ -376,16 +379,16 @@ class WorkflowManage: # 添加节点 self.node_context.append(current_node) traceback.print_exc() - self.status = 500 - current_node.get_write_error_context(e) self.answer += str(e) chunk = self.base_to_response.to_stream_chunk_response(self.params['chat_id'], self.params['chat_record_id'], str(e), False, 0, 0) - node_chunk = NodeChunk() - self.node_chunk_manage.add_node_chunk(node_chunk) + if not self.node_chunk_manage.contains(node_chunk): + self.node_chunk_manage.add_node_chunk(node_chunk) node_chunk.add_chunk(chunk) node_chunk.end() + current_node.get_write_error_context(e) + self.status = 500 def run_node_async(self, node): future = executor.submit(self.run_node, node)