From b40336f9d16c5d03216396692360ec1de2664822 Mon Sep 17 00:00:00 2001 From: shaohuzhang1 <80892890+shaohuzhang1@users.noreply.github.com> Date: Wed, 11 Dec 2024 13:52:23 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E5=BA=93=E5=93=8D=E5=BA=94=E6=95=B0=E6=8D=AE=E5=9C=A8=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E4=B8=AD=E4=B8=8D=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98?= =?UTF-8?q?=20(#1814)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit f9437ca9b8d4a8fe478459facb253dc31ce039c3) --- .../step_node/application_node/impl/base_application_node.py | 4 +++- .../function_lib_node/impl/base_function_lib_node.py | 3 ++- .../flow/step_node/function_node/impl/base_function_node.py | 2 +- apps/application/flow/workflow_manage.py | 4 +++- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/apps/application/flow/step_node/application_node/impl/base_application_node.py b/apps/application/flow/step_node/application_node/impl/base_application_node.py index 5527cf489..17b30d0eb 100644 --- a/apps/application/flow/step_node/application_node/impl/base_application_node.py +++ b/apps/application/flow/step_node/application_node/impl/base_application_node.py @@ -52,6 +52,7 @@ def write_context_stream(node_variable: Dict, workflow_variable: Dict, node: INo runtime_node_id = response_content.get('runtime_node_id', '') chat_record_id = response_content.get('chat_record_id', '') child_node = response_content.get('child_node') + view_type = response_content.get('view_type') node_type = response_content.get('node_type') real_node_id = response_content.get('real_node_id') node_is_end = response_content.get('node_is_end', False) @@ -65,7 +66,8 @@ def write_context_stream(node_variable: Dict, workflow_variable: Dict, node: INo 'runtime_node_id': runtime_node_id, 'chat_record_id': chat_record_id, 'child_node': child_node, 'real_node_id': real_node_id, - 'node_is_end': node_is_end} + 'node_is_end': node_is_end, + 'view_type': view_type} usage = response_content.get('usage', {}) node_variable['result'] = {'usage': usage} node_variable['is_interrupt_exec'] = is_interrupt_exec diff --git a/apps/application/flow/step_node/function_lib_node/impl/base_function_lib_node.py b/apps/application/flow/step_node/function_lib_node/impl/base_function_lib_node.py index 273b84d97..f4c5b53ee 100644 --- a/apps/application/flow/step_node/function_lib_node/impl/base_function_lib_node.py +++ b/apps/application/flow/step_node/function_lib_node/impl/base_function_lib_node.py @@ -29,7 +29,7 @@ def write_context(step_variable: Dict, global_variable: Dict, node, workflow): if workflow.is_result(node, NodeResult(step_variable, global_variable)) and 'result' in step_variable: result = str(step_variable['result']) + '\n' yield result - workflow.answer += result + node.answer_text = result node.context['run_time'] = time.time() - node.context['start_time'] @@ -94,6 +94,7 @@ class BaseFunctionLibNodeNode(IFunctionLibNode): def save_context(self, details, workflow_manage): self.context['result'] = details.get('result') self.answer_text = details.get('result') + def execute(self, function_lib_id, input_field_list, **kwargs) -> NodeResult: function_lib = QuerySet(FunctionLib).filter(id=function_lib_id).first() if not function_lib.is_active: diff --git a/apps/application/flow/step_node/function_node/impl/base_function_node.py b/apps/application/flow/step_node/function_node/impl/base_function_node.py index 3336b308a..e9aac69dc 100644 --- a/apps/application/flow/step_node/function_node/impl/base_function_node.py +++ b/apps/application/flow/step_node/function_node/impl/base_function_node.py @@ -27,7 +27,7 @@ def write_context(step_variable: Dict, global_variable: Dict, node, workflow): if workflow.is_result(node, NodeResult(step_variable, global_variable)) and 'result' in step_variable: result = str(step_variable['result']) + '\n' yield result - workflow.answer += result + node.answer_text = result node.context['run_time'] = time.time() - node.context['start_time'] diff --git a/apps/application/flow/workflow_manage.py b/apps/application/flow/workflow_manage.py index b126387d5..e580a5a6a 100644 --- a/apps/application/flow/workflow_manage.py +++ b/apps/application/flow/workflow_manage.py @@ -454,6 +454,7 @@ class WorkflowManage: content = r child_node = {} node_is_end = False + view_type = current_node.view_type if isinstance(r, dict): content = r.get('content') child_node = {'runtime_node_id': r.get('runtime_node_id'), @@ -461,6 +462,7 @@ class WorkflowManage: , 'child_node': r.get('child_node')} real_node_id = r.get('real_node_id') node_is_end = r.get('node_is_end') + view_type = r.get('view_type') chunk = self.base_to_response.to_stream_chunk_response(self.params['chat_id'], self.params['chat_record_id'], current_node.id, @@ -468,7 +470,7 @@ class WorkflowManage: content, False, 0, 0, {'node_type': current_node.type, 'runtime_node_id': current_node.runtime_node_id, - 'view_type': current_node.view_type, + 'view_type': view_type, 'child_node': child_node, 'node_is_end': node_is_end, 'real_node_id': real_node_id})