diff --git a/apps/application/serializers/application_chat_record.py b/apps/application/serializers/application_chat_record.py index 08f0e5e93b1..04fb4a60907 100644 --- a/apps/application/serializers/application_chat_record.py +++ b/apps/application/serializers/application_chat_record.py @@ -110,6 +110,16 @@ def list(self, with_valid=True): return [ChatRecordSerializerModel(chat_record).data for chat_record in QuerySet(ChatRecord).filter(chat_id=self.data.get('chat_id')).order_by(order_by)] + @staticmethod + def get_loop_workflow_node(details): + result = [] + for item in details.values(): + if item.get('type') == 'loop-node': + for loop_item in item.get('loop_node_data') or []: + for inner_item in loop_item.values(): + result.append(inner_item) + return result + @staticmethod def reset_chat_record(chat_record, show_source, show_exec): knowledge_list = [] @@ -119,7 +129,8 @@ def reset_chat_record(chat_record, show_source, show_exec): paragraph_list = chat_record.details.get('search_step').get( 'paragraph_list') - for item in chat_record.details.values(): + for item in [*chat_record.details.values(), + *ApplicationChatRecordQuerySerializers.get_loop_workflow_node(chat_record.details)]: if item.get('type') == 'search-knowledge-node' and item.get('show_knowledge', False): paragraph_list = paragraph_list + (item.get( 'paragraph_list') or [])