Browse Source

add:知识库删除添加删除向量库逻辑

zhongwei
luyie 2 months ago
parent
commit
77979ff640
  1. 1
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/KnowledgeFileInfoService.java
  2. 13
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/KnowledgeFileInfoServiceImpl.java

1
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/KnowledgeFileInfoService.java

@ -17,6 +17,7 @@ import java.util.List;
*/ */
public interface KnowledgeFileInfoService extends IService<KnowledgeFileInfo> { public interface KnowledgeFileInfoService extends IService<KnowledgeFileInfo> {
String SEGMENT_URL = "/kn/doc_segment"; String SEGMENT_URL = "/kn/doc_segment";
String VECTOR_DATABASE_NAME = "knowledge_data";
Boolean store(IdRequest req); Boolean store(IdRequest req);

13
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/KnowledgeFileInfoServiceImpl.java

@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnac.gglm.bigmodel.database.service.WeaviateService;
import com.hnac.gglm.bigmodel.maintenance.constants.StoreStatus; import com.hnac.gglm.bigmodel.maintenance.constants.StoreStatus;
import com.hnac.gglm.bigmodel.maintenance.entity.KnowledgeFileFragment; import com.hnac.gglm.bigmodel.maintenance.entity.KnowledgeFileFragment;
import com.hnac.gglm.bigmodel.maintenance.entity.KnowledgeFileInfo; import com.hnac.gglm.bigmodel.maintenance.entity.KnowledgeFileInfo;
@ -45,6 +46,7 @@ public class KnowledgeFileInfoServiceImpl extends ServiceImpl<KnowledgeFileInfoM
private final KnowledgeFileInfoMapper knowledgeFileInfoMapper; private final KnowledgeFileInfoMapper knowledgeFileInfoMapper;
private final KnowledgeFileFragmentService fileFragmentService; private final KnowledgeFileFragmentService fileFragmentService;
private final IOssClient ossClient; private final IOssClient ossClient;
private final WeaviateService weaviateService;
@Value("${gglm.url}") @Value("${gglm.url}")
private String interactionUrl; private String interactionUrl;
@ -119,7 +121,16 @@ public class KnowledgeFileInfoServiceImpl extends ServiceImpl<KnowledgeFileInfoM
public Boolean removeRecursive(List<Long> idsList) { public Boolean removeRecursive(List<Long> idsList) {
Boolean result = removeByIds(idsList); Boolean result = removeByIds(idsList);
if (result) { if (result) {
fileFragmentService.remove(Wrappers.<KnowledgeFileFragment>lambdaQuery().in(KnowledgeFileFragment::getDocId, idsList)); try {
fileFragmentService.remove(Wrappers.<KnowledgeFileFragment>lambdaQuery().in(KnowledgeFileFragment::getDocId, idsList));
for (Long id : idsList) {
Map<String, String> condition = new HashMap<>();
condition.put("doc_id", id.toString());
weaviateService.deleteCondition(VECTOR_DATABASE_NAME, condition);
}
} catch (Exception e) {
log.error("删除知识库文件文件出错", e);
}
} }
return result; return result;
} }

Loading…
Cancel
Save