From de630b4595c94c64cc3470b42c4ec1f8452d2dc1 Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Tue, 26 Nov 2024 17:37:10 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E7=9F=A5=E8=AF=86=E5=BA=93=E7=9A=84=E6=AE=B5=E8=90=BD=E5=90=8E?= =?UTF-8?q?=EF=BC=8C=E6=97=A5=E5=BF=97=E5=86=85=E5=AE=B9=E8=BF=98=E6=98=AF?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E6=A0=87=E6=B3=A8=E7=9A=84=E7=BC=BA=E9=99=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/application/serializers/chat_serializers.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/apps/application/serializers/chat_serializers.py b/apps/application/serializers/chat_serializers.py index 468c70316c..d07b5676e5 100644 --- a/apps/application/serializers/chat_serializers.py +++ b/apps/application/serializers/chat_serializers.py @@ -395,7 +395,8 @@ class ChatRecordSerializerModel(serializers.ModelSerializer): class Meta: model = ChatRecord fields = ['id', 'chat_id', 'vote_status', 'problem_text', 'answer_text', - 'message_tokens', 'answer_tokens', 'const', 'improve_paragraph_id_list', 'run_time', 'index','answer_text_list', + 'message_tokens', 'answer_tokens', 'const', 'improve_paragraph_id_list', 'run_time', 'index', + 'answer_text_list', 'create_time', 'update_time'] @@ -457,6 +458,7 @@ def list(self, with_valid=True): def reset_chat_record(chat_record): dataset_list = [] paragraph_list = [] + if 'search_step' in chat_record.details and chat_record.details.get('search_step').get( 'paragraph_list') is not None: paragraph_list = chat_record.details.get('search_step').get( @@ -468,6 +470,14 @@ def reset_chat_record(chat_record): row in paragraph_list], {}).items()] + if len(chat_record.improve_paragraph_id_list) > 0: + paragraph_model_list = QuerySet(Paragraph).filter(id__in=chat_record.improve_paragraph_id_list) + if len(paragraph_model_list) < len(chat_record.improve_paragraph_id_list): + paragraph_model_id_list = [str(p.id) for p in paragraph_model_list] + chat_record.improve_paragraph_id_list = list( + filter(lambda p_id: paragraph_model_id_list.__contains__(p_id), + chat_record.improve_paragraph_id_list)) + chat_record.save() return { **ChatRecordSerializerModel(chat_record).data,