mirror of
https://gitcode.com/ageerle/ruoyi-ai.git
synced 2026-04-01 05:53:43 +08:00
fix: 修复向量库初始化失败
This commit is contained in:
@@ -41,13 +41,13 @@ public class MilvusVectorStore implements VectorStore{
|
||||
@Resource
|
||||
private ConfigService configService;
|
||||
|
||||
@PostConstruct
|
||||
// @PostConstruct
|
||||
public void loadConfig() {
|
||||
this.dimension = Integer.parseInt(configService.getConfigValue("milvus", "dimension"));
|
||||
this.collectionName = configService.getConfigValue("milvus", "collection");
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
//@PostConstruct
|
||||
public void init(){
|
||||
String milvusHost = configService.getConfigValue("milvus", "host");
|
||||
String milvausPort = configService.getConfigValue("milvus", "port");
|
||||
|
||||
@@ -1,39 +1,32 @@
|
||||
package org.ruoyi.knowledge.chain.vectorstore;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.ruoyi.knowledge.domain.KnowledgeInfo;
|
||||
import org.ruoyi.knowledge.domain.vo.KnowledgeInfoVo;
|
||||
import org.ruoyi.knowledge.mapper.KnowledgeInfoMapper;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class VectorStoreFactory {
|
||||
|
||||
private final String type = "weaviate";
|
||||
|
||||
private final WeaviateVectorStore weaviateVectorStore;
|
||||
|
||||
private final MilvusVectorStore milvusVectorStore;
|
||||
|
||||
private final KnowledgeInfoMapper knowledgeInfoMapper;
|
||||
public VectorStoreFactory(WeaviateVectorStore weaviateVectorStore, MilvusVectorStore milvusVectorStore) {
|
||||
this.weaviateVectorStore = weaviateVectorStore;
|
||||
this.milvusVectorStore = milvusVectorStore;
|
||||
}
|
||||
|
||||
public VectorStore getVectorStore(String kid){
|
||||
KnowledgeInfoVo knowledgeInfoVo = knowledgeInfoMapper.selectVoOne(
|
||||
new LambdaQueryWrapper<KnowledgeInfo>().eq(KnowledgeInfo::getKid,kid)
|
||||
);
|
||||
String vectorModel = knowledgeInfoVo.getVector();
|
||||
if ("weaviate".equals(vectorModel)){
|
||||
return weaviateVectorStore;
|
||||
}else if ("milvus".equals(vectorModel)){
|
||||
return milvusVectorStore;
|
||||
}
|
||||
return null;
|
||||
// if ("weaviate".equals(type)){
|
||||
// return weaviateVectorStore;
|
||||
// }else if ("milvus".equals(type)){
|
||||
// return milvusVectorStore;
|
||||
// }
|
||||
//
|
||||
// return null;
|
||||
return weaviateVectorStore;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user