From 1af9ff351b66a7e2d7eb72d2387448232fe90690 Mon Sep 17 00:00:00 2001 From: shaohuzhang1 Date: Thu, 27 Jun 2024 09:48:40 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=97=AE=E9=A2=98=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=AF=B9=E8=AF=9D=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../step_node/question_node/impl/base_question_node.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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 16679ee0e..e5ed6a660 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 @@ -7,6 +7,7 @@ @desc: """ import json +from functools import reduce from typing import List, Dict from django.db.models import QuerySet @@ -148,9 +149,10 @@ class BaseQuestionNode(IQuestionNode): @staticmethod def get_history_message(history_chat_record, dialogue_number): start_index = len(history_chat_record) - dialogue_number - history_message = [[history_chat_record[index].get_human_message(), history_chat_record[index].get_ai_message()] - for index in - range(start_index if start_index > 0 else 0, len(history_chat_record))] + history_message = reduce(lambda x, y: [*x, *y], [ + [history_chat_record[index].get_human_message(), history_chat_record[index].get_ai_message()] + for index in + range(start_index if start_index > 0 else 0, len(history_chat_record))], []) return history_message def generate_prompt_question(self, prompt):