@@ -110,11 +110,16 @@ def embedding_by_paragraph_list(paragraph_id_list, embedding_model: Embeddings):
110110 @embedding_poxy
111111 def embedding_by_paragraph_data_list (data_list , paragraph_id_list , embedding_model : Embeddings ):
112112 max_kb .info (f'开始--->向量化段落:{ paragraph_id_list } ' )
113+ status = Status .success
113114 try :
114115 # 删除段落
115116 VectorStore .get_embedding_vector ().delete_by_paragraph_ids (paragraph_id_list )
117+
118+ def is_save_function ():
119+ return QuerySet (Paragraph ).filter (id__in = paragraph_id_list ).exists ()
120+
116121 # 批量向量化
117- VectorStore .get_embedding_vector ().batch_save (data_list , embedding_model )
122+ VectorStore .get_embedding_vector ().batch_save (data_list , embedding_model , is_save_function )
118123 except Exception as e :
119124 max_kb_error .error (f'向量化段落:{ paragraph_id_list } 出现错误{ str (e )} { traceback .format_exc ()} ' )
120125 status = Status .error
@@ -141,8 +146,12 @@ def embedding_by_paragraph(paragraph_id, embedding_model: Embeddings):
141146 os .path .join (PROJECT_DIR , "apps" , "common" , 'sql' , 'list_embedding_text.sql' )))
142147 # 删除段落
143148 VectorStore .get_embedding_vector ().delete_by_paragraph_id (paragraph_id )
149+
150+ def is_save_function ():
151+ return QuerySet (Paragraph ).filter (id = paragraph_id ).exists ()
152+
144153 # 批量向量化
145- VectorStore .get_embedding_vector ().batch_save (data_list , embedding_model )
154+ VectorStore .get_embedding_vector ().batch_save (data_list , embedding_model , is_save_function )
146155 except Exception as e :
147156 max_kb_error .error (f'向量化段落:{ paragraph_id } 出现错误{ str (e )} { traceback .format_exc ()} ' )
148157 status = Status .error
@@ -175,8 +184,12 @@ def embedding_by_document(document_id, embedding_model: Embeddings):
175184 os .path .join (PROJECT_DIR , "apps" , "common" , 'sql' , 'list_embedding_text.sql' )))
176185 # 删除文档向量数据
177186 VectorStore .get_embedding_vector ().delete_by_document_id (document_id )
187+
188+ def is_save_function ():
189+ return QuerySet (Document ).filter (id = document_id ).exists ()
190+
178191 # 批量向量化
179- VectorStore .get_embedding_vector ().batch_save (data_list , embedding_model )
192+ VectorStore .get_embedding_vector ().batch_save (data_list , embedding_model , is_save_function )
180193 except Exception as e :
181194 max_kb_error .error (f'向量化文档:{ document_id } 出现错误{ str (e )} { traceback .format_exc ()} ' )
182195 status = Status .error
0 commit comments