Skip to content

Commit

Permalink
fix: 修复删除知识库的段落后,日志内容还是显示标注的缺陷
Browse files Browse the repository at this point in the history
  • Loading branch information
wxg0103 committed Nov 26, 2024
1 parent f1083d9 commit de630b4
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion apps/application/serializers/chat_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']


Expand Down Expand Up @@ -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(
Expand All @@ -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,
Expand Down

0 comments on commit de630b4

Please sign in to comment.