Skip to content

Commit 41d97af

Browse files
committed
fix: [Application] When an application with form collection is embedded into the parent application, the conversation will report an error
1 parent bd47349 commit 41d97af

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

apps/application/serializers/common.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,33 @@ def append_chat_record(self, chat_record: ChatRecord):
224224
else:
225225
QuerySet(Chat).filter(id=self.chat_id).update(update_time=timezone.now())
226226
# 插入会话记录
227-
chat_record.save()
227+
QuerySet(ChatRecord).update_or_create(id=chat_record.id,
228+
create_defaults={'id': chat_record.id,
229+
'chat_id': chat_record.chat_id,
230+
"vote_status": chat_record.vote_status,
231+
'problem_text': chat_record.problem_text,
232+
'answer_text': chat_record.answer_text,
233+
'answer_text_list': chat_record.answer_text_list,
234+
'message_tokens': chat_record.message_tokens,
235+
'answer_tokens': chat_record.answer_tokens,
236+
'const': chat_record.const,
237+
'details': chat_record.details,
238+
'improve_paragraph_id_list': chat_record.improve_paragraph_id_list,
239+
'run_time': chat_record.run_time,
240+
'index': chat_record.index},
241+
defaults={
242+
"vote_status": chat_record.vote_status,
243+
'problem_text': chat_record.problem_text,
244+
'answer_text': chat_record.answer_text,
245+
'answer_text_list': chat_record.answer_text_list,
246+
'message_tokens': chat_record.message_tokens,
247+
'answer_tokens': chat_record.answer_tokens,
248+
'const': chat_record.const,
249+
'details': chat_record.details,
250+
'improve_paragraph_id_list': chat_record.improve_paragraph_id_list,
251+
'run_time': chat_record.run_time,
252+
'index': chat_record.index
253+
})
228254
ChatCountSerializer(data={'chat_id': self.chat_id}).update_chat()
229255

230256
def to_dict(self):

0 commit comments

Comments
 (0)