From d1be102060839bb6c2e62e11f40b6738418363e2 Mon Sep 17 00:00:00 2001 From: shaohuzhang1 Date: Fri, 27 Dec 2024 10:44:33 +0800 Subject: [PATCH] feat: AI dialogue roles support obtaining data from other nodes --- .../flow/step_node/ai_chat_step_node/impl/base_chat_node.py | 4 +++- .../flow/step_node/question_node/impl/base_question_node.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) 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 af68c3131ae..ead083364e8 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 @@ -110,6 +110,8 @@ def execute(self, model_id, system, prompt, dialogue_number, history_chat_record self.context['history_message'] = history_message question = self.generate_prompt_question(prompt) self.context['question'] = question.content + system = self.workflow_manage.generate_prompt(system) + self.context['system'] = question.content message_list = self.generate_message_list(system, prompt, history_message) self.context['message_list'] = message_list if stream: @@ -156,7 +158,7 @@ def get_details(self, index: int, **kwargs): 'name': self.node.properties.get('stepName'), "index": index, 'run_time': self.context.get('run_time'), - 'system': self.node_params.get('system'), + 'system': self.context.get('system'), 'history_message': [{'content': message.content, 'role': message.type} for message in (self.context.get('history_message') if self.context.get( 'history_message') is not None else [])], 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 f69cb912cb7..f67206bdaf6 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 @@ -92,6 +92,8 @@ def execute(self, model_id, system, prompt, dialogue_number, history_chat_record self.context['history_message'] = history_message question = self.generate_prompt_question(prompt) self.context['question'] = question.content + system = self.workflow_manage.generate_prompt(system) + self.context['system'] = question.content message_list = self.generate_message_list(system, prompt, history_message) self.context['message_list'] = message_list if stream: @@ -138,7 +140,7 @@ def get_details(self, index: int, **kwargs): 'name': self.node.properties.get('stepName'), "index": index, 'run_time': self.context.get('run_time'), - 'system': self.node_params.get('system'), + 'system': self.context.get('system'), 'history_message': [{'content': message.content, 'role': message.type} for message in (self.context.get('history_message') if self.context.get( 'history_message') is not None else [])],