fix: 修复在对话日志中删除保存的文档,关联的问题未删除的缺陷
--bug=1049555 --user=王孝刚 【应用】将对话日志保存到文档后,在对话日志中删除保存的文档,关联的问题未删除 https://www.tapd.cn/57709429/s/1617726
This commit is contained in:
parent
aafc855435
commit
52575360ed
@ -154,6 +154,7 @@ def get_post_handler(chat_info: ChatInfo):
|
|||||||
details=manage.get_details(),
|
details=manage.get_details(),
|
||||||
message_tokens=manage.context['message_tokens'],
|
message_tokens=manage.context['message_tokens'],
|
||||||
answer_tokens=manage.context['answer_tokens'],
|
answer_tokens=manage.context['answer_tokens'],
|
||||||
|
answer_text_list=[answer_text],
|
||||||
run_time=manage.context['run_time'],
|
run_time=manage.context['run_time'],
|
||||||
index=len(chat_info.chat_record_list) + 1)
|
index=len(chat_info.chat_record_list) + 1)
|
||||||
chat_info.append_chat_record(chat_record, client_id)
|
chat_info.append_chat_record(chat_record, client_id)
|
||||||
|
|||||||
@ -608,13 +608,11 @@ class ChatRecordSerializer(serializers.Serializer):
|
|||||||
title=instance.get("title") if 'title' in instance else '')
|
title=instance.get("title") if 'title' in instance else '')
|
||||||
problem_text = instance.get('problem_text') if instance.get(
|
problem_text = instance.get('problem_text') if instance.get(
|
||||||
'problem_text') is not None else chat_record.problem_text
|
'problem_text') is not None else chat_record.problem_text
|
||||||
problem = Problem(id=uuid.uuid1(), content=problem_text, dataset_id=dataset_id)
|
problem, _ = Problem.objects.get_or_create(content=problem_text, dataset_id=dataset_id)
|
||||||
problem_paragraph_mapping = ProblemParagraphMapping(id=uuid.uuid1(), dataset_id=dataset_id,
|
problem_paragraph_mapping = ProblemParagraphMapping(id=uuid.uuid1(), dataset_id=dataset_id,
|
||||||
document_id=document_id,
|
document_id=document_id,
|
||||||
problem_id=problem.id,
|
problem_id=problem.id,
|
||||||
paragraph_id=paragraph.id)
|
paragraph_id=paragraph.id)
|
||||||
# 插入问题
|
|
||||||
problem.save()
|
|
||||||
# 插入段落
|
# 插入段落
|
||||||
paragraph.save()
|
paragraph.save()
|
||||||
# 插入关联问题
|
# 插入关联问题
|
||||||
|
|||||||
@ -540,8 +540,16 @@ class ParagraphSerializers(ApiMixin, serializers.Serializer):
|
|||||||
if with_valid:
|
if with_valid:
|
||||||
self.is_valid(raise_exception=True)
|
self.is_valid(raise_exception=True)
|
||||||
paragraph_id = self.data.get('paragraph_id')
|
paragraph_id = self.data.get('paragraph_id')
|
||||||
QuerySet(Paragraph).filter(id=paragraph_id).delete()
|
Paragraph.objects.filter(id=paragraph_id).delete()
|
||||||
QuerySet(ProblemParagraphMapping).filter(paragraph_id=paragraph_id).delete()
|
|
||||||
|
problem_id = ProblemParagraphMapping.objects.filter(paragraph_id=paragraph_id).values_list('problem_id',
|
||||||
|
flat=True).first()
|
||||||
|
|
||||||
|
if problem_id is not None:
|
||||||
|
if ProblemParagraphMapping.objects.filter(problem_id=problem_id).count() == 1:
|
||||||
|
Problem.objects.filter(id=problem_id).delete()
|
||||||
|
ProblemParagraphMapping.objects.filter(paragraph_id=paragraph_id).delete()
|
||||||
|
|
||||||
update_document_char_length(self.data.get('document_id'))
|
update_document_char_length(self.data.get('document_id'))
|
||||||
delete_embedding_by_paragraph(paragraph_id)
|
delete_embedding_by_paragraph(paragraph_id)
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user