diff --git a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-hanadb/pom.xml b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-hanadb/pom.xml deleted file mode 100644 index 3a9a457b675..00000000000 --- a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-hanadb/pom.xml +++ /dev/null @@ -1,125 +0,0 @@ - - - - - 4.0.0 - - org.springframework.ai - spring-ai-parent - 1.0.0-SNAPSHOT - ../../../pom.xml - - spring-ai-autoconfigure-vector-store-hanadb - jar - Spring AI Auto Configuration for Hanadb vector store - Spring AI Auto Configuration for Hanadb vector store - https://github.com/spring-projects/spring-ai - - - https://github.com/spring-projects/spring-ai - git://github.com/spring-projects/spring-ai.git - git@github.com:spring-projects/spring-ai.git - - - - - - org.springframework.ai - spring-ai-hanadb-store - ${project.parent.version} - true - - - org.springframework.boot - spring-boot-starter - - - org.springframework.boot - spring-boot-configuration-processor - true - - - org.springframework.boot - spring-boot-autoconfigure-processor - true - - - - org.springframework.ai - spring-ai-test - ${project.parent.version} - test - - - org.springframework.boot - spring-boot-starter-test - test - - - org.springframework.boot - spring-boot-testcontainers - test - - - org.testcontainers - testcontainers - test - - - org.testcontainers - junit-jupiter - test - - - org.awaitility - awaitility - test - - - org.springframework.ai - spring-ai-transformers - ${project.parent.version} - test - - - org.springframework.ai - spring-ai-autoconfigure-retry - ${project.parent.version} - test - - - org.springframework.ai - spring-ai-autoconfigure-model-openai - ${project.parent.version} - test - - - org.springframework.ai - spring-ai-autoconfigure-model-tool - ${project.parent.version} - test - - - org.springframework.ai - spring-ai-openai - ${project.parent.version} - test - - - diff --git a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-hanadb/src/main/java/org/springframework/ai/vectorstore/hanadb/autoconfigure/HanaCloudVectorStoreAutoConfiguration.java b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-hanadb/src/main/java/org/springframework/ai/vectorstore/hanadb/autoconfigure/HanaCloudVectorStoreAutoConfiguration.java deleted file mode 100644 index f2fa1b055f8..00000000000 --- a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-hanadb/src/main/java/org/springframework/ai/vectorstore/hanadb/autoconfigure/HanaCloudVectorStoreAutoConfiguration.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2023-2024 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.ai.vectorstore.hanadb.autoconfigure; - -import javax.sql.DataSource; - -import io.micrometer.observation.ObservationRegistry; - -import org.springframework.ai.embedding.EmbeddingModel; -import org.springframework.ai.vectorstore.SpringAIVectorStoreTypes; -import org.springframework.ai.vectorstore.hanadb.HanaCloudVectorStore; -import org.springframework.ai.vectorstore.hanadb.HanaVectorEntity; -import org.springframework.ai.vectorstore.hanadb.HanaVectorRepository; -import org.springframework.ai.vectorstore.observation.VectorStoreObservationConvention; -import org.springframework.beans.factory.ObjectProvider; -import org.springframework.boot.autoconfigure.AutoConfiguration; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.context.annotation.Bean; - -/** - * {@link AutoConfiguration Auto-configuration} for Hana Cloud Vector Store. - * - * @author Rahul Mittal - * @author Christian Tzolov - * @author Soby Chacko - * @since 1.0.0 - */ -@AutoConfiguration(after = { JpaRepositoriesAutoConfiguration.class }) -@ConditionalOnClass({ HanaCloudVectorStore.class, DataSource.class, HanaVectorEntity.class }) -@EnableConfigurationProperties(HanaCloudVectorStoreProperties.class) -@ConditionalOnProperty(name = SpringAIVectorStoreTypes.TYPE, havingValue = SpringAIVectorStoreTypes.HANADB, - matchIfMissing = true) -public class HanaCloudVectorStoreAutoConfiguration { - - @Bean - @ConditionalOnMissingBean - public HanaCloudVectorStore vectorStore(HanaVectorRepository repository, - EmbeddingModel embeddingModel, HanaCloudVectorStoreProperties properties, - ObjectProvider observationRegistry, - ObjectProvider customObservationConvention) { - - return HanaCloudVectorStore.builder(repository, embeddingModel) - .tableName(properties.getTableName()) - .topK(properties.getTopK()) - .observationRegistry(observationRegistry.getIfUnique(() -> ObservationRegistry.NOOP)) - .customObservationConvention(customObservationConvention.getIfAvailable(() -> null)) - .build(); - } - -} diff --git a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-hanadb/src/main/java/org/springframework/ai/vectorstore/hanadb/autoconfigure/HanaCloudVectorStoreProperties.java b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-hanadb/src/main/java/org/springframework/ai/vectorstore/hanadb/autoconfigure/HanaCloudVectorStoreProperties.java deleted file mode 100644 index 932e151ebab..00000000000 --- a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-hanadb/src/main/java/org/springframework/ai/vectorstore/hanadb/autoconfigure/HanaCloudVectorStoreProperties.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2023-2024 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.ai.vectorstore.hanadb.autoconfigure; - -import org.springframework.boot.context.properties.ConfigurationProperties; - -/** - * Configuration properties for Hana Cloud Vector Store. - * - * @author Rahul Mittal - * @since 1.0.0 - */ -@ConfigurationProperties(HanaCloudVectorStoreProperties.CONFIG_PREFIX) -public class HanaCloudVectorStoreProperties { - - public static final String CONFIG_PREFIX = "spring.ai.vectorstore.hanadb"; - - private String tableName; - - private int topK; - - public String getTableName() { - return this.tableName; - } - - public void setTableName(String tableName) { - this.tableName = tableName; - } - - public int getTopK() { - return this.topK; - } - - public void setTopK(int topK) { - this.topK = topK; - } - -} diff --git a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-hanadb/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-hanadb/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports deleted file mode 100644 index 4542472d7ac..00000000000 --- a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-hanadb/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ /dev/null @@ -1,16 +0,0 @@ -# -# Copyright 2025-2025 the original author or authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -org.springframework.ai.vectorstore.hanadb.autoconfigure.HanaCloudVectorStoreAutoConfiguration diff --git a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-hanadb/src/test/java/org/springframework/ai/vectorstore/hanadb/autoconfigure/HanaCloudVectorStoreAutoConfigurationIT.java b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-hanadb/src/test/java/org/springframework/ai/vectorstore/hanadb/autoconfigure/HanaCloudVectorStoreAutoConfigurationIT.java deleted file mode 100644 index 42bb4eb41f6..00000000000 --- a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-hanadb/src/test/java/org/springframework/ai/vectorstore/hanadb/autoconfigure/HanaCloudVectorStoreAutoConfigurationIT.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright 2023-2024 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.ai.vectorstore.hanadb.autoconfigure; - -import java.util.List; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; - -import org.springframework.ai.document.Document; -import org.springframework.ai.model.openai.autoconfigure.OpenAiEmbeddingAutoConfiguration; -import org.springframework.ai.retry.autoconfigure.SpringAiRetryAutoConfiguration; -import org.springframework.ai.vectorstore.VectorStore; -import org.springframework.boot.autoconfigure.AutoConfigurations; -import org.springframework.boot.autoconfigure.data.jdbc.JdbcRepositoriesAutoConfiguration; -import org.springframework.boot.autoconfigure.web.client.RestClientAutoConfiguration; -import org.springframework.boot.test.context.runner.ApplicationContextRunner; - -@EnabledIfEnvironmentVariable(named = "OPENAI_API_KEY", matches = ".+") -@EnabledIfEnvironmentVariable(named = "HANA_DATASOURCE_URL", matches = ".+") -@EnabledIfEnvironmentVariable(named = "HANA_DATASOURCE_USERNAME", matches = ".+") -@EnabledIfEnvironmentVariable(named = "HANA_DATASOURCE_PASSWORD", matches = ".+") -@Disabled -public class HanaCloudVectorStoreAutoConfigurationIT { - - private final ApplicationContextRunner contextRunner = new ApplicationContextRunner() - .withConfiguration(AutoConfigurations.of(HanaCloudVectorStoreAutoConfiguration.class, - OpenAiEmbeddingAutoConfiguration.class, RestClientAutoConfiguration.class, - SpringAiRetryAutoConfiguration.class, JdbcRepositoriesAutoConfiguration.class)) - .withPropertyValues("spring.ai.openai.api-key=" + System.getenv("OPENAI_API_KEY"), - "spring.ai.openai.embedding.options.model=text-embedding-ada-002", - "spring.datasource.url=" + System.getenv("HANA_DATASOURCE_URL"), - "spring.datasource.username=" + System.getenv("HANA_DATASOURCE_USERNAME"), - "spring.datasource.password=" + System.getenv("HANA_DATASOURCE_PASSWORD"), - "spring.ai.vectorstore.hanadb.tableName=CRICKET_WORLD_CUP", "spring.ai.vectorstore.hanadb.topK=1"); - - List documents = List.of( - new Document("Spring AI rocks!! Spring AI rocks!! Spring AI rocks!! Spring AI rocks!! Spring AI rocks!!"), - new Document("Hello World Hello World Hello World Hello World Hello World Hello World Hello World"), - new Document( - "Great Depression Great Depression Great Depression Great Depression Great Depression Great Depression")); - - @Test - public void addAndSearch() { - this.contextRunner.run(context -> { - VectorStore vectorStore = context.getBean(VectorStore.class); - vectorStore.add(this.documents); - - List results = vectorStore.similaritySearch("What is Great Depression?"); - Assertions.assertEquals(1, results.size()); - - // Remove all documents from the store - vectorStore.delete(this.documents.stream().map(Document::getId).toList()); - List results2 = vectorStore.similaritySearch("Great Depression"); - Assertions.assertEquals(0, results2.size()); - }); - } - -} diff --git a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-hanadb/src/test/java/org/springframework/ai/vectorstore/hanadb/autoconfigure/HanaCloudVectorStorePropertiesTest.java b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-hanadb/src/test/java/org/springframework/ai/vectorstore/hanadb/autoconfigure/HanaCloudVectorStorePropertiesTest.java deleted file mode 100644 index 9a6ac5eb6ee..00000000000 --- a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-hanadb/src/test/java/org/springframework/ai/vectorstore/hanadb/autoconfigure/HanaCloudVectorStorePropertiesTest.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2023-2024 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.ai.vectorstore.hanadb.autoconfigure; - -import org.junit.Test; -import org.junit.jupiter.api.Assertions; - -/** - * @author Rahul Mittal - */ -public class HanaCloudVectorStorePropertiesTest { - - @Test - public void testHanaCloudVectorStoreProperties() { - var props = new HanaCloudVectorStoreProperties(); - props.setTableName("CRICKET_WORLD_CUP"); - props.setTopK(5); - - Assertions.assertEquals("CRICKET_WORLD_CUP", props.getTableName()); - Assertions.assertEquals(5, props.getTopK()); - } - -} diff --git a/pom.xml b/pom.xml index 55ca3e16e57..5198319b9c9 100644 --- a/pom.xml +++ b/pom.xml @@ -123,7 +123,6 @@ auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-couchbase auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-elasticsearch auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-gemfire - auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-hanadb auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-mariadb auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-milvus auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-mongodb-atlas @@ -146,7 +145,6 @@ spring-ai-spring-boot-starters/spring-ai-starter-vector-store-couchbase spring-ai-spring-boot-starters/spring-ai-starter-vector-store-elasticsearch spring-ai-spring-boot-starters/spring-ai-starter-vector-store-gemfire - spring-ai-spring-boot-starters/spring-ai-starter-vector-store-hanadb spring-ai-spring-boot-starters/spring-ai-starter-vector-store-mariadb spring-ai-spring-boot-starters/spring-ai-starter-vector-store-milvus spring-ai-spring-boot-starters/spring-ai-starter-vector-store-mongodb-atlas diff --git a/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/vectordbs/hana.adoc b/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/vectordbs/hana.adoc index b41681c4508..a46c291a128 100644 --- a/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/vectordbs/hana.adoc +++ b/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/vectordbs/hana.adoc @@ -5,34 +5,10 @@ * You need a SAP HANA Cloud vector engine account - Refer xref:api/vectordbs/hanadb-provision-a-trial-account.adoc[SAP HANA Cloud vector engine - provision a trial account] guide to create a trial account. * If required, an API key for the xref:api/embeddings.adoc#available-implementations[EmbeddingModel] to generate the embeddings stored by the vector store. - == Auto-configuration -[NOTE] -==== -There has been a significant change in the Spring AI auto-configuration, starter modules' artifact names. -Please refer to the https://docs.spring.io/spring-ai/reference/upgrade-notes.html[upgrade notes] for more information. -==== - -Spring AI provides Spring Boot auto-configuration for the SAP Hana Vector Store. -To enable it, add the following dependency to your project's Maven `pom.xml` file: - -[source, xml] ----- - - org.springframework.ai - spring-ai-starter-vector-store-hana - ----- - -or to your Gradle `build.gradle` build file. - -[source,groovy] ----- -dependencies { - implementation 'org.springframework.ai:spring-ai-starter-vector-store-hana' -} ----- +Spring AI does not provide a dedicated module for SAP Hana vector store. +Users are expected to provide their own configuration in the applications using the standard vector store module for SAP Hana vector store in Spring AI - `spring-ai-hanadb-store`. TIP: Refer to the xref:getting-started.adoc#dependency-management[Dependency Management] section to add the Spring AI BOM to your build file. @@ -317,6 +293,21 @@ public class CricketWorldCupHanaController { } ---- +Since HanaDB vector store support does not provide the autoconfiguration module, you also need to provide the vector store bean in your application, as shown below, as an example. + +[source,java] +---- +@Bean +public VectorStore hanaCloudVectorStore(CricketWorldCupRepository cricketWorldCupRepository, + EmbeddingModel embeddingModel) { + + return HanaCloudVectorStore.builder(cricketWorldCupRepository, embeddingModel) + .tableName("CRICKET_WORLD_CUP") + .topK(1) + .build(); +} +---- + * Use a `contextual` pdf file from wikipedia diff --git a/spring-ai-spring-boot-starters/spring-ai-starter-vector-store-hanadb/pom.xml b/spring-ai-spring-boot-starters/spring-ai-starter-vector-store-hanadb/pom.xml deleted file mode 100644 index 07ee33bd6dc..00000000000 --- a/spring-ai-spring-boot-starters/spring-ai-starter-vector-store-hanadb/pom.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - 4.0.0 - - org.springframework.ai - spring-ai-parent - 1.0.0-SNAPSHOT - ../../pom.xml - - spring-ai-starter-vector-store-hanadb - jar - Spring AI Starter - SAP Hana Cloud Vector Store - Spring AI SAP Hana Cloud Vector Store Starter - https://github.com/spring-projects/spring-ai - - - https://github.com/spring-projects/spring-ai - git://github.com/spring-projects/spring-ai.git - git@github.com:spring-projects/spring-ai.git - - - - - org.springframework.boot - spring-boot-starter - - - org.springframework.ai - spring-ai-autoconfigure-vector-store-hanadb - ${project.parent.version} - - - org.springframework.ai - spring-ai-autoconfigure-vector-store-observation - ${project.parent.version} - - - org.springframework.ai - spring-ai-hanadb-store - ${project.parent.version} - - - -