7474parse_table_handle_list = [CsvParseTableHandle (), XlsParseTableHandle (), XlsxParseTableHandle ()]
7575
7676
77+ def convert_uuid_to_str (obj ):
78+ if isinstance (obj , dict ):
79+ return {k : convert_uuid_to_str (v ) for k , v in obj .items ()}
80+ elif isinstance (obj , list ):
81+ return [convert_uuid_to_str (i ) for i in obj ]
82+ elif isinstance (obj , uuid .UUID ):
83+ return str (obj )
84+ else :
85+ return obj
86+
87+
7788class BatchCancelInstanceSerializer (serializers .Serializer ):
7889 id_list = serializers .ListField (required = True , child = serializers .UUIDField (required = True ), label = _ ('id list' ))
7990 type = serializers .IntegerField (required = True , label = _ ('task type' ))
@@ -844,6 +855,9 @@ def get_paragraph_model(document_model, paragraph_list: List):
844855 @staticmethod
845856 def get_document_paragraph_model (knowledge_id , instance : Dict ):
846857 source_meta = {'source_file_id' : instance .get ('source_file_id' )} if instance .get ('source_file_id' ) else {}
858+ meta = {** instance .get ('meta' ), ** source_meta } if instance .get ('meta' ) is not None else source_meta
859+ meta = convert_uuid_to_str (meta )
860+
847861 document_model = Document (
848862 ** {
849863 'knowledge_id' : knowledge_id ,
@@ -853,8 +867,7 @@ def get_document_paragraph_model(knowledge_id, instance: Dict):
853867 lambda x , y : x + y ,
854868 [len (p .get ('content' )) for p in instance .get ('paragraphs' , [])],
855869 0 ),
856- 'meta' : {** instance .get ('meta' ), ** source_meta } if instance .get (
857- 'meta' ) is not None else source_meta ,
870+ 'meta' : meta ,
858871 'type' : instance .get ('type' ) if instance .get ('type' ) is not None else KnowledgeType .BASE
859872 })
860873
0 commit comments