mirror of
https://gitcode.com/ageerle/ruoyi-ai.git
synced 2026-04-16 05:13:41 +00:00
fix: 修复向量库初始化失败
This commit is contained in:
@@ -27,7 +27,7 @@ spring:
|
|||||||
driverClassName: com.mysql.cj.jdbc.Driver
|
driverClassName: com.mysql.cj.jdbc.Driver
|
||||||
url: jdbc:mysql://43.139.70.230:3306/ruoyi-ai?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true
|
url: jdbc:mysql://43.139.70.230:3306/ruoyi-ai?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true
|
||||||
username: ruoyi-ai
|
username: ruoyi-ai
|
||||||
password: eCaZ278N62k6fhYj
|
password: xx
|
||||||
|
|
||||||
hikari:
|
hikari:
|
||||||
# 最大连接池数量
|
# 最大连接池数量
|
||||||
|
|||||||
@@ -41,13 +41,13 @@ public class MilvusVectorStore implements VectorStore{
|
|||||||
@Resource
|
@Resource
|
||||||
private ConfigService configService;
|
private ConfigService configService;
|
||||||
|
|
||||||
@PostConstruct
|
// @PostConstruct
|
||||||
public void loadConfig() {
|
public void loadConfig() {
|
||||||
this.dimension = Integer.parseInt(configService.getConfigValue("milvus", "dimension"));
|
this.dimension = Integer.parseInt(configService.getConfigValue("milvus", "dimension"));
|
||||||
this.collectionName = configService.getConfigValue("milvus", "collection");
|
this.collectionName = configService.getConfigValue("milvus", "collection");
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostConstruct
|
//@PostConstruct
|
||||||
public void init(){
|
public void init(){
|
||||||
String milvusHost = configService.getConfigValue("milvus", "host");
|
String milvusHost = configService.getConfigValue("milvus", "host");
|
||||||
String milvausPort = configService.getConfigValue("milvus", "port");
|
String milvausPort = configService.getConfigValue("milvus", "port");
|
||||||
|
|||||||
@@ -1,39 +1,32 @@
|
|||||||
package org.ruoyi.knowledge.chain.vectorstore;
|
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 lombok.extern.slf4j.Slf4j;
|
||||||
import org.ruoyi.knowledge.domain.KnowledgeInfo;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.ruoyi.knowledge.domain.vo.KnowledgeInfoVo;
|
|
||||||
import org.ruoyi.knowledge.mapper.KnowledgeInfoMapper;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class VectorStoreFactory {
|
public class VectorStoreFactory {
|
||||||
|
|
||||||
|
private final String type = "weaviate";
|
||||||
|
|
||||||
private final WeaviateVectorStore weaviateVectorStore;
|
private final WeaviateVectorStore weaviateVectorStore;
|
||||||
|
|
||||||
private final MilvusVectorStore milvusVectorStore;
|
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){
|
public VectorStore getVectorStore(String kid){
|
||||||
KnowledgeInfoVo knowledgeInfoVo = knowledgeInfoMapper.selectVoOne(
|
// if ("weaviate".equals(type)){
|
||||||
new LambdaQueryWrapper<KnowledgeInfo>().eq(KnowledgeInfo::getKid,kid)
|
// return weaviateVectorStore;
|
||||||
);
|
// }else if ("milvus".equals(type)){
|
||||||
String vectorModel = knowledgeInfoVo.getVector();
|
// return milvusVectorStore;
|
||||||
if ("weaviate".equals(vectorModel)){
|
// }
|
||||||
return weaviateVectorStore;
|
//
|
||||||
}else if ("milvus".equals(vectorModel)){
|
// return null;
|
||||||
return milvusVectorStore;
|
return weaviateVectorStore;
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user