feat: 代码优化

This commit is contained in:
ageer
2025-05-08 19:00:48 +08:00
parent 980df20752
commit 9cfcdd2b9b

View File

@@ -47,7 +47,8 @@ public class VectorStoreServiceImpl implements VectorStoreService {
@Override @Override
@PostConstruct @PostConstruct
public void createSchema(String kid,String modelName) { public void createSchema(String kid,String modelName) {
if(modelName.equals("weaviate")){ switch (modelName) {
case "weaviate" -> {
String protocol = configService.getConfigValue("weaviate", "protocol"); String protocol = configService.getConfigValue("weaviate", "protocol");
String host = configService.getConfigValue("weaviate", "host"); String host = configService.getConfigValue("weaviate", "host");
String className = configService.getConfigValue("weaviate", "classname"); String className = configService.getConfigValue("weaviate", "classname");
@@ -59,7 +60,8 @@ public class VectorStoreServiceImpl implements VectorStoreService {
.avoidDups(true) .avoidDups(true)
.consistencyLevel("ALL") .consistencyLevel("ALL")
.build(); .build();
}else if(modelName.equals("milvus")){ }
case "milvus" -> {
String uri = configService.getConfigValue("milvus", "host"); String uri = configService.getConfigValue("milvus", "host");
String collection = configService.getConfigValue("milvus", "collection"); String collection = configService.getConfigValue("milvus", "collection");
String dimension = configService.getConfigValue("milvus", "dimension"); String dimension = configService.getConfigValue("milvus", "dimension");
@@ -68,7 +70,8 @@ public class VectorStoreServiceImpl implements VectorStoreService {
.collectionName(collection + kid) .collectionName(collection + kid)
.dimension(Integer.parseInt(dimension)) .dimension(Integer.parseInt(dimension))
.build(); .build();
}else if(modelName.equals("qdrant")){ }
case "qdrant" -> {
String host = configService.getConfigValue("qdrant", "host"); String host = configService.getConfigValue("qdrant", "host");
String port = configService.getConfigValue("qdrant", "port"); String port = configService.getConfigValue("qdrant", "port");
String collectionName = configService.getConfigValue("qdrant", "collectionName"); String collectionName = configService.getConfigValue("qdrant", "collectionName");
@@ -79,6 +82,7 @@ public class VectorStoreServiceImpl implements VectorStoreService {
.build(); .build();
} }
} }
}
@Override @Override
public void storeEmbeddings(StoreEmbeddingBo storeEmbeddingBo) { public void storeEmbeddings(StoreEmbeddingBo storeEmbeddingBo) {