From 472fadda615a169e2df2b37f1f5b45b15461ec65 Mon Sep 17 00:00:00 2001 From: Christian Tzolov Date: Sat, 23 Dec 2023 14:45:48 +0100 Subject: [PATCH] Update the VecotorStore pom versions - update boot to 3.2.1 - update vector-stores: postgresql (42.7.1) , pgvecgor (0.1.4), pinecone (0.7.1) azure-search (11.6.1), weaviate (4.5.0) - clean the auto-configuraito properties - resolve Milvus auto-conf property expossing external API. --- pom.xml | 12 ++-- spring-ai-spring-boot-autoconfigure/pom.xml | 9 +-- .../milvus/MilvusServiceClientProperties.java | 4 +- .../MilvusVectorStoreAutoConfiguration.java | 6 +- .../milvus/MilvusVectorStoreProperties.java | 55 ++++++++++++++----- .../PgVectorStoreAutoConfiguration.java | 1 - .../pgvector/PgVectorStoreProperties.java | 7 +-- .../PineconeVectorStoreProperties.java | 3 +- .../redis/RedisVectorStoreProperties.java | 4 +- 9 files changed, 60 insertions(+), 41 deletions(-) diff --git a/pom.xml b/pom.xml index 11750e8fa..d647dc807 100644 --- a/pom.xml +++ b/pom.xml @@ -93,7 +93,7 @@ 17 - 3.2.0 + 3.2.1 6.1.1 4.0.2 1.0.0-beta.6 @@ -104,14 +104,14 @@ 3.0.0 - 0.1.3 - 42.6.0 + 0.1.4 + 42.7.1 2.3.3 - 0.6.0 + 0.7.1 3.24.4 2.0.42 - 11.6.0 - 4.4.1 + 11.6.1 + 4.5.0 1.19.0 diff --git a/spring-ai-spring-boot-autoconfigure/pom.xml b/spring-ai-spring-boot-autoconfigure/pom.xml index f9a672140..8cb693f9f 100644 --- a/spring-ai-spring-boot-autoconfigure/pom.xml +++ b/spring-ai-spring-boot-autoconfigure/pom.xml @@ -132,7 +132,7 @@ ${project.parent.version} true - + org.springframework.ai @@ -140,13 +140,13 @@ ${project.parent.version} true - + redis.clients jedis 5.1.0 - + @@ -192,6 +192,7 @@ org.postgresql postgresql + ${postgresql.version} test @@ -208,7 +209,7 @@ ${testcontainers.version} test - + com.redis testcontainers-redis diff --git a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/vectorstore/milvus/MilvusServiceClientProperties.java b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/vectorstore/milvus/MilvusServiceClientProperties.java index 35e543c49..df445f23a 100644 --- a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/vectorstore/milvus/MilvusServiceClientProperties.java +++ b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/vectorstore/milvus/MilvusServiceClientProperties.java @@ -20,14 +20,12 @@ import java.util.concurrent.TimeUnit; import org.springframework.boot.context.properties.ConfigurationProperties; -import static org.springframework.ai.autoconfigure.vectorstore.milvus.MilvusServiceClientProperties.CONFIG_PREFIX; - /** * Parameters for Milvus client connection. * * @author Christian Tzolov */ -@ConfigurationProperties(CONFIG_PREFIX) +@ConfigurationProperties(MilvusServiceClientProperties.CONFIG_PREFIX) public class MilvusServiceClientProperties { public static final String CONFIG_PREFIX = "spring.ai.vectorstore.milvus.client"; diff --git a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/vectorstore/milvus/MilvusVectorStoreAutoConfiguration.java b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/vectorstore/milvus/MilvusVectorStoreAutoConfiguration.java index 99ecccc33..84f82fb6d 100644 --- a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/vectorstore/milvus/MilvusVectorStoreAutoConfiguration.java +++ b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/vectorstore/milvus/MilvusVectorStoreAutoConfiguration.java @@ -20,6 +20,8 @@ import java.util.concurrent.TimeUnit; import io.milvus.client.MilvusServiceClient; import io.milvus.param.ConnectParam; +import io.milvus.param.IndexType; +import io.milvus.param.MetricType; import org.springframework.ai.embedding.EmbeddingClient; import org.springframework.ai.vectorstore.MilvusVectorStore; @@ -48,8 +50,8 @@ public class MilvusVectorStoreAutoConfiguration { MilvusVectorStoreConfig config = MilvusVectorStoreConfig.builder() .withCollectionName(properties.getCollectionName()) .withDatabaseName(properties.getDatabaseName()) - .withIndexType(properties.getIndexType()) - .withMetricType(properties.getMetricType()) + .withIndexType(IndexType.valueOf(properties.getIndexType().name())) + .withMetricType(MetricType.valueOf(properties.getMetricType().name())) .withIndexParameters(properties.getIndexParameters()) .build(); diff --git a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/vectorstore/milvus/MilvusVectorStoreProperties.java b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/vectorstore/milvus/MilvusVectorStoreProperties.java index 9094ab9fc..bf2a61d49 100644 --- a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/vectorstore/milvus/MilvusVectorStoreProperties.java +++ b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/vectorstore/milvus/MilvusVectorStoreProperties.java @@ -16,19 +16,14 @@ package org.springframework.ai.autoconfigure.vectorstore.milvus; -import io.milvus.param.IndexType; -import io.milvus.param.MetricType; - import org.springframework.ai.vectorstore.MilvusVectorStore; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.util.Assert; -import static org.springframework.ai.autoconfigure.vectorstore.milvus.MilvusVectorStoreProperties.CONFIG_PREFIX; - /** * @author Christian Tzolov */ -@ConfigurationProperties(CONFIG_PREFIX) +@ConfigurationProperties(MilvusVectorStoreProperties.CONFIG_PREFIX) public class MilvusVectorStoreProperties { public static final String CONFIG_PREFIX = "spring.ai.vectorstore.milvus"; @@ -42,14 +37,46 @@ public class MilvusVectorStoreProperties { private int embeddingDimension = MilvusVectorStore.OPENAI_EMBEDDING_DIMENSION_SIZE; - private IndexType indexType = IndexType.IVF_FLAT; + private MilvusIndexType indexType = MilvusIndexType.IVF_FLAT; - private MetricType metricType = MetricType.COSINE; + private MilvusMetricType metricType = MilvusMetricType.COSINE; private String indexParameters = "{\"nlist\":1024}"; - public static String getConfigPrefix() { - return CONFIG_PREFIX; + public enum MilvusMetricType { + + /** + * Invalid metric type + */ + INVALID, + /** + * Euclidean distance + */ + L2, + /** + * Inner product + */ + IP, + /** + * Cosine distance + */ + COSINE, + /** + * Hamming distance + */ + HAMMING, + /** + * Jaccard distance + */ + JACCARD; + + } + + public enum MilvusIndexType { + + INVALID, FLAT, IVF_FLAT, IVF_SQ8, IVF_PQ, HNSW, DISKANN, AUTOINDEX, SCANN, GPU_IVF_FLAT, GPU_IVF_PQ, BIN_FLAT, + BIN_IVF_FLAT, TRIE, STL_SORT; + } public String getDatabaseName() { @@ -79,20 +106,20 @@ public class MilvusVectorStoreProperties { this.embeddingDimension = embeddingDimension; } - public IndexType getIndexType() { + public MilvusIndexType getIndexType() { return indexType; } - public void setIndexType(IndexType indexType) { + public void setIndexType(MilvusIndexType indexType) { Assert.notNull(indexType, "Index type can not be null"); this.indexType = indexType; } - public MetricType getMetricType() { + public MilvusMetricType getMetricType() { return metricType; } - public void setMetricType(MetricType metricType) { + public void setMetricType(MilvusMetricType metricType) { Assert.notNull(metricType, "MetricType can not be null"); this.metricType = metricType; } diff --git a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/vectorstore/pgvector/PgVectorStoreAutoConfiguration.java b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/vectorstore/pgvector/PgVectorStoreAutoConfiguration.java index cbdd9ed45..a3f34eb8d 100644 --- a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/vectorstore/pgvector/PgVectorStoreAutoConfiguration.java +++ b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/vectorstore/pgvector/PgVectorStoreAutoConfiguration.java @@ -17,7 +17,6 @@ package org.springframework.ai.autoconfigure.vectorstore.pgvector; import javax.sql.DataSource; - import org.springframework.ai.embedding.EmbeddingClient; import org.springframework.ai.vectorstore.PgVectorStore; import org.springframework.ai.vectorstore.VectorStore; diff --git a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/vectorstore/pgvector/PgVectorStoreProperties.java b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/vectorstore/pgvector/PgVectorStoreProperties.java index 77461d8ee..75b353466 100644 --- a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/vectorstore/pgvector/PgVectorStoreProperties.java +++ b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/vectorstore/pgvector/PgVectorStoreProperties.java @@ -20,12 +20,11 @@ import org.springframework.ai.vectorstore.PgVectorStore; import org.springframework.ai.vectorstore.PgVectorStore.PgDistanceType; import org.springframework.ai.vectorstore.PgVectorStore.PgIndexType; import org.springframework.boot.context.properties.ConfigurationProperties; -import static org.springframework.ai.autoconfigure.vectorstore.pgvector.PgVectorStoreProperties.CONFIG_PREFIX; /** * @author Christian Tzolov */ -@ConfigurationProperties(CONFIG_PREFIX) +@ConfigurationProperties(PgVectorStoreProperties.CONFIG_PREFIX) public class PgVectorStoreProperties { public static final String CONFIG_PREFIX = "spring.ai.vectorstore.pgvector"; @@ -38,10 +37,6 @@ public class PgVectorStoreProperties { private boolean removeExistingVectorStoreTable = false; - public static String getConfigPrefix() { - return CONFIG_PREFIX; - } - public int getDimensions() { return dimensions; } diff --git a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/vectorstore/pinecone/PineconeVectorStoreProperties.java b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/vectorstore/pinecone/PineconeVectorStoreProperties.java index ab5ef8dc9..d5a8779eb 100644 --- a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/vectorstore/pinecone/PineconeVectorStoreProperties.java +++ b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/vectorstore/pinecone/PineconeVectorStoreProperties.java @@ -19,12 +19,11 @@ package org.springframework.ai.autoconfigure.vectorstore.pinecone; import java.time.Duration; import org.springframework.boot.context.properties.ConfigurationProperties; -import static org.springframework.ai.autoconfigure.vectorstore.pinecone.PineconeVectorStoreProperties.CONFIG_PREFIX; /** * @author Christian Tzolov */ -@ConfigurationProperties(CONFIG_PREFIX) +@ConfigurationProperties(PineconeVectorStoreProperties.CONFIG_PREFIX) public class PineconeVectorStoreProperties { public static final String CONFIG_PREFIX = "spring.ai.vectorstore.pinecone"; diff --git a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/vectorstore/redis/RedisVectorStoreProperties.java b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/vectorstore/redis/RedisVectorStoreProperties.java index 2959336fe..f2faa3dd4 100644 --- a/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/vectorstore/redis/RedisVectorStoreProperties.java +++ b/spring-ai-spring-boot-autoconfigure/src/main/java/org/springframework/ai/autoconfigure/vectorstore/redis/RedisVectorStoreProperties.java @@ -18,12 +18,10 @@ package org.springframework.ai.autoconfigure.vectorstore.redis; import org.springframework.boot.context.properties.ConfigurationProperties; -import static org.springframework.ai.autoconfigure.vectorstore.redis.RedisVectorStoreProperties.CONFIG_PREFIX; - /** * @author Julien Ruaux */ -@ConfigurationProperties(CONFIG_PREFIX) +@ConfigurationProperties(RedisVectorStoreProperties.CONFIG_PREFIX) public class RedisVectorStoreProperties { public static final String CONFIG_PREFIX = "spring.ai.vectorstore.redis";