From c5b7dd9c46ada0ca4843e7449eee1854da9e5485 Mon Sep 17 00:00:00 2001 From: Josh Long Date: Mon, 6 May 2024 12:36:37 +0200 Subject: [PATCH] i ran the spring javaformat maven plugin to clean up any source code incompatabilities. --- .../vectorstore/azure/AzureVectorStore.java | 42 +++++++++---------- .../CassandraFilterExpressionConverter.java | 3 +- .../ai/vectorstore/ChromaVectorStore.java | 1 + .../vectorstore/ElasticsearchVectorStore.java | 1 + .../ai/vectorstore/MilvusVectorStore.java | 2 +- .../ai/vectorstore/Neo4jVectorStore.java | 10 ++--- .../ai/vectorstore/PgVectorStore.java | 16 +++---- .../vectorstore/qdrant/QdrantVectorStore.java | 25 +++++------ 8 files changed, 53 insertions(+), 47 deletions(-) diff --git a/vector-stores/spring-ai-azure-vector-store/src/main/java/org/springframework/ai/vectorstore/azure/AzureVectorStore.java b/vector-stores/spring-ai-azure-vector-store/src/main/java/org/springframework/ai/vectorstore/azure/AzureVectorStore.java index 071a48fa5..9a5205cfb 100644 --- a/vector-stores/spring-ai-azure-vector-store/src/main/java/org/springframework/ai/vectorstore/azure/AzureVectorStore.java +++ b/vector-stores/spring-ai-azure-vector-store/src/main/java/org/springframework/ai/vectorstore/azure/AzureVectorStore.java @@ -109,37 +109,37 @@ public class AzureVectorStore implements VectorStore, ApplicationListener fields = new ArrayList<>(); fields.add(new SearchField(ID_FIELD_NAME, SearchFieldDataType.STRING).setKey(true) - .setFilterable(true) - .setSortable(true)); + .setFilterable(true) + .setSortable(true)); fields.add(new SearchField(EMBEDDING_FIELD_NAME, SearchFieldDataType.collection(SearchFieldDataType.SINGLE)) - .setSearchable(true) - .setVectorSearchDimensions(dimensions) - // This must match a vector search configuration name. - .setVectorSearchProfileName(SPRING_AI_VECTOR_PROFILE)); + .setSearchable(true) + .setVectorSearchDimensions(dimensions) + // This must match a vector search configuration name. + .setVectorSearchProfileName(SPRING_AI_VECTOR_PROFILE)); fields.add(new SearchField(CONTENT_FIELD_NAME, SearchFieldDataType.STRING).setSearchable(true) - .setFilterable(true)); + .setFilterable(true)); fields.add(new SearchField(METADATA_FIELD_NAME, SearchFieldDataType.STRING).setSearchable(true) - .setFilterable(true)); + .setFilterable(true)); for (MetadataField filterableMetadataField : this.filterMetadataFields) { fields.add(new SearchField(METADATA_FIELD_PREFIX + filterableMetadataField.name(), filterableMetadataField.fieldType()) - .setSearchable(false) - .setFacetable(true)); + .setSearchable(false) + .setFacetable(true)); } SearchIndex searchIndex = new SearchIndex(this.indexName).setFields(fields) - // VectorSearch configuration is required for a vector field. The name used - // for the vector search algorithm configuration must match the configuration - // used by the search field used for vector search. - .setVectorSearch(new VectorSearch() - .setProfiles(Collections - .singletonList(new VectorSearchProfile(SPRING_AI_VECTOR_PROFILE, SPRING_AI_VECTOR_CONFIG))) - .setAlgorithms(Collections.singletonList(new HnswAlgorithmConfiguration(SPRING_AI_VECTOR_CONFIG) - .setParameters(new HnswParameters().setM(4) - .setEfConstruction(400) - .setEfSearch(1000) - .setMetric(VectorSearchAlgorithmMetric.COSINE))))); + // VectorSearch configuration is required for a vector field. The name used + // for the vector search algorithm configuration must match the configuration + // used by the search field used for vector search. + .setVectorSearch(new VectorSearch() + .setProfiles(Collections + .singletonList(new VectorSearchProfile(SPRING_AI_VECTOR_PROFILE, SPRING_AI_VECTOR_CONFIG))) + .setAlgorithms(Collections.singletonList(new HnswAlgorithmConfiguration(SPRING_AI_VECTOR_CONFIG) + .setParameters(new HnswParameters().setM(4) + .setEfConstruction(400) + .setEfSearch(1000) + .setMetric(VectorSearchAlgorithmMetric.COSINE))))); SearchIndex index = this.searchIndexClient.createOrUpdateIndex(searchIndex); diff --git a/vector-stores/spring-ai-cassandra/src/main/java/org/springframework/ai/vectorstore/CassandraFilterExpressionConverter.java b/vector-stores/spring-ai-cassandra/src/main/java/org/springframework/ai/vectorstore/CassandraFilterExpressionConverter.java index 15028f725..f3270ac81 100644 --- a/vector-stores/spring-ai-cassandra/src/main/java/org/springframework/ai/vectorstore/CassandraFilterExpressionConverter.java +++ b/vector-stores/spring-ai-cassandra/src/main/java/org/springframework/ai/vectorstore/CassandraFilterExpressionConverter.java @@ -32,7 +32,8 @@ import java.util.function.Function; import java.util.stream.Collectors; /** - * Converts {@link org.springframework.ai.vectorstore.filter.Filter.Expression} into CQL where clauses. + * Converts {@link org.springframework.ai.vectorstore.filter.Filter.Expression} into CQL + * where clauses. * * @author Mick Semb Wever * @since 1.0.0 diff --git a/vector-stores/spring-ai-chroma-store/src/main/java/org/springframework/ai/vectorstore/ChromaVectorStore.java b/vector-stores/spring-ai-chroma-store/src/main/java/org/springframework/ai/vectorstore/ChromaVectorStore.java index 411398a6d..3c9741cbe 100644 --- a/vector-stores/spring-ai-chroma-store/src/main/java/org/springframework/ai/vectorstore/ChromaVectorStore.java +++ b/vector-stores/spring-ai-chroma-store/src/main/java/org/springframework/ai/vectorstore/ChromaVectorStore.java @@ -153,4 +153,5 @@ public class ChromaVectorStore implements VectorStore, ApplicationListener { +public class MilvusVectorStore implements VectorStore, ApplicationListener { private static final Logger logger = LoggerFactory.getLogger(MilvusVectorStore.class); diff --git a/vector-stores/spring-ai-neo4j-store/src/main/java/org/springframework/ai/vectorstore/Neo4jVectorStore.java b/vector-stores/spring-ai-neo4j-store/src/main/java/org/springframework/ai/vectorstore/Neo4jVectorStore.java index bb1799584..8b5b3024f 100644 --- a/vector-stores/spring-ai-neo4j-store/src/main/java/org/springframework/ai/vectorstore/Neo4jVectorStore.java +++ b/vector-stores/spring-ai-neo4j-store/src/main/java/org/springframework/ai/vectorstore/Neo4jVectorStore.java @@ -52,8 +52,8 @@ public class Neo4jVectorStore implements VectorStore, ApplicationListener { +public class PgVectorStore implements VectorStore, ApplicationListener { private static final Logger logger = LoggerFactory.getLogger(PgVectorStore.class); @@ -82,7 +82,7 @@ public class PgVectorStore implements VectorStore, ApplicationListener { private static final String CONTENT_FIELD_NAME = "doc_content"; + private static final String DISTANCE_FIELD_NAME = "distance"; public static final String DEFAULT_COLLECTION_NAME = "vector_store"; @@ -89,6 +90,7 @@ public class QdrantVectorStore implements VectorStore, ApplicationListener d.floatValue()).toList(); } - private boolean isCollectionExists() { try { return this.qdrantClient.listCollectionsAsync().get().stream().anyMatch(c -> c.equals(this.collectionName));