From b19ed0d8db26d456555b93641b3b1fc4c42c7f7d Mon Sep 17 00:00:00 2001 From: shaohuzhang1 Date: Tue, 27 Aug 2024 11:32:27 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dai=E5=AF=B9=E8=AF=9D?= =?UTF-8?q?=E8=8A=82=E7=82=B9=E8=BE=93=E5=87=BA=E5=86=85=E5=AE=B9=E5=9B=9E?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=9B=9E=E8=BD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/application/flow/i_step_node.py | 2 +- .../step_node/ai_chat_step_node/impl/base_chat_node.py | 2 -- .../step_node/question_node/impl/base_question_node.py | 2 -- apps/application/flow/workflow_manage.py | 8 ++++++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/apps/application/flow/i_step_node.py b/apps/application/flow/i_step_node.py index 5ac951dab..2d5e38881 100644 --- a/apps/application/flow/i_step_node.py +++ b/apps/application/flow/i_step_node.py @@ -29,7 +29,7 @@ def write_context(step_variable: Dict, global_variable: Dict, node, workflow): for key in step_variable: node.context[key] = step_variable[key] if workflow.is_result() and 'answer' in step_variable: - answer = step_variable['answer'] + '\n' + answer = step_variable['answer'] yield answer workflow.answer += answer if global_variable is not None: diff --git a/apps/application/flow/step_node/ai_chat_step_node/impl/base_chat_node.py b/apps/application/flow/step_node/ai_chat_step_node/impl/base_chat_node.py index 6eac5004b..3581b5cfd 100644 --- a/apps/application/flow/step_node/ai_chat_step_node/impl/base_chat_node.py +++ b/apps/application/flow/step_node/ai_chat_step_node/impl/base_chat_node.py @@ -45,8 +45,6 @@ def write_context_stream(node_variable: Dict, workflow_variable: Dict, node: INo for chunk in response: answer += chunk.content yield chunk.content - answer += '\n' - yield '\n' _write_context(node_variable, workflow_variable, node, workflow, answer) diff --git a/apps/application/flow/step_node/question_node/impl/base_question_node.py b/apps/application/flow/step_node/question_node/impl/base_question_node.py index de40d3a8c..397a0bfc1 100644 --- a/apps/application/flow/step_node/question_node/impl/base_question_node.py +++ b/apps/application/flow/step_node/question_node/impl/base_question_node.py @@ -45,8 +45,6 @@ def write_context_stream(node_variable: Dict, workflow_variable: Dict, node: INo for chunk in response: answer += chunk.content yield chunk.content - answer += '\n' - yield '\n' _write_context(node_variable, workflow_variable, node, workflow, answer) diff --git a/apps/application/flow/workflow_manage.py b/apps/application/flow/workflow_manage.py index fcd1daf71..65097d788 100644 --- a/apps/application/flow/workflow_manage.py +++ b/apps/application/flow/workflow_manage.py @@ -209,9 +209,13 @@ class WorkflowManage: self.current_result = self.current_node.run() result = self.current_result.write_context(self.current_node, self) if result is not None: - for r in result: - if self.is_result(): + if self.is_result(): + for r in result: yield self.get_chunk_content(r) + yield self.get_chunk_content('\n') + self.answer += '\n' + else: + list(result) if not self.has_next_node(self.current_result): yield self.get_chunk_content('', True) break