From 666c379be94e60af485c07e1eb8bd1e3a9ee7faf Mon Sep 17 00:00:00 2001 From: shaohuzhang1 <80892890+shaohuzhang1@users.noreply.github.com> Date: Tue, 9 Dec 2025 17:08:57 +0800 Subject: [PATCH] fix: [Application] When an application with form collection is embedded into the parent application, the conversation will report an error (#4472) --- apps/application/serializers/common.py | 28 +++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/apps/application/serializers/common.py b/apps/application/serializers/common.py index 5c60512ad..b7ac4c5e4 100644 --- a/apps/application/serializers/common.py +++ b/apps/application/serializers/common.py @@ -224,7 +224,33 @@ class ChatInfo: else: QuerySet(Chat).filter(id=self.chat_id).update(update_time=timezone.now()) # 插入会话记录 - chat_record.save() + QuerySet(ChatRecord).update_or_create(id=chat_record.id, + create_defaults={'id': chat_record.id, + 'chat_id': chat_record.chat_id, + "vote_status": chat_record.vote_status, + 'problem_text': chat_record.problem_text, + 'answer_text': chat_record.answer_text, + 'answer_text_list': chat_record.answer_text_list, + 'message_tokens': chat_record.message_tokens, + 'answer_tokens': chat_record.answer_tokens, + 'const': chat_record.const, + 'details': chat_record.details, + 'improve_paragraph_id_list': chat_record.improve_paragraph_id_list, + 'run_time': chat_record.run_time, + 'index': chat_record.index}, + defaults={ + "vote_status": chat_record.vote_status, + 'problem_text': chat_record.problem_text, + 'answer_text': chat_record.answer_text, + 'answer_text_list': chat_record.answer_text_list, + 'message_tokens': chat_record.message_tokens, + 'answer_tokens': chat_record.answer_tokens, + 'const': chat_record.const, + 'details': chat_record.details, + 'improve_paragraph_id_list': chat_record.improve_paragraph_id_list, + 'run_time': chat_record.run_time, + 'index': chat_record.index + }) ChatCountSerializer(data={'chat_id': self.chat_id}).update_chat() def to_dict(self):