@@ -395,7 +395,8 @@ class ChatRecordSerializerModel(serializers.ModelSerializer):
395395 class Meta :
396396 model = ChatRecord
397397 fields = ['id' , 'chat_id' , 'vote_status' , 'problem_text' , 'answer_text' ,
398- 'message_tokens' , 'answer_tokens' , 'const' , 'improve_paragraph_id_list' , 'run_time' , 'index' ,'answer_text_list' ,
398+ 'message_tokens' , 'answer_tokens' , 'const' , 'improve_paragraph_id_list' , 'run_time' , 'index' ,
399+ 'answer_text_list' ,
399400 'create_time' , 'update_time' ]
400401
401402
@@ -457,6 +458,7 @@ def list(self, with_valid=True):
457458 def reset_chat_record (chat_record ):
458459 dataset_list = []
459460 paragraph_list = []
461+
460462 if 'search_step' in chat_record .details and chat_record .details .get ('search_step' ).get (
461463 'paragraph_list' ) is not None :
462464 paragraph_list = chat_record .details .get ('search_step' ).get (
@@ -468,6 +470,14 @@ def reset_chat_record(chat_record):
468470 row in
469471 paragraph_list ],
470472 {}).items ()]
473+ if len (chat_record .improve_paragraph_id_list ) > 0 :
474+ paragraph_model_list = QuerySet (Paragraph ).filter (id__in = chat_record .improve_paragraph_id_list )
475+ if len (paragraph_model_list ) < len (chat_record .improve_paragraph_id_list ):
476+ paragraph_model_id_list = [str (p .id ) for p in paragraph_model_list ]
477+ chat_record .improve_paragraph_id_list = list (
478+ filter (lambda p_id : paragraph_model_id_list .__contains__ (p_id ),
479+ chat_record .improve_paragraph_id_list ))
480+ chat_record .save ()
471481
472482 return {
473483 ** ChatRecordSerializerModel (chat_record ).data ,
0 commit comments