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)