办学质量监测教学评价系统
ageer
2025-05-08 9cfcdd2b9b16ee4c5876315a2a0309e012e1520d
feat: 代码优化
已修改1个文件
64 ■■■■ 文件已修改
ruoyi-modules-api/ruoyi-knowledge-api/src/main/java/org/ruoyi/service/impl/VectorStoreServiceImpl.java 64 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-modules-api/ruoyi-knowledge-api/src/main/java/org/ruoyi/service/impl/VectorStoreServiceImpl.java
@@ -47,36 +47,40 @@
    @Override
    @PostConstruct
    public void createSchema(String kid,String modelName) {
        if(modelName.equals("weaviate")){
            String protocol = configService.getConfigValue("weaviate", "protocol");
            String host = configService.getConfigValue("weaviate", "host");
            String className = configService.getConfigValue("weaviate", "classname");
            this.embeddingStore = WeaviateEmbeddingStore.builder()
                    .scheme(protocol)
                    .host(host)
                    .objectClass(className+kid)
                    .scheme(protocol)
                    .avoidDups(true)
                    .consistencyLevel("ALL")
                    .build();
        }else if(modelName.equals("milvus")){
            String uri = configService.getConfigValue("milvus", "host");
            String collection = configService.getConfigValue("milvus", "collection");
            String dimension = configService.getConfigValue("milvus", "dimension");
            this.embeddingStore =  MilvusEmbeddingStore.builder()
                    .uri(uri)
                    .collectionName(collection+kid)
                    .dimension(Integer.parseInt(dimension))
                    .build();
        }else if(modelName.equals("qdrant")){
            String host = configService.getConfigValue("qdrant", "host");
            String port = configService.getConfigValue("qdrant", "port");
            String collectionName = configService.getConfigValue("qdrant", "collectionName");
            this.embeddingStore = QdrantEmbeddingStore.builder()
                            .host(host)
                            .port(Integer.parseInt(port))
                            .collectionName(collectionName)
                            .build();
        switch (modelName) {
            case "weaviate" -> {
                String protocol = configService.getConfigValue("weaviate", "protocol");
                String host = configService.getConfigValue("weaviate", "host");
                String className = configService.getConfigValue("weaviate", "classname");
                this.embeddingStore = WeaviateEmbeddingStore.builder()
                        .scheme(protocol)
                        .host(host)
                        .objectClass(className + kid)
                        .scheme(protocol)
                        .avoidDups(true)
                        .consistencyLevel("ALL")
                        .build();
            }
            case "milvus" -> {
                String uri = configService.getConfigValue("milvus", "host");
                String collection = configService.getConfigValue("milvus", "collection");
                String dimension = configService.getConfigValue("milvus", "dimension");
                this.embeddingStore = MilvusEmbeddingStore.builder()
                        .uri(uri)
                        .collectionName(collection + kid)
                        .dimension(Integer.parseInt(dimension))
                        .build();
            }
            case "qdrant" -> {
                String host = configService.getConfigValue("qdrant", "host");
                String port = configService.getConfigValue("qdrant", "port");
                String collectionName = configService.getConfigValue("qdrant", "collectionName");
                this.embeddingStore = QdrantEmbeddingStore.builder()
                        .host(host)
                        .port(Integer.parseInt(port))
                        .collectionName(collectionName)
                        .build();
            }
        }
    }