From 77814972a49595c223b2a6f1fbc1d97ff38b23b6 Mon Sep 17 00:00:00 2001 From: shaohuzhang1 <80892890+shaohuzhang1@users.noreply.github.com> Date: Tue, 6 Aug 2024 16:56:05 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=8A=82=E7=82=B9?= =?UTF-8?q?=E7=9B=B4=E6=8E=A5=E5=9B=9E=E7=AD=94,=E4=B8=8D=E5=90=8C?= =?UTF-8?q?=E8=8A=82=E7=82=B9=E5=93=8D=E5=BA=94=E7=94=A8=E5=9B=9E=E8=BD=A6?= =?UTF-8?q?=E9=9A=94=E5=BC=80=20(#935)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit 8453ea2b4bd9e23c775ad2938c58fa87dff47c88) --- apps/application/flow/i_step_node.py | 5 +++-- .../flow/step_node/ai_chat_step_node/impl/base_chat_node.py | 2 ++ .../flow/step_node/question_node/impl/base_question_node.py | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/application/flow/i_step_node.py b/apps/application/flow/i_step_node.py index e6b87f46c..b0058cbe9 100644 --- a/apps/application/flow/i_step_node.py +++ b/apps/application/flow/i_step_node.py @@ -28,8 +28,9 @@ 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: - yield step_variable['answer'] - workflow.answer += step_variable['answer'] + answer = step_variable['answer'] + '\n' + yield answer + workflow.answer += answer if global_variable is not None: for key in global_variable: workflow.context[key] = global_variable[key] 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 6588012e9..fdc5e99e5 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,6 +45,8 @@ 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 445b59aff..3826e59e5 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,6 +45,8 @@ 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)