From 1d18ecb354b823b568d244ba5cb257d9645393fe Mon Sep 17 00:00:00 2001 From: Soby Chacko Date: Mon, 14 Apr 2025 16:53:06 -0400 Subject: [PATCH] Addressing the remaining checkstyle failures Signed-off-by: Soby Chacko --- .../McpClientAutoConfiguration.java | 46 +-- .../McpToolCallbackAutoConfiguration.java | 40 +-- .../NamedClientMcpTransport.java | 29 +- ...eHttpClientTransportAutoConfiguration.java | 2 +- .../SseWebFluxTransportAutoConfiguration.java | 2 +- .../properties/McpSseClientProperties.java | 45 +-- .../properties/McpStdioClientProperties.java | 52 ++-- .../McpClientAutoConfigurationIT.java | 6 +- ...McpToolCallbackAutoConfigurationTests.java | 14 +- ...llbackAutoconfigurationConditionTests.java | 25 +- ...ClientTransportAutoConfigurationTests.java | 12 +- ...ebFluxTransportAutoConfigurationTests.java | 13 +- .../McpServerAutoConfiguration.java | 4 +- .../McpWebFluxServerAutoConfigurationIT.java | 21 +- .../McpWebMvcServerAutoConfigurationTest.java | 21 +- .../CosmosDBVectorStoreAutoConfiguration.java | 3 +- .../AzureVectorStoreProperties.java | 2 +- .../CassandraVectorStoreProperties.java | 2 +- ...ssandraVectorStoreAutoConfigurationIT.java | 2 +- .../ChromaVectorStoreAutoConfiguration.java | 2 +- .../ChromaVectorStoreProperties.java | 2 +- ...aseSearchVectorStoreAutoConfiguration.java | 6 +- .../CouchbaseSearchVectorStoreProperties.java | 5 +- .../CouchbaseContainerMetadata.java | 11 +- ...eSearchVectorStoreAutoConfigurationIT.java | 35 +-- .../ElasticsearchVectorStoreProperties.java | 2 +- ...csearchVectorStoreAutoConfigurationIT.java | 6 +- .../GemFireVectorStoreProperties.java | 2 +- ...GemFireVectorStoreAutoConfigurationIT.java | 4 +- ...naCloudVectorStoreAutoConfigurationIT.java | 2 +- .../MariaDbStoreAutoConfiguration.java | 5 +- .../autoconfigure/MariaDbStoreProperties.java | 2 +- .../MariaDbStoreAutoConfigurationIT.java | 27 +- .../MilvusVectorStoreAutoConfiguration.java | 2 +- .../MilvusVectorStoreProperties.java | 2 +- .../MilvusVectorStoreAutoConfigurationIT.java | 2 +- ...DBAtlasVectorStoreAutoConfigurationIT.java | 4 +- .../Neo4jVectorStoreProperties.java | 2 +- .../Neo4jVectorStoreAutoConfigurationIT.java | 2 +- ...penSearchVectorStoreAutoConfiguration.java | 2 +- ...nSearchVectorStoreAutoConfigurationIT.java | 4 +- ...nSearchVectorStoreAutoConfigurationIT.java | 6 +- .../OracleVectorStoreAutoConfiguration.java | 2 +- .../OracleVectorStoreProperties.java | 2 +- .../PgVectorStoreAutoConfiguration.java | 2 +- .../PgVectorStoreProperties.java | 2 +- .../PgVectorStoreAutoConfigurationIT.java | 4 +- .../PineconeVectorStoreAutoConfiguration.java | 2 +- ...ineconeVectorStoreAutoConfigurationIT.java | 4 +- .../RedisVectorStoreAutoConfiguration.java | 2 +- .../RedisVectorStoreAutoConfigurationIT.java | 2 +- ...TypesenseVectorStoreAutoConfiguration.java | 2 +- ...pesenseVectorStoreAutoConfigurationIT.java | 2 +- .../config/JsoupDocumentReaderConfig.java | 4 +- .../jsoup/JsoupDocumentReaderTests.java | 2 +- .../ai/reader/pdf/PagePdfDocumentReader.java | 4 +- .../pdf/ParagraphPdfDocumentReader.java | 4 +- .../reader/tika/TikaDocumentReaderTests.java | 2 + .../springframework/ai/mcp/McpToolUtils.java | 5 +- .../RetrievalAugmentationAdvisorIT.java | 2 +- .../CompressionQueryTransformerIT.java | 1 + .../RewriteQueryTransformerIT.java | 1 + .../VectorStoreDocumentRetrieverIT.java | 2 +- .../tests/tool/FunctionToolCallbackTests.java | 14 +- .../tests/tool/ToolCallingManagerTests.java | 2 +- .../tests/tool/domain/BookService.java | 2 +- .../vectorstore/SimpleVectorStoreIT.java | 13 +- ...usContainerConnectionDetailsFactoryIT.java | 4 +- ...ntContainerConnectionDetailsFactoryIT.java | 2 +- ...rWithApiKeyConnectionDetailsFactoryIT.java | 2 +- ...seContainerConnectionDetailsFactoryIT.java | 4 +- ...teContainerConnectionDetailsFactoryIT.java | 4 +- src/checkstyle/checkstyle-suppressions.xml | 2 + ...baseAiSearchFilterExpressionConverter.java | 5 +- .../CouchbaseIndexOptimization.java | 5 +- .../CouchbaseSearchVectorStore.java | 290 +++++++++--------- .../CouchbaseSimilarityFunction.java | 5 +- .../src/main/resources/application.properties | 1 - .../CouchbaseSearchVectorStoreIT.java | 39 ++- .../CouchbaseContainerMetadata.java | 11 +- .../src/test/resources/application.properties | 2 +- .../milvus/MilvusSearchRequest.java | 16 + .../milvus/MilvusSearchRequestTest.java | 24 +- .../milvus/MilvusVectorStoreTest.java | 21 +- 84 files changed, 544 insertions(+), 455 deletions(-) delete mode 100644 vector-stores/spring-ai-couchbase-store/src/main/resources/application.properties diff --git a/auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/main/java/org/springframework/ai/mcp/client/autoconfigure/McpClientAutoConfiguration.java b/auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/main/java/org/springframework/ai/mcp/client/autoconfigure/McpClientAutoConfiguration.java index 77077d43279..8fe163a5407 100644 --- a/auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/main/java/org/springframework/ai/mcp/client/autoconfigure/McpClientAutoConfiguration.java +++ b/auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/main/java/org/springframework/ai/mcp/client/autoconfigure/McpClientAutoConfiguration.java @@ -175,22 +175,6 @@ public List mcpSyncClients(McpSyncClientConfigurer mcpSyncClientC return mcpSyncClients; } - /** - * Record class that implements {@link AutoCloseable} to ensure proper cleanup of MCP - * clients. - * - *

- * This class is responsible for closing all MCP sync clients when the application - * context is closed, preventing resource leaks. - */ - public record CloseableMcpSyncClients(List clients) implements AutoCloseable { - - @Override - public void close() { - this.clients.forEach(McpSyncClient::close); - } - } - /** * Creates a closeable wrapper for MCP sync clients to ensure proper resource cleanup. * @param clients the list of MCP sync clients to manage @@ -258,13 +242,6 @@ public List mcpAsyncClients(McpAsyncClientConfigurer mcpSyncClie return mcpSyncClients; } - public record CloseableMcpAsyncClients(List clients) implements AutoCloseable { - @Override - public void close() { - this.clients.forEach(McpAsyncClient::close); - } - } - @Bean @ConditionalOnProperty(prefix = McpClientCommonProperties.CONFIG_PREFIX, name = "type", havingValue = "ASYNC") public CloseableMcpAsyncClients makeAsynClientsClosable(List clients) { @@ -278,4 +255,27 @@ McpAsyncClientConfigurer mcpAsyncClientConfigurer(ObjectProvider + * This class is responsible for closing all MCP sync clients when the application + * context is closed, preventing resource leaks. + */ + public record CloseableMcpSyncClients(List clients) implements AutoCloseable { + + @Override + public void close() { + this.clients.forEach(McpSyncClient::close); + } + } + + public record CloseableMcpAsyncClients(List clients) implements AutoCloseable { + @Override + public void close() { + this.clients.forEach(McpAsyncClient::close); + } + } + } diff --git a/auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/main/java/org/springframework/ai/mcp/client/autoconfigure/McpToolCallbackAutoConfiguration.java b/auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/main/java/org/springframework/ai/mcp/client/autoconfigure/McpToolCallbackAutoConfiguration.java index 65bd8ebbc8f..fe1801b1e14 100644 --- a/auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/main/java/org/springframework/ai/mcp/client/autoconfigure/McpToolCallbackAutoConfiguration.java +++ b/auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/main/java/org/springframework/ai/mcp/client/autoconfigure/McpToolCallbackAutoConfiguration.java @@ -40,26 +40,6 @@ @Conditional(McpToolCallbackAutoConfiguration.McpToolCallbackAutoconfigurationCondition.class) public class McpToolCallbackAutoConfiguration { - public static class McpToolCallbackAutoconfigurationCondition extends AllNestedConditions { - - public McpToolCallbackAutoconfigurationCondition() { - super(ConfigurationPhase.PARSE_CONFIGURATION); - } - - @ConditionalOnProperty(prefix = McpClientCommonProperties.CONFIG_PREFIX, name = "enabled", havingValue = "true", - matchIfMissing = true) - static class McpAutoConfigEnabled { - - } - - @ConditionalOnProperty(prefix = McpClientCommonProperties.CONFIG_PREFIX + ".toolcallback", name = "enabled", - havingValue = "true", matchIfMissing = false) - static class ToolCallbackProviderEnabled { - - } - - } - /** * Creates tool callbacks for all configured MCP clients. * @@ -84,4 +64,24 @@ public ToolCallbackProvider mcpAsyncToolCallbacks(ObjectProvider @@ -70,4 +63,12 @@ public Map getConnections() { return this.connections; } + /** + * Parameters for configuring an SSE connection to an MCP server. + * + * @param url the URL endpoint for SSE communication with the MCP server + */ + public record SseParameters(String url) { + } + } diff --git a/auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/main/java/org/springframework/ai/mcp/client/autoconfigure/properties/McpStdioClientProperties.java b/auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/main/java/org/springframework/ai/mcp/client/autoconfigure/properties/McpStdioClientProperties.java index e0f0ec8a7f6..f4d013b7a8f 100644 --- a/auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/main/java/org/springframework/ai/mcp/client/autoconfigure/properties/McpStdioClientProperties.java +++ b/auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/main/java/org/springframework/ai/mcp/client/autoconfigure/properties/McpStdioClientProperties.java @@ -73,32 +73,6 @@ public Map getConnections() { return this.connections; } - /** - * Record representing the parameters for an MCP server connection. - *

- * Includes the command to execute, command arguments, and environment variables. - */ - @JsonInclude(JsonInclude.Include.NON_ABSENT) - public record Parameters( - /** - * The command to execute for the MCP server. - */ - @JsonProperty("command") String command, - /** - * List of command arguments. - */ - @JsonProperty("args") List args, - /** - * Map of environment variables for the server process. - */ - @JsonProperty("env") Map env) { - - public ServerParameters toServerParameters() { - return ServerParameters.builder(this.command()).args(this.args()).env(this.env()).build(); - } - - } - private Map resourceToServerParameters() { try { Map> stdioConnection = new ObjectMapper().readValue( @@ -133,4 +107,30 @@ public Map toServerParameters() { return serverParameters; } + /** + * Record representing the parameters for an MCP server connection. + *

+ * Includes the command to execute, command arguments, and environment variables. + */ + @JsonInclude(JsonInclude.Include.NON_ABSENT) + public record Parameters( + /** + * The command to execute for the MCP server. + */ + @JsonProperty("command") String command, + /** + * List of command arguments. + */ + @JsonProperty("args") List args, + /** + * Map of environment variables for the server process. + */ + @JsonProperty("env") Map env) { + + public ServerParameters toServerParameters() { + return ServerParameters.builder(this.command()).args(this.args()).env(this.env()).build(); + } + + } + } diff --git a/auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/test/java/org/springframework/ai/mcp/client/autoconfigure/McpClientAutoConfigurationIT.java b/auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/test/java/org/springframework/ai/mcp/client/autoconfigure/McpClientAutoConfigurationIT.java index 8372ebdd340..0b988f80cba 100644 --- a/auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/test/java/org/springframework/ai/mcp/client/autoconfigure/McpClientAutoConfigurationIT.java +++ b/auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/test/java/org/springframework/ai/mcp/client/autoconfigure/McpClientAutoConfigurationIT.java @@ -121,9 +121,9 @@ void toolCallbacksCreation() { @Test void closeableWrappersCreation() { - this.contextRunner.withUserConfiguration(TestTransportConfiguration.class).run(context -> { - assertThat(context).hasSingleBean(McpClientAutoConfiguration.CloseableMcpSyncClients.class); - }); + this.contextRunner.withUserConfiguration(TestTransportConfiguration.class) + .run(context -> assertThat(context) + .hasSingleBean(McpClientAutoConfiguration.CloseableMcpSyncClients.class)); } @Configuration diff --git a/auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/test/java/org/springframework/ai/mcp/client/autoconfigure/McpToolCallbackAutoConfigurationTests.java b/auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/test/java/org/springframework/ai/mcp/client/autoconfigure/McpToolCallbackAutoConfigurationTests.java index 86202c87c5d..e813953b305 100644 --- a/auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/test/java/org/springframework/ai/mcp/client/autoconfigure/McpToolCallbackAutoConfigurationTests.java +++ b/auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/test/java/org/springframework/ai/mcp/client/autoconfigure/McpToolCallbackAutoConfigurationTests.java @@ -31,21 +31,21 @@ public class McpToolCallbackAutoConfigurationTests { @Test void disabledByDeafault() { - this.applicationContext.run((context) -> { + this.applicationContext.run(context -> { assertThat(context).doesNotHaveBean("mcpToolCallbacks"); assertThat(context).doesNotHaveBean("mcpAsyncToolCallbacks"); }); this.applicationContext .withPropertyValues("spring.ai.mcp.client.enabled=true", "spring.ai.mcp.client.type=SYNC") - .run((context) -> { + .run(context -> { assertThat(context).doesNotHaveBean("mcpToolCallbacks"); assertThat(context).doesNotHaveBean("mcpAsyncToolCallbacks"); }); this.applicationContext .withPropertyValues("spring.ai.mcp.client.enabled=true", "spring.ai.mcp.client.type=ASYNC") - .run((context) -> { + .run(context -> { assertThat(context).doesNotHaveBean("mcpToolCallbacks"); assertThat(context).doesNotHaveBean("mcpAsyncToolCallbacks"); }); @@ -55,7 +55,7 @@ void disabledByDeafault() { void enabledMcpToolCallbackAutoconfiguration() { // sync - this.applicationContext.withPropertyValues("spring.ai.mcp.client.toolcallback.enabled=true").run((context) -> { + this.applicationContext.withPropertyValues("spring.ai.mcp.client.toolcallback.enabled=true").run(context -> { assertThat(context).hasBean("mcpToolCallbacks"); assertThat(context).doesNotHaveBean("mcpAsyncToolCallbacks"); }); @@ -63,7 +63,7 @@ void enabledMcpToolCallbackAutoconfiguration() { this.applicationContext .withPropertyValues("spring.ai.mcp.client.enabled=true", "spring.ai.mcp.client.toolcallback.enabled=true", "spring.ai.mcp.client.type=SYNC") - .run((context) -> { + .run(context -> { assertThat(context).hasBean("mcpToolCallbacks"); assertThat(context).doesNotHaveBean("mcpAsyncToolCallbacks"); }); @@ -71,7 +71,7 @@ void enabledMcpToolCallbackAutoconfiguration() { // Async this.applicationContext .withPropertyValues("spring.ai.mcp.client.toolcallback.enabled=true", "spring.ai.mcp.client.type=ASYNC") - .run((context) -> { + .run(context -> { assertThat(context).doesNotHaveBean("mcpToolCallbacks"); assertThat(context).hasBean("mcpAsyncToolCallbacks"); }); @@ -79,7 +79,7 @@ void enabledMcpToolCallbackAutoconfiguration() { this.applicationContext .withPropertyValues("spring.ai.mcp.client.enabled=true", "spring.ai.mcp.client.toolcallback.enabled=true", "spring.ai.mcp.client.type=ASYNC") - .run((context) -> { + .run(context -> { assertThat(context).doesNotHaveBean("mcpToolCallbacks"); assertThat(context).hasBean("mcpAsyncToolCallbacks"); }); diff --git a/auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/test/java/org/springframework/ai/mcp/client/autoconfigure/McpToolCallbackAutoconfigurationConditionTests.java b/auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/test/java/org/springframework/ai/mcp/client/autoconfigure/McpToolCallbackAutoconfigurationConditionTests.java index 682ee6c4973..6e3226c7f38 100644 --- a/auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/test/java/org/springframework/ai/mcp/client/autoconfigure/McpToolCallbackAutoconfigurationConditionTests.java +++ b/auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/test/java/org/springframework/ai/mcp/client/autoconfigure/McpToolCallbackAutoconfigurationConditionTests.java @@ -38,54 +38,43 @@ public class McpToolCallbackAutoconfigurationConditionTests { void matchesWhenBothPropertiesAreEnabled() { this.contextRunner .withPropertyValues("spring.ai.mcp.client.enabled=true", "spring.ai.mcp.client.toolcallback.enabled=true") - .run(context -> { - assertThat(context).hasBean("testBean"); - }); + .run(context -> assertThat(context).hasBean("testBean")); } @Test void doesNotMatchWhenMcpClientIsDisabled() { this.contextRunner .withPropertyValues("spring.ai.mcp.client.enabled=false", "spring.ai.mcp.client.toolcallback.enabled=true") - .run(context -> { - assertThat(context).doesNotHaveBean("testBean"); - }); + .run(context -> assertThat(context).doesNotHaveBean("testBean")); } @Test void doesNotMatchWhenToolCallbackIsDisabled() { this.contextRunner .withPropertyValues("spring.ai.mcp.client.enabled=true", "spring.ai.mcp.client.toolcallback.enabled=false") - .run(context -> { - assertThat(context).doesNotHaveBean("testBean"); - }); + .run(context -> assertThat(context).doesNotHaveBean("testBean")); } @Test void doesNotMatchWhenBothPropertiesAreDisabled() { this.contextRunner .withPropertyValues("spring.ai.mcp.client.enabled=false", "spring.ai.mcp.client.toolcallback.enabled=false") - .run(context -> { - assertThat(context).doesNotHaveBean("testBean"); - }); + .run(context -> assertThat(context).doesNotHaveBean("testBean")); } @Test void doesNotMatchWhenToolCallbackPropertyIsMissing() { // McpClientEnabled is true by default if missing, but ToolCallbackEnabled is // false by default if missing - this.contextRunner.withPropertyValues("spring.ai.mcp.client.enabled=true").run(context -> { - assertThat(context).doesNotHaveBean("testBean"); - }); + this.contextRunner.withPropertyValues("spring.ai.mcp.client.enabled=true") + .run(context -> assertThat(context).doesNotHaveBean("testBean")); } @Test void doesNotMatchWhenBothPropertiesAreMissing() { // McpClientEnabled is true by default if missing, but ToolCallbackEnabled is // false by default if missing - this.contextRunner.run(context -> { - assertThat(context).doesNotHaveBean("testBean"); - }); + this.contextRunner.run(context -> assertThat(context).doesNotHaveBean("testBean")); } @Configuration diff --git a/auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/test/java/org/springframework/ai/mcp/client/autoconfigure/SseHttpClientTransportAutoConfigurationTests.java b/auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/test/java/org/springframework/ai/mcp/client/autoconfigure/SseHttpClientTransportAutoConfigurationTests.java index a48c3903c49..406502070b7 100644 --- a/auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/test/java/org/springframework/ai/mcp/client/autoconfigure/SseHttpClientTransportAutoConfigurationTests.java +++ b/auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/test/java/org/springframework/ai/mcp/client/autoconfigure/SseHttpClientTransportAutoConfigurationTests.java @@ -32,9 +32,7 @@ public class SseHttpClientTransportAutoConfigurationTests { @Test void mcpHttpClientTransportsNotPresentIfMissingWebFluxSseClientTransportPresent() { - this.applicationContext.run((context) -> { - assertThat(context.containsBean("mcpHttpClientTransports")).isFalse(); - }); + this.applicationContext.run(context -> assertThat(context.containsBean("mcpHttpClientTransports")).isFalse()); } @Test @@ -43,9 +41,7 @@ void mcpHttpClientTransportsPresentIfMissingWebFluxSseClientTransportNotPresent( this.applicationContext .withClassLoader( new FilteredClassLoader("io.modelcontextprotocol.client.transport.WebFluxSseClientTransport")) - .run((context) -> { - assertThat(context.containsBean("mcpHttpClientTransports")).isTrue(); - }); + .run(context -> assertThat(context.containsBean("mcpHttpClientTransports")).isTrue()); } @Test @@ -55,9 +51,7 @@ void mcpHttpClientTransportsNotPresentIfMcpClientDisabled() { .withClassLoader( new FilteredClassLoader("io.modelcontextprotocol.client.transport.WebFluxSseClientTransport")) .withPropertyValues("spring.ai.mcp.client.enabled", "false") - .run((context) -> { - assertThat(context.containsBean("mcpHttpClientTransports")).isFalse(); - }); + .run(context -> assertThat(context.containsBean("mcpHttpClientTransports")).isFalse()); } } diff --git a/auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/test/java/org/springframework/ai/mcp/client/autoconfigure/SseWebFluxTransportAutoConfigurationTests.java b/auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/test/java/org/springframework/ai/mcp/client/autoconfigure/SseWebFluxTransportAutoConfigurationTests.java index 449d71883a7..aad5272f0e0 100644 --- a/auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/test/java/org/springframework/ai/mcp/client/autoconfigure/SseWebFluxTransportAutoConfigurationTests.java +++ b/auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/test/java/org/springframework/ai/mcp/client/autoconfigure/SseWebFluxTransportAutoConfigurationTests.java @@ -32,9 +32,7 @@ public class SseWebFluxTransportAutoConfigurationTests { @Test void webFluxClientTransportsPresentIfWebFluxSseClientTransportPresent() { - this.applicationContext.run((context) -> { - assertThat(context.containsBean("webFluxClientTransports")).isTrue(); - }); + this.applicationContext.run(context -> assertThat(context.containsBean("webFluxClientTransports")).isTrue()); } @Test @@ -43,17 +41,14 @@ void webFluxClientTransportsNotPresentIfMissingWebFluxSseClientTransportNotPrese this.applicationContext .withClassLoader( new FilteredClassLoader("io.modelcontextprotocol.client.transport.WebFluxSseClientTransport")) - .run((context) -> { - assertThat(context.containsBean("webFluxClientTransports")).isFalse(); - }); + .run(context -> assertThat(context.containsBean("webFluxClientTransports")).isFalse()); } @Test void webFluxClientTransportsNotPresentIfMcpClientDisabled() { - this.applicationContext.withPropertyValues("spring.ai.mcp.client.enabled", "false").run((context) -> { - assertThat(context.containsBean("webFluxClientTransports")).isFalse(); - }); + this.applicationContext.withPropertyValues("spring.ai.mcp.client.enabled", "false") + .run(context -> assertThat(context.containsBean("webFluxClientTransports")).isFalse()); } } diff --git a/auto-configurations/mcp/spring-ai-autoconfigure-mcp-server/src/main/java/org/springframework/ai/mcp/server/autoconfigure/McpServerAutoConfiguration.java b/auto-configurations/mcp/spring-ai-autoconfigure-mcp-server/src/main/java/org/springframework/ai/mcp/server/autoconfigure/McpServerAutoConfiguration.java index 7c88552e618..2af9d61cba4 100644 --- a/auto-configurations/mcp/spring-ai-autoconfigure-mcp-server/src/main/java/org/springframework/ai/mcp/server/autoconfigure/McpServerAutoConfiguration.java +++ b/auto-configurations/mcp/spring-ai-autoconfigure-mcp-server/src/main/java/org/springframework/ai/mcp/server/autoconfigure/McpServerAutoConfiguration.java @@ -217,9 +217,7 @@ public McpSyncServer mcpSyncServer(McpServerTransportProvider transportProvider, } rootsChangeConsumers.ifAvailable(consumer -> { - serverBuilder.rootsChangeHandler((exchange, roots) -> { - consumer.accept(exchange, roots); - }); + serverBuilder.rootsChangeHandler((exchange, roots) -> consumer.accept(exchange, roots)); logger.info("Registered roots change consumer"); }); diff --git a/auto-configurations/mcp/spring-ai-autoconfigure-mcp-server/src/test/java/org/springframework/ai/mcp/server/autoconfigure/McpWebFluxServerAutoConfigurationIT.java b/auto-configurations/mcp/spring-ai-autoconfigure-mcp-server/src/test/java/org/springframework/ai/mcp/server/autoconfigure/McpWebFluxServerAutoConfigurationIT.java index e05b290019d..4f6c646621d 100644 --- a/auto-configurations/mcp/spring-ai-autoconfigure-mcp-server/src/test/java/org/springframework/ai/mcp/server/autoconfigure/McpWebFluxServerAutoConfigurationIT.java +++ b/auto-configurations/mcp/spring-ai-autoconfigure-mcp-server/src/test/java/org/springframework/ai/mcp/server/autoconfigure/McpWebFluxServerAutoConfigurationIT.java @@ -1,3 +1,19 @@ +/* + * 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. + */ + package org.springframework.ai.mcp.server.autoconfigure; import com.fasterxml.jackson.databind.ObjectMapper; @@ -33,9 +49,8 @@ void objectMapperConfiguration() { @Test void stdioEnabledConfiguration() { - this.contextRunner.withPropertyValues("spring.ai.mcp.server.stdio=true").run(context -> { - assertThat(context).doesNotHaveBean(WebFluxSseServerTransportProvider.class); - }); + this.contextRunner.withPropertyValues("spring.ai.mcp.server.stdio=true") + .run(context -> assertThat(context).doesNotHaveBean(WebFluxSseServerTransportProvider.class)); } } diff --git a/auto-configurations/mcp/spring-ai-autoconfigure-mcp-server/src/test/java/org/springframework/ai/mcp/server/autoconfigure/McpWebMvcServerAutoConfigurationTest.java b/auto-configurations/mcp/spring-ai-autoconfigure-mcp-server/src/test/java/org/springframework/ai/mcp/server/autoconfigure/McpWebMvcServerAutoConfigurationTest.java index d9a45a6efc5..0ebf4c78ab5 100644 --- a/auto-configurations/mcp/spring-ai-autoconfigure-mcp-server/src/test/java/org/springframework/ai/mcp/server/autoconfigure/McpWebMvcServerAutoConfigurationTest.java +++ b/auto-configurations/mcp/spring-ai-autoconfigure-mcp-server/src/test/java/org/springframework/ai/mcp/server/autoconfigure/McpWebMvcServerAutoConfigurationTest.java @@ -1,3 +1,19 @@ +/* + * 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. + */ + package org.springframework.ai.mcp.server.autoconfigure; import com.fasterxml.jackson.databind.ObjectMapper; @@ -33,9 +49,8 @@ void objectMapperConfiguration() { @Test void stdioEnabledConfiguration() { - this.contextRunner.withPropertyValues("spring.ai.mcp.server.stdio=true").run(context -> { - assertThat(context).doesNotHaveBean(WebMvcSseServerTransportProvider.class); - }); + this.contextRunner.withPropertyValues("spring.ai.mcp.server.stdio=true") + .run(context -> assertThat(context).doesNotHaveBean(WebMvcSseServerTransportProvider.class)); } } diff --git a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-azure-cosmos-db/src/main/java/org/springframework/ai/vectorstore/cosmosdb/autoconfigure/CosmosDBVectorStoreAutoConfiguration.java b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-azure-cosmos-db/src/main/java/org/springframework/ai/vectorstore/cosmosdb/autoconfigure/CosmosDBVectorStoreAutoConfiguration.java index b11a606a868..bb401ce7306 100644 --- a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-azure-cosmos-db/src/main/java/org/springframework/ai/vectorstore/cosmosdb/autoconfigure/CosmosDBVectorStoreAutoConfiguration.java +++ b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-azure-cosmos-db/src/main/java/org/springframework/ai/vectorstore/cosmosdb/autoconfigure/CosmosDBVectorStoreAutoConfiguration.java @@ -16,6 +16,8 @@ package org.springframework.ai.vectorstore.cosmosdb.autoconfigure; +import java.util.List; + import com.azure.cosmos.CosmosAsyncClient; import com.azure.cosmos.CosmosClientBuilder; import io.micrometer.observation.ObservationRegistry; @@ -33,7 +35,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; -import java.util.List; /** * {@link AutoConfiguration Auto-configuration} for CosmosDB Vector Store. diff --git a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-azure/src/main/java/org/springframework/ai/vectorstore/azure/autoconfigure/AzureVectorStoreProperties.java b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-azure/src/main/java/org/springframework/ai/vectorstore/azure/autoconfigure/AzureVectorStoreProperties.java index cafde9578ec..519b93ce5bc 100644 --- a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-azure/src/main/java/org/springframework/ai/vectorstore/azure/autoconfigure/AzureVectorStoreProperties.java +++ b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-azure/src/main/java/org/springframework/ai/vectorstore/azure/autoconfigure/AzureVectorStoreProperties.java @@ -16,8 +16,8 @@ package org.springframework.ai.vectorstore.azure.autoconfigure; -import org.springframework.ai.vectorstore.properties.CommonVectorStoreProperties; import org.springframework.ai.vectorstore.azure.AzureVectorStore; +import org.springframework.ai.vectorstore.properties.CommonVectorStoreProperties; import org.springframework.boot.context.properties.ConfigurationProperties; /** diff --git a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-cassandra/src/main/java/org/springframework/ai/vectorstore/cassandra/autoconfigure/CassandraVectorStoreProperties.java b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-cassandra/src/main/java/org/springframework/ai/vectorstore/cassandra/autoconfigure/CassandraVectorStoreProperties.java index f93cc9e38bb..a9c960f07ac 100644 --- a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-cassandra/src/main/java/org/springframework/ai/vectorstore/cassandra/autoconfigure/CassandraVectorStoreProperties.java +++ b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-cassandra/src/main/java/org/springframework/ai/vectorstore/cassandra/autoconfigure/CassandraVectorStoreProperties.java @@ -19,8 +19,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.ai.vectorstore.properties.CommonVectorStoreProperties; import org.springframework.ai.vectorstore.cassandra.CassandraVectorStore; +import org.springframework.ai.vectorstore.properties.CommonVectorStoreProperties; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.util.Assert; diff --git a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-cassandra/src/test/java/org/springframework/ai/vectorstore/cassandra/autoconfigure/CassandraVectorStoreAutoConfigurationIT.java b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-cassandra/src/test/java/org/springframework/ai/vectorstore/cassandra/autoconfigure/CassandraVectorStoreAutoConfigurationIT.java index 78aa9b6d140..26cef92371e 100644 --- a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-cassandra/src/test/java/org/springframework/ai/vectorstore/cassandra/autoconfigure/CassandraVectorStoreAutoConfigurationIT.java +++ b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-cassandra/src/test/java/org/springframework/ai/vectorstore/cassandra/autoconfigure/CassandraVectorStoreAutoConfigurationIT.java @@ -26,12 +26,12 @@ import org.testcontainers.junit.jupiter.Testcontainers; import org.testcontainers.utility.DockerImageName; -import org.springframework.ai.util.ResourceUtils; import org.springframework.ai.document.Document; import org.springframework.ai.embedding.EmbeddingModel; import org.springframework.ai.observation.conventions.VectorStoreProvider; import org.springframework.ai.test.vectorstore.ObservationTestUtil; import org.springframework.ai.transformers.TransformersEmbeddingModel; +import org.springframework.ai.util.ResourceUtils; import org.springframework.ai.vectorstore.SearchRequest; import org.springframework.ai.vectorstore.VectorStore; import org.springframework.ai.vectorstore.cassandra.CassandraVectorStore; diff --git a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-chroma/src/main/java/org/springframework/ai/vectorstore/chroma/autoconfigure/ChromaVectorStoreAutoConfiguration.java b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-chroma/src/main/java/org/springframework/ai/vectorstore/chroma/autoconfigure/ChromaVectorStoreAutoConfiguration.java index 2296180b441..6f96c5aaa4f 100644 --- a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-chroma/src/main/java/org/springframework/ai/vectorstore/chroma/autoconfigure/ChromaVectorStoreAutoConfiguration.java +++ b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-chroma/src/main/java/org/springframework/ai/vectorstore/chroma/autoconfigure/ChromaVectorStoreAutoConfiguration.java @@ -20,10 +20,10 @@ import io.micrometer.observation.ObservationRegistry; import org.springframework.ai.chroma.vectorstore.ChromaApi; +import org.springframework.ai.chroma.vectorstore.ChromaVectorStore; import org.springframework.ai.embedding.BatchingStrategy; import org.springframework.ai.embedding.EmbeddingModel; import org.springframework.ai.embedding.TokenCountBatchingStrategy; -import org.springframework.ai.chroma.vectorstore.ChromaVectorStore; import org.springframework.ai.vectorstore.SpringAIVectorStoreTypes; import org.springframework.ai.vectorstore.observation.VectorStoreObservationConvention; import org.springframework.beans.factory.ObjectProvider; diff --git a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-chroma/src/main/java/org/springframework/ai/vectorstore/chroma/autoconfigure/ChromaVectorStoreProperties.java b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-chroma/src/main/java/org/springframework/ai/vectorstore/chroma/autoconfigure/ChromaVectorStoreProperties.java index 81fc4acf5cd..3098eb4e5e2 100644 --- a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-chroma/src/main/java/org/springframework/ai/vectorstore/chroma/autoconfigure/ChromaVectorStoreProperties.java +++ b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-chroma/src/main/java/org/springframework/ai/vectorstore/chroma/autoconfigure/ChromaVectorStoreProperties.java @@ -16,8 +16,8 @@ package org.springframework.ai.vectorstore.chroma.autoconfigure; -import org.springframework.ai.vectorstore.properties.CommonVectorStoreProperties; import org.springframework.ai.chroma.vectorstore.ChromaVectorStore; +import org.springframework.ai.vectorstore.properties.CommonVectorStoreProperties; import org.springframework.boot.context.properties.ConfigurationProperties; /** diff --git a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-couchbase/src/main/java/org/springframework/ai/vectorstore/couchbase/autoconfigure/CouchbaseSearchVectorStoreAutoConfiguration.java b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-couchbase/src/main/java/org/springframework/ai/vectorstore/couchbase/autoconfigure/CouchbaseSearchVectorStoreAutoConfiguration.java index 2e6a2b442a9..25aa0617930 100644 --- a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-couchbase/src/main/java/org/springframework/ai/vectorstore/couchbase/autoconfigure/CouchbaseSearchVectorStoreAutoConfiguration.java +++ b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-couchbase/src/main/java/org/springframework/ai/vectorstore/couchbase/autoconfigure/CouchbaseSearchVectorStoreAutoConfiguration.java @@ -1,11 +1,11 @@ /* - * Copyright 2023 - 2025 the original author or authors. + * 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 + * 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, @@ -13,9 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.ai.vectorstore.couchbase.autoconfigure; import com.couchbase.client.java.Cluster; + import org.springframework.ai.embedding.EmbeddingModel; import org.springframework.ai.vectorstore.CouchbaseSearchVectorStore; import org.springframework.boot.autoconfigure.AutoConfiguration; diff --git a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-couchbase/src/main/java/org/springframework/ai/vectorstore/couchbase/autoconfigure/CouchbaseSearchVectorStoreProperties.java b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-couchbase/src/main/java/org/springframework/ai/vectorstore/couchbase/autoconfigure/CouchbaseSearchVectorStoreProperties.java index 0af6d225e62..c75cabcdfd8 100644 --- a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-couchbase/src/main/java/org/springframework/ai/vectorstore/couchbase/autoconfigure/CouchbaseSearchVectorStoreProperties.java +++ b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-couchbase/src/main/java/org/springframework/ai/vectorstore/couchbase/autoconfigure/CouchbaseSearchVectorStoreProperties.java @@ -1,11 +1,11 @@ /* - * Copyright 2023 - 2025 the original author or authors. + * 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 + * 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, @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.ai.vectorstore.couchbase.autoconfigure; import org.springframework.ai.vectorstore.CouchbaseIndexOptimization; diff --git a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-couchbase/src/test/java/org/springframework/ai/vectorstore/couchbase/autoconfigure/CouchbaseContainerMetadata.java b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-couchbase/src/test/java/org/springframework/ai/vectorstore/couchbase/autoconfigure/CouchbaseContainerMetadata.java index 73bf9533e8c..f8558372515 100644 --- a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-couchbase/src/test/java/org/springframework/ai/vectorstore/couchbase/autoconfigure/CouchbaseContainerMetadata.java +++ b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-couchbase/src/test/java/org/springframework/ai/vectorstore/couchbase/autoconfigure/CouchbaseContainerMetadata.java @@ -1,11 +1,11 @@ /* - * Copyright 2023 - 2025 the original author or authors. + * 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 + * 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, @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.ai.vectorstore.couchbase.autoconfigure; import org.testcontainers.couchbase.BucketDefinition; @@ -22,7 +23,7 @@ * @author Laurent Doguin * @since 1.0.0 */ -public class CouchbaseContainerMetadata { +public final class CouchbaseContainerMetadata { public static final String BUCKET_NAME = "example"; @@ -36,4 +37,8 @@ public class CouchbaseContainerMetadata { .asCompatibleSubstituteFor("couchbase/server") .withTag("enterprise-7.6.1"); + private CouchbaseContainerMetadata() { + // Avoids instantiation + } + } diff --git a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-couchbase/src/test/java/org/springframework/ai/vectorstore/couchbase/autoconfigure/CouchbaseSearchVectorStoreAutoConfigurationIT.java b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-couchbase/src/test/java/org/springframework/ai/vectorstore/couchbase/autoconfigure/CouchbaseSearchVectorStoreAutoConfigurationIT.java index 0b7531484aa..bb8cc8b646c 100644 --- a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-couchbase/src/test/java/org/springframework/ai/vectorstore/couchbase/autoconfigure/CouchbaseSearchVectorStoreAutoConfigurationIT.java +++ b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-couchbase/src/test/java/org/springframework/ai/vectorstore/couchbase/autoconfigure/CouchbaseSearchVectorStoreAutoConfigurationIT.java @@ -1,11 +1,11 @@ /* - * Copyright 2023 - 2025 the original author or authors. + * 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 + * 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, @@ -13,10 +13,21 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.ai.vectorstore.couchbase.autoconfigure; +import java.time.Duration; +import java.util.List; +import java.util.Map; + import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; +import org.testcontainers.containers.wait.strategy.Wait; +import org.testcontainers.couchbase.CouchbaseContainer; +import org.testcontainers.couchbase.CouchbaseService; +import org.testcontainers.junit.jupiter.Container; +import org.testcontainers.junit.jupiter.Testcontainers; + import org.springframework.ai.document.Document; import org.springframework.ai.model.openai.autoconfigure.OpenAiEmbeddingAutoConfiguration; import org.springframework.ai.retry.autoconfigure.SpringAiRetryAutoConfiguration; @@ -28,21 +39,8 @@ import org.springframework.boot.autoconfigure.couchbase.CouchbaseAutoConfiguration; import org.springframework.boot.autoconfigure.web.client.RestClientAutoConfiguration; import org.springframework.boot.test.context.runner.ApplicationContextRunner; -import org.testcontainers.containers.wait.strategy.Wait; -import org.testcontainers.couchbase.CouchbaseContainer; -import org.testcontainers.couchbase.CouchbaseService; -import org.testcontainers.junit.jupiter.Container; -import org.testcontainers.junit.jupiter.Testcontainers; - -import java.time.Duration; -import java.util.List; -import java.util.Map; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.ai.vectorstore.couchbase.autoconfigure.CouchbaseContainerMetadata.COUCHBASE_IMAGE_ENTERPRISE; -import static org.springframework.ai.vectorstore.couchbase.autoconfigure.CouchbaseContainerMetadata.PASSWORD; -import static org.springframework.ai.vectorstore.couchbase.autoconfigure.CouchbaseContainerMetadata.USERNAME; -import static org.springframework.ai.vectorstore.couchbase.autoconfigure.CouchbaseContainerMetadata.bucketDefinition; /** * @author Laurent Doguin @@ -54,11 +52,12 @@ class CouchbaseSearchVectorStoreAutoConfigurationIT { // Define the couchbase container. @Container - final static CouchbaseContainer couchbaseContainer = new CouchbaseContainer(COUCHBASE_IMAGE_ENTERPRISE) - .withCredentials(USERNAME, PASSWORD) + final static CouchbaseContainer couchbaseContainer = new CouchbaseContainer( + CouchbaseContainerMetadata.COUCHBASE_IMAGE_ENTERPRISE) + .withCredentials(CouchbaseContainerMetadata.USERNAME, CouchbaseContainerMetadata.PASSWORD) .withEnabledServices(CouchbaseService.KV, CouchbaseService.QUERY, CouchbaseService.INDEX, CouchbaseService.SEARCH) - .withBucket(bucketDefinition) + .withBucket(CouchbaseContainerMetadata.bucketDefinition) .withStartupAttempts(4) .withStartupTimeout(Duration.ofSeconds(90)) .waitingFor(Wait.forHealthcheck()); diff --git a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-elasticsearch/src/main/java/org/springframework/ai/vectorstore/elasticsearch/autoconfigure/ElasticsearchVectorStoreProperties.java b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-elasticsearch/src/main/java/org/springframework/ai/vectorstore/elasticsearch/autoconfigure/ElasticsearchVectorStoreProperties.java index c1f869c8d56..4c0e4c9cdfc 100644 --- a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-elasticsearch/src/main/java/org/springframework/ai/vectorstore/elasticsearch/autoconfigure/ElasticsearchVectorStoreProperties.java +++ b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-elasticsearch/src/main/java/org/springframework/ai/vectorstore/elasticsearch/autoconfigure/ElasticsearchVectorStoreProperties.java @@ -16,8 +16,8 @@ package org.springframework.ai.vectorstore.elasticsearch.autoconfigure; -import org.springframework.ai.vectorstore.properties.CommonVectorStoreProperties; import org.springframework.ai.vectorstore.elasticsearch.SimilarityFunction; +import org.springframework.ai.vectorstore.properties.CommonVectorStoreProperties; import org.springframework.boot.context.properties.ConfigurationProperties; /** diff --git a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-elasticsearch/src/test/java/org/springframework/ai/vectorstore/elasticsearch/autoconfigure/ElasticsearchVectorStoreAutoConfigurationIT.java b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-elasticsearch/src/test/java/org/springframework/ai/vectorstore/elasticsearch/autoconfigure/ElasticsearchVectorStoreAutoConfigurationIT.java index d2c194ce6cc..e86548e4be7 100644 --- a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-elasticsearch/src/test/java/org/springframework/ai/vectorstore/elasticsearch/autoconfigure/ElasticsearchVectorStoreAutoConfigurationIT.java +++ b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-elasticsearch/src/test/java/org/springframework/ai/vectorstore/elasticsearch/autoconfigure/ElasticsearchVectorStoreAutoConfigurationIT.java @@ -29,14 +29,14 @@ import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; -import org.springframework.ai.model.openai.autoconfigure.OpenAiEmbeddingAutoConfiguration; -import org.springframework.ai.retry.autoconfigure.SpringAiRetryAutoConfiguration; import org.springframework.ai.document.Document; +import org.springframework.ai.model.openai.autoconfigure.OpenAiEmbeddingAutoConfiguration; import org.springframework.ai.observation.conventions.VectorStoreProvider; +import org.springframework.ai.retry.autoconfigure.SpringAiRetryAutoConfiguration; import org.springframework.ai.test.vectorstore.ObservationTestUtil; +import org.springframework.ai.vectorstore.SearchRequest; import org.springframework.ai.vectorstore.VectorStore; import org.springframework.ai.vectorstore.elasticsearch.ElasticsearchVectorStore; -import org.springframework.ai.vectorstore.SearchRequest; import org.springframework.ai.vectorstore.elasticsearch.SimilarityFunction; import org.springframework.ai.vectorstore.observation.VectorStoreObservationContext; import org.springframework.boot.autoconfigure.AutoConfigurations; diff --git a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-gemfire/src/main/java/org/springframework/ai/vectorstore/gemfire/autoconfigure/GemFireVectorStoreProperties.java b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-gemfire/src/main/java/org/springframework/ai/vectorstore/gemfire/autoconfigure/GemFireVectorStoreProperties.java index e010bec1de7..7db368003c9 100644 --- a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-gemfire/src/main/java/org/springframework/ai/vectorstore/gemfire/autoconfigure/GemFireVectorStoreProperties.java +++ b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-gemfire/src/main/java/org/springframework/ai/vectorstore/gemfire/autoconfigure/GemFireVectorStoreProperties.java @@ -16,8 +16,8 @@ package org.springframework.ai.vectorstore.gemfire.autoconfigure; -import org.springframework.ai.vectorstore.properties.CommonVectorStoreProperties; import org.springframework.ai.vectorstore.gemfire.GemFireVectorStore; +import org.springframework.ai.vectorstore.properties.CommonVectorStoreProperties; import org.springframework.boot.context.properties.ConfigurationProperties; /** diff --git a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-gemfire/src/test/java/org/springframework/ai/vectorstore/gemfire/autoconfigure/GemFireVectorStoreAutoConfigurationIT.java b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-gemfire/src/test/java/org/springframework/ai/vectorstore/gemfire/autoconfigure/GemFireVectorStoreAutoConfigurationIT.java index c7f9bca7f1e..fd6954c2f0d 100644 --- a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-gemfire/src/test/java/org/springframework/ai/vectorstore/gemfire/autoconfigure/GemFireVectorStoreAutoConfigurationIT.java +++ b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-gemfire/src/test/java/org/springframework/ai/vectorstore/gemfire/autoconfigure/GemFireVectorStoreAutoConfigurationIT.java @@ -33,15 +33,15 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import org.springframework.ai.util.ResourceUtils; import org.springframework.ai.document.Document; import org.springframework.ai.embedding.EmbeddingModel; import org.springframework.ai.observation.conventions.VectorStoreProvider; import org.springframework.ai.test.vectorstore.ObservationTestUtil; import org.springframework.ai.transformers.TransformersEmbeddingModel; -import org.springframework.ai.vectorstore.gemfire.GemFireVectorStore; +import org.springframework.ai.util.ResourceUtils; import org.springframework.ai.vectorstore.SearchRequest; import org.springframework.ai.vectorstore.VectorStore; +import org.springframework.ai.vectorstore.gemfire.GemFireVectorStore; import org.springframework.ai.vectorstore.observation.VectorStoreObservationContext; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.test.context.runner.ApplicationContextRunner; 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 index c407fe7cf50..42bb4eb41f6 100644 --- 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 @@ -23,9 +23,9 @@ 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.document.Document; import org.springframework.ai.vectorstore.VectorStore; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.data.jdbc.JdbcRepositoriesAutoConfiguration; diff --git a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-mariadb/src/main/java/org/springframework/ai/vectorstore/mariadb/autoconfigure/MariaDbStoreAutoConfiguration.java b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-mariadb/src/main/java/org/springframework/ai/vectorstore/mariadb/autoconfigure/MariaDbStoreAutoConfiguration.java index c8a7403987e..48cd4d99ae5 100644 --- a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-mariadb/src/main/java/org/springframework/ai/vectorstore/mariadb/autoconfigure/MariaDbStoreAutoConfiguration.java +++ b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-mariadb/src/main/java/org/springframework/ai/vectorstore/mariadb/autoconfigure/MariaDbStoreAutoConfiguration.java @@ -16,7 +16,10 @@ package org.springframework.ai.vectorstore.mariadb.autoconfigure; +import javax.sql.DataSource; + import io.micrometer.observation.ObservationRegistry; + import org.springframework.ai.embedding.BatchingStrategy; import org.springframework.ai.embedding.EmbeddingModel; import org.springframework.ai.embedding.TokenCountBatchingStrategy; @@ -33,8 +36,6 @@ import org.springframework.context.annotation.Bean; import org.springframework.jdbc.core.JdbcTemplate; -import javax.sql.DataSource; - /** * @author Diego Dupin * @since 1.0.0 diff --git a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-mariadb/src/main/java/org/springframework/ai/vectorstore/mariadb/autoconfigure/MariaDbStoreProperties.java b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-mariadb/src/main/java/org/springframework/ai/vectorstore/mariadb/autoconfigure/MariaDbStoreProperties.java index 59b32748528..9ae0763a968 100644 --- a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-mariadb/src/main/java/org/springframework/ai/vectorstore/mariadb/autoconfigure/MariaDbStoreProperties.java +++ b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-mariadb/src/main/java/org/springframework/ai/vectorstore/mariadb/autoconfigure/MariaDbStoreProperties.java @@ -16,9 +16,9 @@ package org.springframework.ai.vectorstore.mariadb.autoconfigure; -import org.springframework.ai.vectorstore.properties.CommonVectorStoreProperties; import org.springframework.ai.vectorstore.mariadb.MariaDBVectorStore; import org.springframework.ai.vectorstore.mariadb.MariaDBVectorStore.MariaDBDistanceType; +import org.springframework.ai.vectorstore.properties.CommonVectorStoreProperties; import org.springframework.boot.context.properties.ConfigurationProperties; /** diff --git a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-mariadb/src/test/java/org/springframework/ai/vectorstore/mariadb/autoconfigure/MariaDbStoreAutoConfigurationIT.java b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-mariadb/src/test/java/org/springframework/ai/vectorstore/mariadb/autoconfigure/MariaDbStoreAutoConfigurationIT.java index 44217bd0663..09fbfd6ad0b 100644 --- a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-mariadb/src/test/java/org/springframework/ai/vectorstore/mariadb/autoconfigure/MariaDbStoreAutoConfigurationIT.java +++ b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-mariadb/src/test/java/org/springframework/ai/vectorstore/mariadb/autoconfigure/MariaDbStoreAutoConfigurationIT.java @@ -16,10 +16,20 @@ package org.springframework.ai.vectorstore.mariadb.autoconfigure; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.List; +import java.util.Map; + import io.micrometer.observation.tck.TestObservationRegistry; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; +import org.testcontainers.containers.MariaDBContainer; +import org.testcontainers.junit.jupiter.Container; +import org.testcontainers.junit.jupiter.Testcontainers; +import org.testcontainers.utility.DockerImageName; + import org.springframework.ai.document.Document; import org.springframework.ai.embedding.EmbeddingModel; import org.springframework.ai.observation.conventions.VectorStoreProvider; @@ -37,15 +47,6 @@ import org.springframework.context.annotation.Configuration; import org.springframework.core.io.DefaultResourceLoader; import org.springframework.jdbc.core.JdbcTemplate; -import org.testcontainers.containers.MariaDBContainer; -import org.testcontainers.junit.jupiter.Container; -import org.testcontainers.junit.jupiter.Testcontainers; -import org.testcontainers.utility.DockerImageName; - -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.util.List; -import java.util.Map; import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.ai.test.vectorstore.ObservationTestUtil.assertObservationRegistry; @@ -160,9 +161,7 @@ public void customSchemaNames(String schemaTableName) { "spring.ai.vectorstore.mariadb.metadata-field-name=" + metaName, "spring.ai.vectorstore.mariadb.embedding-field-name=" + embeddingName, "spring.ai.vectorstore.mariadb.content-field-name=" + contentName) - .run(context -> { - assertThat(isFullyQualifiedTableExists(context, schemaName, tableName)).isTrue(); - }); + .run(context -> assertThat(isFullyQualifiedTableExists(context, schemaName, tableName)).isTrue()); } @ParameterizedTest(name = "{0} : {displayName} ") @@ -175,9 +174,7 @@ public void disableSchemaInitialization(String schemaTableName) { .withPropertyValues("spring.ai.vectorstore.mariadb.schema-name=" + schemaName, "spring.ai.vectorstore.mariadb.table-name=" + tableName, "spring.ai.vectorstore.mariadb.initialize-schema=false") - .run(context -> { - assertThat(isFullyQualifiedTableExists(context, schemaName, tableName)).isFalse(); - }); + .run(context -> assertThat(isFullyQualifiedTableExists(context, schemaName, tableName)).isFalse()); } @Test diff --git a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-milvus/src/main/java/org/springframework/ai/vectorstore/milvus/autoconfigure/MilvusVectorStoreAutoConfiguration.java b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-milvus/src/main/java/org/springframework/ai/vectorstore/milvus/autoconfigure/MilvusVectorStoreAutoConfiguration.java index 7dda6426d84..3d3a9c43511 100644 --- a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-milvus/src/main/java/org/springframework/ai/vectorstore/milvus/autoconfigure/MilvusVectorStoreAutoConfiguration.java +++ b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-milvus/src/main/java/org/springframework/ai/vectorstore/milvus/autoconfigure/MilvusVectorStoreAutoConfiguration.java @@ -21,9 +21,9 @@ import io.micrometer.observation.ObservationRegistry; 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.BatchingStrategy; import org.springframework.ai.embedding.EmbeddingModel; import org.springframework.ai.embedding.TokenCountBatchingStrategy; diff --git a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-milvus/src/main/java/org/springframework/ai/vectorstore/milvus/autoconfigure/MilvusVectorStoreProperties.java b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-milvus/src/main/java/org/springframework/ai/vectorstore/milvus/autoconfigure/MilvusVectorStoreProperties.java index 8ab62eb94dc..c36a24be377 100644 --- a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-milvus/src/main/java/org/springframework/ai/vectorstore/milvus/autoconfigure/MilvusVectorStoreProperties.java +++ b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-milvus/src/main/java/org/springframework/ai/vectorstore/milvus/autoconfigure/MilvusVectorStoreProperties.java @@ -16,8 +16,8 @@ package org.springframework.ai.vectorstore.milvus.autoconfigure; -import org.springframework.ai.vectorstore.properties.CommonVectorStoreProperties; import org.springframework.ai.vectorstore.milvus.MilvusVectorStore; +import org.springframework.ai.vectorstore.properties.CommonVectorStoreProperties; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.util.Assert; diff --git a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-milvus/src/test/java/org/springframework/ai/vectorstore/milvus/autoconfigure/MilvusVectorStoreAutoConfigurationIT.java b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-milvus/src/test/java/org/springframework/ai/vectorstore/milvus/autoconfigure/MilvusVectorStoreAutoConfigurationIT.java index e60be59fc54..b92a8525a0c 100644 --- a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-milvus/src/test/java/org/springframework/ai/vectorstore/milvus/autoconfigure/MilvusVectorStoreAutoConfigurationIT.java +++ b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-milvus/src/test/java/org/springframework/ai/vectorstore/milvus/autoconfigure/MilvusVectorStoreAutoConfigurationIT.java @@ -25,12 +25,12 @@ import org.testcontainers.junit.jupiter.Testcontainers; import org.testcontainers.milvus.MilvusContainer; -import org.springframework.ai.util.ResourceUtils; import org.springframework.ai.document.Document; import org.springframework.ai.embedding.EmbeddingModel; import org.springframework.ai.observation.conventions.VectorStoreProvider; import org.springframework.ai.test.vectorstore.ObservationTestUtil; import org.springframework.ai.transformers.TransformersEmbeddingModel; +import org.springframework.ai.util.ResourceUtils; import org.springframework.ai.vectorstore.SearchRequest; import org.springframework.ai.vectorstore.VectorStore; import org.springframework.ai.vectorstore.milvus.MilvusVectorStore; diff --git a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-mongodb-atlas/src/test/java/org/springframework/ai/vectorstore/mongodb/autoconfigure/MongoDBAtlasVectorStoreAutoConfigurationIT.java b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-mongodb-atlas/src/test/java/org/springframework/ai/vectorstore/mongodb/autoconfigure/MongoDBAtlasVectorStoreAutoConfigurationIT.java index 17351f5d57a..afd2723b452 100644 --- a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-mongodb-atlas/src/test/java/org/springframework/ai/vectorstore/mongodb/autoconfigure/MongoDBAtlasVectorStoreAutoConfigurationIT.java +++ b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-mongodb-atlas/src/test/java/org/springframework/ai/vectorstore/mongodb/autoconfigure/MongoDBAtlasVectorStoreAutoConfigurationIT.java @@ -27,10 +27,10 @@ import org.testcontainers.junit.jupiter.Testcontainers; import org.testcontainers.mongodb.MongoDBAtlasLocalContainer; -import org.springframework.ai.model.openai.autoconfigure.OpenAiEmbeddingAutoConfiguration; -import org.springframework.ai.retry.autoconfigure.SpringAiRetryAutoConfiguration; import org.springframework.ai.document.Document; +import org.springframework.ai.model.openai.autoconfigure.OpenAiEmbeddingAutoConfiguration; import org.springframework.ai.observation.conventions.VectorStoreProvider; +import org.springframework.ai.retry.autoconfigure.SpringAiRetryAutoConfiguration; import org.springframework.ai.test.vectorstore.ObservationTestUtil; import org.springframework.ai.vectorstore.SearchRequest; import org.springframework.ai.vectorstore.VectorStore; diff --git a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-neo4j/src/main/java/org/springframework/ai/vectorstore/neo4j/autoconfigure/Neo4jVectorStoreProperties.java b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-neo4j/src/main/java/org/springframework/ai/vectorstore/neo4j/autoconfigure/Neo4jVectorStoreProperties.java index e8980d8ba68..cc37bb1acd3 100644 --- a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-neo4j/src/main/java/org/springframework/ai/vectorstore/neo4j/autoconfigure/Neo4jVectorStoreProperties.java +++ b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-neo4j/src/main/java/org/springframework/ai/vectorstore/neo4j/autoconfigure/Neo4jVectorStoreProperties.java @@ -16,8 +16,8 @@ package org.springframework.ai.vectorstore.neo4j.autoconfigure; -import org.springframework.ai.vectorstore.properties.CommonVectorStoreProperties; import org.springframework.ai.vectorstore.neo4j.Neo4jVectorStore; +import org.springframework.ai.vectorstore.properties.CommonVectorStoreProperties; import org.springframework.boot.context.properties.ConfigurationProperties; /** diff --git a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-neo4j/src/test/java/org/springframework/ai/vectorstore/neo4j/autoconfigure/Neo4jVectorStoreAutoConfigurationIT.java b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-neo4j/src/test/java/org/springframework/ai/vectorstore/neo4j/autoconfigure/Neo4jVectorStoreAutoConfigurationIT.java index 31ca754ac88..fd9077d6c73 100644 --- a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-neo4j/src/test/java/org/springframework/ai/vectorstore/neo4j/autoconfigure/Neo4jVectorStoreAutoConfigurationIT.java +++ b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-neo4j/src/test/java/org/springframework/ai/vectorstore/neo4j/autoconfigure/Neo4jVectorStoreAutoConfigurationIT.java @@ -26,12 +26,12 @@ import org.testcontainers.junit.jupiter.Testcontainers; import org.testcontainers.utility.DockerImageName; -import org.springframework.ai.util.ResourceUtils; import org.springframework.ai.document.Document; import org.springframework.ai.embedding.EmbeddingModel; import org.springframework.ai.observation.conventions.VectorStoreProvider; import org.springframework.ai.test.vectorstore.ObservationTestUtil; import org.springframework.ai.transformers.TransformersEmbeddingModel; +import org.springframework.ai.util.ResourceUtils; import org.springframework.ai.vectorstore.SearchRequest; import org.springframework.ai.vectorstore.VectorStore; import org.springframework.ai.vectorstore.neo4j.Neo4jVectorStore; diff --git a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-opensearch/src/main/java/org/springframework/ai/vectorstore/opensearch/autoconfigure/OpenSearchVectorStoreAutoConfiguration.java b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-opensearch/src/main/java/org/springframework/ai/vectorstore/opensearch/autoconfigure/OpenSearchVectorStoreAutoConfiguration.java index 91e946eef1e..a41dee55e76 100644 --- a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-opensearch/src/main/java/org/springframework/ai/vectorstore/opensearch/autoconfigure/OpenSearchVectorStoreAutoConfiguration.java +++ b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-opensearch/src/main/java/org/springframework/ai/vectorstore/opensearch/autoconfigure/OpenSearchVectorStoreAutoConfiguration.java @@ -41,8 +41,8 @@ import org.springframework.ai.embedding.EmbeddingModel; import org.springframework.ai.embedding.TokenCountBatchingStrategy; import org.springframework.ai.vectorstore.SpringAIVectorStoreTypes; -import org.springframework.ai.vectorstore.opensearch.OpenSearchVectorStore; import org.springframework.ai.vectorstore.observation.VectorStoreObservationConvention; +import org.springframework.ai.vectorstore.opensearch.OpenSearchVectorStore; import org.springframework.beans.factory.ObjectProvider; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; diff --git a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-opensearch/src/test/java/org/springframework/ai/vectorstore/opensearch/autoconfigure/AwsOpenSearchVectorStoreAutoConfigurationIT.java b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-opensearch/src/test/java/org/springframework/ai/vectorstore/opensearch/autoconfigure/AwsOpenSearchVectorStoreAutoConfigurationIT.java index 74547b767b0..6e238b17fad 100644 --- a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-opensearch/src/test/java/org/springframework/ai/vectorstore/opensearch/autoconfigure/AwsOpenSearchVectorStoreAutoConfigurationIT.java +++ b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-opensearch/src/test/java/org/springframework/ai/vectorstore/opensearch/autoconfigure/AwsOpenSearchVectorStoreAutoConfigurationIT.java @@ -32,12 +32,12 @@ import org.testcontainers.junit.jupiter.Testcontainers; import org.testcontainers.utility.DockerImageName; -import org.springframework.ai.retry.autoconfigure.SpringAiRetryAutoConfiguration; import org.springframework.ai.document.Document; import org.springframework.ai.embedding.EmbeddingModel; +import org.springframework.ai.retry.autoconfigure.SpringAiRetryAutoConfiguration; import org.springframework.ai.transformers.TransformersEmbeddingModel; -import org.springframework.ai.vectorstore.opensearch.OpenSearchVectorStore; import org.springframework.ai.vectorstore.SearchRequest; +import org.springframework.ai.vectorstore.opensearch.OpenSearchVectorStore; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.context.annotation.Bean; diff --git a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-opensearch/src/test/java/org/springframework/ai/vectorstore/opensearch/autoconfigure/OpenSearchVectorStoreAutoConfigurationIT.java b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-opensearch/src/test/java/org/springframework/ai/vectorstore/opensearch/autoconfigure/OpenSearchVectorStoreAutoConfigurationIT.java index 2c40806b069..5f98c2b4867 100644 --- a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-opensearch/src/test/java/org/springframework/ai/vectorstore/opensearch/autoconfigure/OpenSearchVectorStoreAutoConfigurationIT.java +++ b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-opensearch/src/test/java/org/springframework/ai/vectorstore/opensearch/autoconfigure/OpenSearchVectorStoreAutoConfigurationIT.java @@ -31,16 +31,16 @@ import software.amazon.awssdk.http.apache.ApacheHttpClient; import software.amazon.awssdk.regions.Region; -import org.springframework.ai.retry.autoconfigure.SpringAiRetryAutoConfiguration; import org.springframework.ai.document.Document; import org.springframework.ai.embedding.EmbeddingModel; import org.springframework.ai.observation.conventions.VectorStoreProvider; +import org.springframework.ai.retry.autoconfigure.SpringAiRetryAutoConfiguration; import org.springframework.ai.test.vectorstore.ObservationTestUtil; import org.springframework.ai.transformers.TransformersEmbeddingModel; -import org.springframework.ai.vectorstore.VectorStore; -import org.springframework.ai.vectorstore.opensearch.OpenSearchVectorStore; import org.springframework.ai.vectorstore.SearchRequest; +import org.springframework.ai.vectorstore.VectorStore; import org.springframework.ai.vectorstore.observation.VectorStoreObservationContext; +import org.springframework.ai.vectorstore.opensearch.OpenSearchVectorStore; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.test.context.FilteredClassLoader; import org.springframework.boot.test.context.runner.ApplicationContextRunner; diff --git a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-oracle/src/main/java/org/springframework/ai/vectorstore/oracle/autoconfigure/OracleVectorStoreAutoConfiguration.java b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-oracle/src/main/java/org/springframework/ai/vectorstore/oracle/autoconfigure/OracleVectorStoreAutoConfiguration.java index 82c71c17073..38c197e4f5a 100644 --- a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-oracle/src/main/java/org/springframework/ai/vectorstore/oracle/autoconfigure/OracleVectorStoreAutoConfiguration.java +++ b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-oracle/src/main/java/org/springframework/ai/vectorstore/oracle/autoconfigure/OracleVectorStoreAutoConfiguration.java @@ -24,8 +24,8 @@ import org.springframework.ai.embedding.EmbeddingModel; import org.springframework.ai.embedding.TokenCountBatchingStrategy; import org.springframework.ai.vectorstore.SpringAIVectorStoreTypes; -import org.springframework.ai.vectorstore.oracle.OracleVectorStore; import org.springframework.ai.vectorstore.observation.VectorStoreObservationConvention; +import org.springframework.ai.vectorstore.oracle.OracleVectorStore; import org.springframework.beans.factory.ObjectProvider; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; diff --git a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-oracle/src/main/java/org/springframework/ai/vectorstore/oracle/autoconfigure/OracleVectorStoreProperties.java b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-oracle/src/main/java/org/springframework/ai/vectorstore/oracle/autoconfigure/OracleVectorStoreProperties.java index 83415d31ca8..4f3e371a64d 100644 --- a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-oracle/src/main/java/org/springframework/ai/vectorstore/oracle/autoconfigure/OracleVectorStoreProperties.java +++ b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-oracle/src/main/java/org/springframework/ai/vectorstore/oracle/autoconfigure/OracleVectorStoreProperties.java @@ -16,8 +16,8 @@ package org.springframework.ai.vectorstore.oracle.autoconfigure; -import org.springframework.ai.vectorstore.properties.CommonVectorStoreProperties; import org.springframework.ai.vectorstore.oracle.OracleVectorStore; +import org.springframework.ai.vectorstore.properties.CommonVectorStoreProperties; import org.springframework.boot.context.properties.ConfigurationProperties; /** diff --git a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-pgvector/src/main/java/org/springframework/ai/vectorstore/pgvector/autoconfigure/PgVectorStoreAutoConfiguration.java b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-pgvector/src/main/java/org/springframework/ai/vectorstore/pgvector/autoconfigure/PgVectorStoreAutoConfiguration.java index d901d96b84a..0cb8dc09e29 100644 --- a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-pgvector/src/main/java/org/springframework/ai/vectorstore/pgvector/autoconfigure/PgVectorStoreAutoConfiguration.java +++ b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-pgvector/src/main/java/org/springframework/ai/vectorstore/pgvector/autoconfigure/PgVectorStoreAutoConfiguration.java @@ -24,8 +24,8 @@ import org.springframework.ai.embedding.EmbeddingModel; import org.springframework.ai.embedding.TokenCountBatchingStrategy; import org.springframework.ai.vectorstore.SpringAIVectorStoreTypes; -import org.springframework.ai.vectorstore.pgvector.PgVectorStore; import org.springframework.ai.vectorstore.observation.VectorStoreObservationConvention; +import org.springframework.ai.vectorstore.pgvector.PgVectorStore; import org.springframework.beans.factory.ObjectProvider; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; diff --git a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-pgvector/src/main/java/org/springframework/ai/vectorstore/pgvector/autoconfigure/PgVectorStoreProperties.java b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-pgvector/src/main/java/org/springframework/ai/vectorstore/pgvector/autoconfigure/PgVectorStoreProperties.java index e4535edb5b7..7bd7ed8dcaf 100644 --- a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-pgvector/src/main/java/org/springframework/ai/vectorstore/pgvector/autoconfigure/PgVectorStoreProperties.java +++ b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-pgvector/src/main/java/org/springframework/ai/vectorstore/pgvector/autoconfigure/PgVectorStoreProperties.java @@ -16,10 +16,10 @@ package org.springframework.ai.vectorstore.pgvector.autoconfigure; -import org.springframework.ai.vectorstore.properties.CommonVectorStoreProperties; import org.springframework.ai.vectorstore.pgvector.PgVectorStore; import org.springframework.ai.vectorstore.pgvector.PgVectorStore.PgDistanceType; import org.springframework.ai.vectorstore.pgvector.PgVectorStore.PgIndexType; +import org.springframework.ai.vectorstore.properties.CommonVectorStoreProperties; import org.springframework.boot.context.properties.ConfigurationProperties; /** diff --git a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-pgvector/src/test/java/org/springframework/ai/vectorstore/pgvector/autoconfigure/PgVectorStoreAutoConfigurationIT.java b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-pgvector/src/test/java/org/springframework/ai/vectorstore/pgvector/autoconfigure/PgVectorStoreAutoConfigurationIT.java index 0db699138f3..3958c109cdb 100644 --- a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-pgvector/src/test/java/org/springframework/ai/vectorstore/pgvector/autoconfigure/PgVectorStoreAutoConfigurationIT.java +++ b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-pgvector/src/test/java/org/springframework/ai/vectorstore/pgvector/autoconfigure/PgVectorStoreAutoConfigurationIT.java @@ -34,10 +34,10 @@ import org.springframework.ai.observation.conventions.VectorStoreProvider; import org.springframework.ai.test.vectorstore.ObservationTestUtil; import org.springframework.ai.transformers.TransformersEmbeddingModel; -import org.springframework.ai.vectorstore.VectorStore; -import org.springframework.ai.vectorstore.pgvector.PgVectorStore; import org.springframework.ai.vectorstore.SearchRequest; +import org.springframework.ai.vectorstore.VectorStore; import org.springframework.ai.vectorstore.observation.VectorStoreObservationContext; +import org.springframework.ai.vectorstore.pgvector.PgVectorStore; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; import org.springframework.boot.autoconfigure.jdbc.JdbcTemplateAutoConfiguration; diff --git a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-pinecone/src/main/java/org/springframework/ai/vectorstore/pinecone/autoconfigure/PineconeVectorStoreAutoConfiguration.java b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-pinecone/src/main/java/org/springframework/ai/vectorstore/pinecone/autoconfigure/PineconeVectorStoreAutoConfiguration.java index bfa56985f78..e40de1cb202 100644 --- a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-pinecone/src/main/java/org/springframework/ai/vectorstore/pinecone/autoconfigure/PineconeVectorStoreAutoConfiguration.java +++ b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-pinecone/src/main/java/org/springframework/ai/vectorstore/pinecone/autoconfigure/PineconeVectorStoreAutoConfiguration.java @@ -22,8 +22,8 @@ import org.springframework.ai.embedding.EmbeddingModel; import org.springframework.ai.embedding.TokenCountBatchingStrategy; import org.springframework.ai.vectorstore.SpringAIVectorStoreTypes; -import org.springframework.ai.vectorstore.pinecone.PineconeVectorStore; import org.springframework.ai.vectorstore.observation.VectorStoreObservationConvention; +import org.springframework.ai.vectorstore.pinecone.PineconeVectorStore; import org.springframework.beans.factory.ObjectProvider; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; diff --git a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-pinecone/src/test/java/org/springframework/ai/vectorstore/pinecone/autoconfigure/PineconeVectorStoreAutoConfigurationIT.java b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-pinecone/src/test/java/org/springframework/ai/vectorstore/pinecone/autoconfigure/PineconeVectorStoreAutoConfigurationIT.java index 30bc9f7fa8a..32c29aa653e 100644 --- a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-pinecone/src/test/java/org/springframework/ai/vectorstore/pinecone/autoconfigure/PineconeVectorStoreAutoConfigurationIT.java +++ b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-pinecone/src/test/java/org/springframework/ai/vectorstore/pinecone/autoconfigure/PineconeVectorStoreAutoConfigurationIT.java @@ -34,10 +34,10 @@ import org.springframework.ai.observation.conventions.VectorStoreProvider; import org.springframework.ai.test.vectorstore.ObservationTestUtil; import org.springframework.ai.transformers.TransformersEmbeddingModel; -import org.springframework.ai.vectorstore.VectorStore; -import org.springframework.ai.vectorstore.pinecone.PineconeVectorStore; import org.springframework.ai.vectorstore.SearchRequest; +import org.springframework.ai.vectorstore.VectorStore; import org.springframework.ai.vectorstore.observation.VectorStoreObservationContext; +import org.springframework.ai.vectorstore.pinecone.PineconeVectorStore; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.context.annotation.Bean; diff --git a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-redis/src/main/java/org/springframework/ai/vectorstore/redis/autoconfigure/RedisVectorStoreAutoConfiguration.java b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-redis/src/main/java/org/springframework/ai/vectorstore/redis/autoconfigure/RedisVectorStoreAutoConfiguration.java index 431104779db..f332752faa1 100644 --- a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-redis/src/main/java/org/springframework/ai/vectorstore/redis/autoconfigure/RedisVectorStoreAutoConfiguration.java +++ b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-redis/src/main/java/org/springframework/ai/vectorstore/redis/autoconfigure/RedisVectorStoreAutoConfiguration.java @@ -26,8 +26,8 @@ import org.springframework.ai.embedding.EmbeddingModel; import org.springframework.ai.embedding.TokenCountBatchingStrategy; import org.springframework.ai.vectorstore.SpringAIVectorStoreTypes; -import org.springframework.ai.vectorstore.redis.RedisVectorStore; import org.springframework.ai.vectorstore.observation.VectorStoreObservationConvention; +import org.springframework.ai.vectorstore.redis.RedisVectorStore; import org.springframework.beans.factory.ObjectProvider; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; diff --git a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-redis/src/test/java/org/springframework/ai/vectorstore/redis/autoconfigure/RedisVectorStoreAutoConfigurationIT.java b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-redis/src/test/java/org/springframework/ai/vectorstore/redis/autoconfigure/RedisVectorStoreAutoConfigurationIT.java index 54c92920839..40d3bce6e93 100644 --- a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-redis/src/test/java/org/springframework/ai/vectorstore/redis/autoconfigure/RedisVectorStoreAutoConfigurationIT.java +++ b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-redis/src/test/java/org/springframework/ai/vectorstore/redis/autoconfigure/RedisVectorStoreAutoConfigurationIT.java @@ -25,12 +25,12 @@ import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; -import org.springframework.ai.util.ResourceUtils; import org.springframework.ai.document.Document; import org.springframework.ai.embedding.EmbeddingModel; import org.springframework.ai.observation.conventions.VectorStoreProvider; import org.springframework.ai.test.vectorstore.ObservationTestUtil; import org.springframework.ai.transformers.TransformersEmbeddingModel; +import org.springframework.ai.util.ResourceUtils; import org.springframework.ai.vectorstore.SearchRequest; import org.springframework.ai.vectorstore.VectorStore; import org.springframework.ai.vectorstore.observation.VectorStoreObservationContext; diff --git a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-typesense/src/main/java/org/springframework/ai/vectorstore/typesense/autoconfigure/TypesenseVectorStoreAutoConfiguration.java b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-typesense/src/main/java/org/springframework/ai/vectorstore/typesense/autoconfigure/TypesenseVectorStoreAutoConfiguration.java index 41e8d048f58..944de4c7606 100644 --- a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-typesense/src/main/java/org/springframework/ai/vectorstore/typesense/autoconfigure/TypesenseVectorStoreAutoConfiguration.java +++ b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-typesense/src/main/java/org/springframework/ai/vectorstore/typesense/autoconfigure/TypesenseVectorStoreAutoConfiguration.java @@ -29,8 +29,8 @@ import org.springframework.ai.embedding.EmbeddingModel; import org.springframework.ai.embedding.TokenCountBatchingStrategy; import org.springframework.ai.vectorstore.SpringAIVectorStoreTypes; -import org.springframework.ai.vectorstore.typesense.TypesenseVectorStore; import org.springframework.ai.vectorstore.observation.VectorStoreObservationConvention; +import org.springframework.ai.vectorstore.typesense.TypesenseVectorStore; import org.springframework.beans.factory.ObjectProvider; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; diff --git a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-typesense/src/test/java/org/springframework/ai/vectorstore/typesense/autoconfigure/TypesenseVectorStoreAutoConfigurationIT.java b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-typesense/src/test/java/org/springframework/ai/vectorstore/typesense/autoconfigure/TypesenseVectorStoreAutoConfigurationIT.java index b6b23d8551f..f0d69f93463 100644 --- a/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-typesense/src/test/java/org/springframework/ai/vectorstore/typesense/autoconfigure/TypesenseVectorStoreAutoConfigurationIT.java +++ b/auto-configurations/vector-stores/spring-ai-autoconfigure-vector-store-typesense/src/test/java/org/springframework/ai/vectorstore/typesense/autoconfigure/TypesenseVectorStoreAutoConfigurationIT.java @@ -25,12 +25,12 @@ import org.testcontainers.junit.jupiter.Testcontainers; import org.testcontainers.typesense.TypesenseContainer; -import org.springframework.ai.util.ResourceUtils; import org.springframework.ai.document.Document; import org.springframework.ai.embedding.EmbeddingModel; import org.springframework.ai.observation.conventions.VectorStoreProvider; import org.springframework.ai.test.vectorstore.ObservationTestUtil; import org.springframework.ai.transformers.TransformersEmbeddingModel; +import org.springframework.ai.util.ResourceUtils; import org.springframework.ai.vectorstore.SearchRequest; import org.springframework.ai.vectorstore.VectorStore; import org.springframework.ai.vectorstore.observation.VectorStoreObservationContext; diff --git a/document-readers/jsoup-reader/src/main/java/org/springframework/ai/reader/jsoup/config/JsoupDocumentReaderConfig.java b/document-readers/jsoup-reader/src/main/java/org/springframework/ai/reader/jsoup/config/JsoupDocumentReaderConfig.java index c6f1cab7ffb..97b1e2a9f53 100644 --- a/document-readers/jsoup-reader/src/main/java/org/springframework/ai/reader/jsoup/config/JsoupDocumentReaderConfig.java +++ b/document-readers/jsoup-reader/src/main/java/org/springframework/ai/reader/jsoup/config/JsoupDocumentReaderConfig.java @@ -33,7 +33,7 @@ * * @author Alexandros Pappas */ -public class JsoupDocumentReaderConfig { +public final class JsoupDocumentReaderConfig { public final String charset; @@ -70,7 +70,7 @@ public static JsoupDocumentReaderConfig defaultConfig() { return builder().build(); } - public static class Builder { + public static final class Builder { private String charset = "UTF-8"; diff --git a/document-readers/jsoup-reader/src/test/java/org/springframework/ai/reader/jsoup/JsoupDocumentReaderTests.java b/document-readers/jsoup-reader/src/test/java/org/springframework/ai/reader/jsoup/JsoupDocumentReaderTests.java index 41c7c289ecf..20704f1a1f5 100644 --- a/document-readers/jsoup-reader/src/test/java/org/springframework/ai/reader/jsoup/JsoupDocumentReaderTests.java +++ b/document-readers/jsoup-reader/src/test/java/org/springframework/ai/reader/jsoup/JsoupDocumentReaderTests.java @@ -18,7 +18,6 @@ import java.util.List; -import static org.assertj.core.api.Assertions.assertThatThrownBy; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @@ -28,6 +27,7 @@ import org.springframework.core.io.DefaultResourceLoader; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; /** * Tests for {@link JsoupDocumentReader}. diff --git a/document-readers/pdf-reader/src/main/java/org/springframework/ai/reader/pdf/PagePdfDocumentReader.java b/document-readers/pdf-reader/src/main/java/org/springframework/ai/reader/pdf/PagePdfDocumentReader.java index 4919929a57b..724f7ee5c0a 100644 --- a/document-readers/pdf-reader/src/main/java/org/springframework/ai/reader/pdf/PagePdfDocumentReader.java +++ b/document-readers/pdf-reader/src/main/java/org/springframework/ai/reader/pdf/PagePdfDocumentReader.java @@ -112,7 +112,7 @@ public List get() { for (PDPage page : this.document.getDocumentCatalog().getPages()) { lastPage = page; if (counter % logFrequency == 0 && counter / logFrequency < 10) { - this.logger.info("Processing PDF page: {}", (counter + 1)); + logger.info("Processing PDF page: {}", (counter + 1)); } counter++; @@ -154,7 +154,7 @@ public List get() { readDocuments.add(toDocument(lastPage, pageTextGroupList.stream().collect(Collectors.joining()), startPageNumber, pageNumber)); } - this.logger.info("Processing {} pages", totalPages); + logger.info("Processing {} pages", totalPages); return readDocuments; } diff --git a/document-readers/pdf-reader/src/main/java/org/springframework/ai/reader/pdf/ParagraphPdfDocumentReader.java b/document-readers/pdf-reader/src/main/java/org/springframework/ai/reader/pdf/ParagraphPdfDocumentReader.java index fa9bac7d8c0..95863fff649 100644 --- a/document-readers/pdf-reader/src/main/java/org/springframework/ai/reader/pdf/ParagraphPdfDocumentReader.java +++ b/document-readers/pdf-reader/src/main/java/org/springframework/ai/reader/pdf/ParagraphPdfDocumentReader.java @@ -133,7 +133,7 @@ public List get() { List documents = new ArrayList<>(paragraphs.size()); if (!CollectionUtils.isEmpty(paragraphs)) { - this.logger.info("Start processing paragraphs from PDF"); + logger.info("Start processing paragraphs from PDF"); Iterator itr = paragraphs.iterator(); var current = itr.next(); @@ -152,7 +152,7 @@ public List get() { } } } - this.logger.info("End processing paragraphs from PDF"); + logger.info("End processing paragraphs from PDF"); return documents; } diff --git a/document-readers/tika-reader/src/test/java/org/springframework/ai/reader/tika/TikaDocumentReaderTests.java b/document-readers/tika-reader/src/test/java/org/springframework/ai/reader/tika/TikaDocumentReaderTests.java index 814431d1dad..a8dbf88355f 100644 --- a/document-readers/tika-reader/src/test/java/org/springframework/ai/reader/tika/TikaDocumentReaderTests.java +++ b/document-readers/tika-reader/src/test/java/org/springframework/ai/reader/tika/TikaDocumentReaderTests.java @@ -18,7 +18,9 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvSource; + import org.springframework.ai.reader.ExtractedTextFormatter; + import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertFalse; diff --git a/mcp/common/src/main/java/org/springframework/ai/mcp/McpToolUtils.java b/mcp/common/src/main/java/org/springframework/ai/mcp/McpToolUtils.java index f1e30311b01..4ab5ca02d10 100644 --- a/mcp/common/src/main/java/org/springframework/ai/mcp/McpToolUtils.java +++ b/mcp/common/src/main/java/org/springframework/ai/mcp/McpToolUtils.java @@ -360,8 +360,9 @@ public static List getToolCallbacksFromAsyncClients(List { - logger.info("CALLBACK - Welcoming users to the library"); - }) + .tools(FunctionToolCallback.builder("sayWelcome", + (Consumer) input -> logger.info("CALLBACK - Welcoming users to the library")) .description("Welcome users to the library") .inputType(Void.class) .build()) @@ -105,9 +104,8 @@ void chatVoidOutputFromCallback() { .build() .prompt() .user("Welcome %s to the library".formatted("James Bond")) - .tools(FunctionToolCallback.builder("welcomeUser", (user) -> { - logger.info("CALLBACK - Welcoming {} to the library", ((User) user).name()); - }) + .tools(FunctionToolCallback.builder("welcomeUser", + (Consumer) user -> logger.info("CALLBACK - Welcoming {} to the library", ((User) user).name())) .description("Welcome a specific user to the library") .inputType(User.class) .build()) @@ -202,7 +200,7 @@ static class Tools { @Bean(WELCOME) @Description("Welcome users to the library") Consumer welcome() { - return (input) -> logger.info("Welcoming users to the library"); + return input -> logger.info("Welcoming users to the library"); } @Bean(WELCOME_USER) @@ -215,7 +213,7 @@ Consumer welcomeUser() { @Description("Get the list of books written by the given author available in the library") Function> booksByAuthor() { return author -> { - logger.info("Getting books by author: "+ author.name()); + logger.info("Getting books by author: " + author.name()); return this.bookService.getBooksByAuthor(author); }; } diff --git a/spring-ai-integration-tests/src/test/java/org/springframework/ai/integration/tests/tool/ToolCallingManagerTests.java b/spring-ai-integration-tests/src/test/java/org/springframework/ai/integration/tests/tool/ToolCallingManagerTests.java index 63dca3849bc..ba63fbbb93c 100644 --- a/spring-ai-integration-tests/src/test/java/org/springframework/ai/integration/tests/tool/ToolCallingManagerTests.java +++ b/spring-ai-integration-tests/src/test/java/org/springframework/ai/integration/tests/tool/ToolCallingManagerTests.java @@ -22,7 +22,6 @@ import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.ai.model.tool.ToolExecutionResult; import reactor.core.publisher.Flux; import org.springframework.ai.chat.messages.ToolResponseMessage; @@ -36,6 +35,7 @@ import org.springframework.ai.integration.tests.tool.domain.BookService; import org.springframework.ai.model.tool.ToolCallingChatOptions; import org.springframework.ai.model.tool.ToolCallingManager; +import org.springframework.ai.model.tool.ToolExecutionResult; import org.springframework.ai.openai.OpenAiChatModel; import org.springframework.ai.tool.ToolCallbacks; import org.springframework.ai.tool.annotation.Tool; diff --git a/spring-ai-integration-tests/src/test/java/org/springframework/ai/integration/tests/tool/domain/BookService.java b/spring-ai-integration-tests/src/test/java/org/springframework/ai/integration/tests/tool/domain/BookService.java index 641fd84d483..b93f0fca47f 100644 --- a/spring-ai-integration-tests/src/test/java/org/springframework/ai/integration/tests/tool/domain/BookService.java +++ b/spring-ai-integration-tests/src/test/java/org/springframework/ai/integration/tests/tool/domain/BookService.java @@ -26,7 +26,7 @@ public class BookService { private static final ConcurrentHashMap books = new ConcurrentHashMap<>(Map - .of( // @formatter:off + .of(// @formatter:off 1, new Book("His Dark Materials", "Philip Pullman"), 2, new Book("The Lion, the Witch and the Wardrobe", "C.S. Lewis"), 3, new Book("The Hobbit", "J.R.R. Tolkien"), diff --git a/spring-ai-integration-tests/src/test/java/org/springframework/ai/integration/tests/vectorstore/SimpleVectorStoreIT.java b/spring-ai-integration-tests/src/test/java/org/springframework/ai/integration/tests/vectorstore/SimpleVectorStoreIT.java index 40bfe3f499f..916bfb8d984 100644 --- a/spring-ai-integration-tests/src/test/java/org/springframework/ai/integration/tests/vectorstore/SimpleVectorStoreIT.java +++ b/spring-ai-integration-tests/src/test/java/org/springframework/ai/integration/tests/vectorstore/SimpleVectorStoreIT.java @@ -16,9 +16,16 @@ package org.springframework.ai.integration.tests.vectorstore; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.List; +import java.util.Map; +import java.util.UUID; + import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; + import org.springframework.ai.document.Document; import org.springframework.ai.document.DocumentMetadata; import org.springframework.ai.integration.tests.TestApplication; @@ -28,12 +35,6 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.core.io.DefaultResourceLoader; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.util.List; -import java.util.Map; -import java.util.UUID; - import static org.assertj.core.api.Assertions.assertThat; /** diff --git a/spring-ai-spring-boot-testcontainers/src/test/java/org/springframework/ai/testcontainers/service/connection/milvus/MilvusContainerConnectionDetailsFactoryIT.java b/spring-ai-spring-boot-testcontainers/src/test/java/org/springframework/ai/testcontainers/service/connection/milvus/MilvusContainerConnectionDetailsFactoryIT.java index 19b57bf5873..ff54d88f201 100644 --- a/spring-ai-spring-boot-testcontainers/src/test/java/org/springframework/ai/testcontainers/service/connection/milvus/MilvusContainerConnectionDetailsFactoryIT.java +++ b/spring-ai-spring-boot-testcontainers/src/test/java/org/springframework/ai/testcontainers/service/connection/milvus/MilvusContainerConnectionDetailsFactoryIT.java @@ -24,13 +24,13 @@ import org.testcontainers.junit.jupiter.Testcontainers; import org.testcontainers.milvus.MilvusContainer; -import org.springframework.ai.util.ResourceUtils; -import org.springframework.ai.vectorstore.milvus.autoconfigure.MilvusVectorStoreAutoConfiguration; import org.springframework.ai.document.Document; import org.springframework.ai.embedding.EmbeddingModel; import org.springframework.ai.transformers.TransformersEmbeddingModel; +import org.springframework.ai.util.ResourceUtils; import org.springframework.ai.vectorstore.SearchRequest; import org.springframework.ai.vectorstore.VectorStore; +import org.springframework.ai.vectorstore.milvus.autoconfigure.MilvusVectorStoreAutoConfiguration; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.testcontainers.service.connection.ServiceConnection; diff --git a/spring-ai-spring-boot-testcontainers/src/test/java/org/springframework/ai/testcontainers/service/connection/qdrant/QdrantContainerConnectionDetailsFactoryIT.java b/spring-ai-spring-boot-testcontainers/src/test/java/org/springframework/ai/testcontainers/service/connection/qdrant/QdrantContainerConnectionDetailsFactoryIT.java index 39b4c94f125..cc4958ffd46 100644 --- a/spring-ai-spring-boot-testcontainers/src/test/java/org/springframework/ai/testcontainers/service/connection/qdrant/QdrantContainerConnectionDetailsFactoryIT.java +++ b/spring-ai-spring-boot-testcontainers/src/test/java/org/springframework/ai/testcontainers/service/connection/qdrant/QdrantContainerConnectionDetailsFactoryIT.java @@ -26,12 +26,12 @@ import org.testcontainers.junit.jupiter.Testcontainers; import org.testcontainers.qdrant.QdrantContainer; -import org.springframework.ai.vectorstore.qdrant.autoconfigure.QdrantVectorStoreAutoConfiguration; import org.springframework.ai.document.Document; import org.springframework.ai.embedding.EmbeddingModel; import org.springframework.ai.transformers.TransformersEmbeddingModel; import org.springframework.ai.vectorstore.SearchRequest; import org.springframework.ai.vectorstore.VectorStore; +import org.springframework.ai.vectorstore.qdrant.autoconfigure.QdrantVectorStoreAutoConfiguration; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.testcontainers.service.connection.ServiceConnection; diff --git a/spring-ai-spring-boot-testcontainers/src/test/java/org/springframework/ai/testcontainers/service/connection/qdrant/QdrantContainerWithApiKeyConnectionDetailsFactoryIT.java b/spring-ai-spring-boot-testcontainers/src/test/java/org/springframework/ai/testcontainers/service/connection/qdrant/QdrantContainerWithApiKeyConnectionDetailsFactoryIT.java index 11df3e951a1..fb26bca475e 100644 --- a/spring-ai-spring-boot-testcontainers/src/test/java/org/springframework/ai/testcontainers/service/connection/qdrant/QdrantContainerWithApiKeyConnectionDetailsFactoryIT.java +++ b/spring-ai-spring-boot-testcontainers/src/test/java/org/springframework/ai/testcontainers/service/connection/qdrant/QdrantContainerWithApiKeyConnectionDetailsFactoryIT.java @@ -26,12 +26,12 @@ import org.testcontainers.junit.jupiter.Testcontainers; import org.testcontainers.qdrant.QdrantContainer; -import org.springframework.ai.vectorstore.qdrant.autoconfigure.QdrantVectorStoreAutoConfiguration; import org.springframework.ai.document.Document; import org.springframework.ai.embedding.EmbeddingModel; import org.springframework.ai.transformers.TransformersEmbeddingModel; import org.springframework.ai.vectorstore.SearchRequest; import org.springframework.ai.vectorstore.VectorStore; +import org.springframework.ai.vectorstore.qdrant.autoconfigure.QdrantVectorStoreAutoConfiguration; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.testcontainers.service.connection.ServiceConnection; diff --git a/spring-ai-spring-boot-testcontainers/src/test/java/org/springframework/ai/testcontainers/service/connection/typesense/TypesenseContainerConnectionDetailsFactoryIT.java b/spring-ai-spring-boot-testcontainers/src/test/java/org/springframework/ai/testcontainers/service/connection/typesense/TypesenseContainerConnectionDetailsFactoryIT.java index a8897e7ce02..5445cd25970 100644 --- a/spring-ai-spring-boot-testcontainers/src/test/java/org/springframework/ai/testcontainers/service/connection/typesense/TypesenseContainerConnectionDetailsFactoryIT.java +++ b/spring-ai-spring-boot-testcontainers/src/test/java/org/springframework/ai/testcontainers/service/connection/typesense/TypesenseContainerConnectionDetailsFactoryIT.java @@ -24,13 +24,13 @@ import org.testcontainers.junit.jupiter.Testcontainers; import org.testcontainers.typesense.TypesenseContainer; -import org.springframework.ai.util.ResourceUtils; -import org.springframework.ai.vectorstore.typesense.autoconfigure.TypesenseVectorStoreAutoConfiguration; import org.springframework.ai.document.Document; import org.springframework.ai.embedding.EmbeddingModel; import org.springframework.ai.transformers.TransformersEmbeddingModel; +import org.springframework.ai.util.ResourceUtils; import org.springframework.ai.vectorstore.SearchRequest; import org.springframework.ai.vectorstore.VectorStore; +import org.springframework.ai.vectorstore.typesense.autoconfigure.TypesenseVectorStoreAutoConfiguration; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.testcontainers.service.connection.ServiceConnection; diff --git a/spring-ai-spring-boot-testcontainers/src/test/java/org/springframework/ai/testcontainers/service/connection/weaviate/WeaviateContainerConnectionDetailsFactoryIT.java b/spring-ai-spring-boot-testcontainers/src/test/java/org/springframework/ai/testcontainers/service/connection/weaviate/WeaviateContainerConnectionDetailsFactoryIT.java index adcb49a787b..242d80ffbe0 100644 --- a/spring-ai-spring-boot-testcontainers/src/test/java/org/springframework/ai/testcontainers/service/connection/weaviate/WeaviateContainerConnectionDetailsFactoryIT.java +++ b/spring-ai-spring-boot-testcontainers/src/test/java/org/springframework/ai/testcontainers/service/connection/weaviate/WeaviateContainerConnectionDetailsFactoryIT.java @@ -25,14 +25,14 @@ import org.testcontainers.junit.jupiter.Testcontainers; import org.testcontainers.weaviate.WeaviateContainer; -import org.springframework.ai.vectorstore.weaviate.autoconfigure.WeaviateVectorStoreAutoConfiguration; -import org.springframework.ai.vectorstore.weaviate.autoconfigure.WeaviateVectorStoreProperties; import org.springframework.ai.document.Document; import org.springframework.ai.embedding.EmbeddingModel; import org.springframework.ai.transformers.TransformersEmbeddingModel; import org.springframework.ai.vectorstore.SearchRequest; import org.springframework.ai.vectorstore.VectorStore; import org.springframework.ai.vectorstore.weaviate.WeaviateVectorStore; +import org.springframework.ai.vectorstore.weaviate.autoconfigure.WeaviateVectorStoreAutoConfiguration; +import org.springframework.ai.vectorstore.weaviate.autoconfigure.WeaviateVectorStoreProperties; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.testcontainers.service.connection.ServiceConnection; diff --git a/src/checkstyle/checkstyle-suppressions.xml b/src/checkstyle/checkstyle-suppressions.xml index cfb80a1532b..6d1f023c2cb 100644 --- a/src/checkstyle/checkstyle-suppressions.xml +++ b/src/checkstyle/checkstyle-suppressions.xml @@ -40,12 +40,14 @@ + + diff --git a/vector-stores/spring-ai-couchbase-store/src/main/java/org/springframework/ai/vectorstore/CouchbaseAiSearchFilterExpressionConverter.java b/vector-stores/spring-ai-couchbase-store/src/main/java/org/springframework/ai/vectorstore/CouchbaseAiSearchFilterExpressionConverter.java index 415247dafc7..da25f13c1b6 100644 --- a/vector-stores/spring-ai-couchbase-store/src/main/java/org/springframework/ai/vectorstore/CouchbaseAiSearchFilterExpressionConverter.java +++ b/vector-stores/spring-ai-couchbase-store/src/main/java/org/springframework/ai/vectorstore/CouchbaseAiSearchFilterExpressionConverter.java @@ -1,11 +1,11 @@ /* - * Copyright 2023 - 2024 the original author or authors. + * 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 + * 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, @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.ai.vectorstore; import org.springframework.ai.vectorstore.filter.Filter.Expression; diff --git a/vector-stores/spring-ai-couchbase-store/src/main/java/org/springframework/ai/vectorstore/CouchbaseIndexOptimization.java b/vector-stores/spring-ai-couchbase-store/src/main/java/org/springframework/ai/vectorstore/CouchbaseIndexOptimization.java index c36bd3d7266..11742bcaad5 100644 --- a/vector-stores/spring-ai-couchbase-store/src/main/java/org/springframework/ai/vectorstore/CouchbaseIndexOptimization.java +++ b/vector-stores/spring-ai-couchbase-store/src/main/java/org/springframework/ai/vectorstore/CouchbaseIndexOptimization.java @@ -1,11 +1,11 @@ /* - * Copyright 2023 - 2024 the original author or authors. + * 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 + * 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, @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.ai.vectorstore; /** diff --git a/vector-stores/spring-ai-couchbase-store/src/main/java/org/springframework/ai/vectorstore/CouchbaseSearchVectorStore.java b/vector-stores/spring-ai-couchbase-store/src/main/java/org/springframework/ai/vectorstore/CouchbaseSearchVectorStore.java index bf35f2828d8..ad0ebc95a1d 100644 --- a/vector-stores/spring-ai-couchbase-store/src/main/java/org/springframework/ai/vectorstore/CouchbaseSearchVectorStore.java +++ b/vector-stores/spring-ai-couchbase-store/src/main/java/org/springframework/ai/vectorstore/CouchbaseSearchVectorStore.java @@ -1,11 +1,11 @@ /* - * Copyright 2023 - 2024 the original author or authors. + * 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 + * 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, @@ -13,8 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.ai.vectorstore; +import java.time.Duration; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + import com.couchbase.client.core.util.ConsistencyUtil; import com.couchbase.client.java.Bucket; import com.couchbase.client.java.Cluster; @@ -29,6 +37,9 @@ import com.couchbase.client.java.query.QueryResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import reactor.core.publisher.Mono; +import reactor.util.retry.RetrySpec; + import org.springframework.ai.document.Document; import org.springframework.ai.embedding.EmbeddingModel; import org.springframework.ai.embedding.EmbeddingOptionsBuilder; @@ -38,11 +49,6 @@ import org.springframework.ai.vectorstore.observation.VectorStoreObservationContext; import org.springframework.beans.factory.InitializingBean; import org.springframework.util.Assert; -import reactor.core.publisher.Mono; -import reactor.util.retry.RetrySpec; - -import java.time.Duration; -import java.util.*; /** * @author Laurent Doguin @@ -203,141 +209,6 @@ public static Builder builder(Cluster cluster, EmbeddingModel embeddingModel) { return new Builder(cluster, embeddingModel); } - public static class Builder extends AbstractVectorStoreBuilder { - - private String collectionName = DEFAULT_COLLECTION_NAME; - - private String scopeName = DEFAULT_SCOPE_NAME; - - private String bucketName = DEFAULT_BUCKET_NAME; - - private String vectorIndexName = DEFAULT_INDEX_NAME; - - private Integer dimensions = 1536; - - private CouchbaseSimilarityFunction similarityFunction = CouchbaseSimilarityFunction.dot_product; - - private CouchbaseIndexOptimization indexOptimization = CouchbaseIndexOptimization.recall; - - private final Cluster cluster; - - private final CouchbaseAiSearchFilterExpressionConverter filterExpressionConverter = new CouchbaseAiSearchFilterExpressionConverter(); - - private boolean initializeSchema = false; - - /** - * @throws IllegalArgumentException if couchbaseSearchVectorConfig or cluster is - * null - */ - private Builder(Cluster cluster, EmbeddingModel embeddingModel) { - super(embeddingModel); - Assert.notNull(cluster, "Cluster must not be null"); - this.cluster = cluster; - } - - /** - * Sets whether to initialize the schema. - * @param initializeSchema true to initialize schema, false otherwise - * @return the builder instance - */ - public Builder initializeSchema(boolean initializeSchema) { - this.initializeSchema = initializeSchema; - return this; - } - - /** - * Configures the Couchbase collection storing {@link Document}. - * @param collectionName - * @return this builder - */ - public CouchbaseSearchVectorStore.Builder collectionName(String collectionName) { - Assert.notNull(collectionName, "Collection Name must not be null"); - Assert.notNull(collectionName, "Collection Name must not be empty"); - this.collectionName = collectionName; - return this; - } - - /** - * Configures the Couchbase scope, parent of the selected collection. Search will - * be executed in this scope context. - * @param scopeName - * @return this builder - */ - public CouchbaseSearchVectorStore.Builder scopeName(String scopeName) { - Assert.notNull(scopeName, "Scope Name must not be null"); - Assert.notNull(scopeName, "Scope Name must not be empty"); - this.scopeName = scopeName; - return this; - } - - /** - * Configures the Couchbase bucket, parent of the selected Scope. - * @param bucketName - * @return this builder - */ - public CouchbaseSearchVectorStore.Builder bucketName(String bucketName) { - Assert.notNull(bucketName, "Bucket Name must not be null"); - Assert.notNull(bucketName, "Bucket Name must not be empty"); - this.bucketName = bucketName; - return this; - } - - /** - * Configures the vector index name. This must match the name of the Vector Search - * Index Name in Atlas - * @param vectorIndexName - * @return this builder - */ - public CouchbaseSearchVectorStore.Builder vectorIndexName(String vectorIndexName) { - Assert.notNull(vectorIndexName, "Vector Index Name must not be null"); - Assert.notNull(vectorIndexName, "Vector Index Name must not be empty"); - this.vectorIndexName = vectorIndexName; - return this; - } - - /** - * The number of dimensions in the vector. - * @param dimensions - * @return this builder - */ - public CouchbaseSearchVectorStore.Builder dimensions(Integer dimensions) { - Assert.notNull(dimensions, "Dimensions must not be null"); - Assert.notNull(dimensions, "Dimensions must not be empty"); - this.dimensions = dimensions; - return this; - } - - /** - * Choose the method to calculate the similarity between the vector embedding in a - * Vector Search index and the vector embedding in a Vector Search query. - * @param similarityFunction - * @return this builder - */ - public CouchbaseSearchVectorStore.Builder similarityFunction(CouchbaseSimilarityFunction similarityFunction) { - Assert.notNull(similarityFunction, "Couchbase Similarity Function must not be null"); - Assert.notNull(similarityFunction, "Couchbase Similarity Function must not be empty"); - this.similarityFunction = similarityFunction; - return this; - } - - /** - * Choose to prioritize accuracy or latency. - * @param indexOptimization - * @return this builder - */ - public CouchbaseSearchVectorStore.Builder indexOptimization(CouchbaseIndexOptimization indexOptimization) { - Assert.notNull(indexOptimization, "Index Optimization must not be null"); - Assert.notNull(indexOptimization, "Index Optimization must not be empty"); - this.indexOptimization = indexOptimization; - return this; - } - - public CouchbaseSearchVectorStore build() { - return new CouchbaseSearchVectorStore(this); - } - - } - public void initCluster() throws InterruptedException { // init scope, collection, indexes BucketSettings bs = this.cluster.buckets().getAllBuckets().get(this.bucketName); @@ -478,4 +349,139 @@ public void close() throws Exception { public record CouchbaseDocument(String id, String content, Map metadata, float[] embedding) { } + public static class Builder extends AbstractVectorStoreBuilder { + + private String collectionName = DEFAULT_COLLECTION_NAME; + + private String scopeName = DEFAULT_SCOPE_NAME; + + private String bucketName = DEFAULT_BUCKET_NAME; + + private String vectorIndexName = DEFAULT_INDEX_NAME; + + private Integer dimensions = 1536; + + private CouchbaseSimilarityFunction similarityFunction = CouchbaseSimilarityFunction.dot_product; + + private CouchbaseIndexOptimization indexOptimization = CouchbaseIndexOptimization.recall; + + private final Cluster cluster; + + private final CouchbaseAiSearchFilterExpressionConverter filterExpressionConverter = new CouchbaseAiSearchFilterExpressionConverter(); + + private boolean initializeSchema = false; + + /** + * @throws IllegalArgumentException if couchbaseSearchVectorConfig or cluster is + * null + */ + private Builder(Cluster cluster, EmbeddingModel embeddingModel) { + super(embeddingModel); + Assert.notNull(cluster, "Cluster must not be null"); + this.cluster = cluster; + } + + /** + * Sets whether to initialize the schema. + * @param initializeSchema true to initialize schema, false otherwise + * @return the builder instance + */ + public Builder initializeSchema(boolean initializeSchema) { + this.initializeSchema = initializeSchema; + return this; + } + + /** + * Configures the Couchbase collection storing {@link Document}. + * @param collectionName + * @return this builder + */ + public CouchbaseSearchVectorStore.Builder collectionName(String collectionName) { + Assert.notNull(collectionName, "Collection Name must not be null"); + Assert.notNull(collectionName, "Collection Name must not be empty"); + this.collectionName = collectionName; + return this; + } + + /** + * Configures the Couchbase scope, parent of the selected collection. Search will + * be executed in this scope context. + * @param scopeName + * @return this builder + */ + public CouchbaseSearchVectorStore.Builder scopeName(String scopeName) { + Assert.notNull(scopeName, "Scope Name must not be null"); + Assert.notNull(scopeName, "Scope Name must not be empty"); + this.scopeName = scopeName; + return this; + } + + /** + * Configures the Couchbase bucket, parent of the selected Scope. + * @param bucketName + * @return this builder + */ + public CouchbaseSearchVectorStore.Builder bucketName(String bucketName) { + Assert.notNull(bucketName, "Bucket Name must not be null"); + Assert.notNull(bucketName, "Bucket Name must not be empty"); + this.bucketName = bucketName; + return this; + } + + /** + * Configures the vector index name. This must match the name of the Vector Search + * Index Name in Atlas + * @param vectorIndexName + * @return this builder + */ + public CouchbaseSearchVectorStore.Builder vectorIndexName(String vectorIndexName) { + Assert.notNull(vectorIndexName, "Vector Index Name must not be null"); + Assert.notNull(vectorIndexName, "Vector Index Name must not be empty"); + this.vectorIndexName = vectorIndexName; + return this; + } + + /** + * The number of dimensions in the vector. + * @param dimensions + * @return this builder + */ + public CouchbaseSearchVectorStore.Builder dimensions(Integer dimensions) { + Assert.notNull(dimensions, "Dimensions must not be null"); + Assert.notNull(dimensions, "Dimensions must not be empty"); + this.dimensions = dimensions; + return this; + } + + /** + * Choose the method to calculate the similarity between the vector embedding in a + * Vector Search index and the vector embedding in a Vector Search query. + * @param similarityFunction + * @return this builder + */ + public CouchbaseSearchVectorStore.Builder similarityFunction(CouchbaseSimilarityFunction similarityFunction) { + Assert.notNull(similarityFunction, "Couchbase Similarity Function must not be null"); + Assert.notNull(similarityFunction, "Couchbase Similarity Function must not be empty"); + this.similarityFunction = similarityFunction; + return this; + } + + /** + * Choose to prioritize accuracy or latency. + * @param indexOptimization + * @return this builder + */ + public CouchbaseSearchVectorStore.Builder indexOptimization(CouchbaseIndexOptimization indexOptimization) { + Assert.notNull(indexOptimization, "Index Optimization must not be null"); + Assert.notNull(indexOptimization, "Index Optimization must not be empty"); + this.indexOptimization = indexOptimization; + return this; + } + + public CouchbaseSearchVectorStore build() { + return new CouchbaseSearchVectorStore(this); + } + + } + } diff --git a/vector-stores/spring-ai-couchbase-store/src/main/java/org/springframework/ai/vectorstore/CouchbaseSimilarityFunction.java b/vector-stores/spring-ai-couchbase-store/src/main/java/org/springframework/ai/vectorstore/CouchbaseSimilarityFunction.java index e2ac036dac9..0812ae2fac5 100644 --- a/vector-stores/spring-ai-couchbase-store/src/main/java/org/springframework/ai/vectorstore/CouchbaseSimilarityFunction.java +++ b/vector-stores/spring-ai-couchbase-store/src/main/java/org/springframework/ai/vectorstore/CouchbaseSimilarityFunction.java @@ -1,11 +1,11 @@ /* - * Copyright 2023 - 2024 the original author or authors. + * 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 + * 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, @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.ai.vectorstore; /** diff --git a/vector-stores/spring-ai-couchbase-store/src/main/resources/application.properties b/vector-stores/spring-ai-couchbase-store/src/main/resources/application.properties deleted file mode 100644 index 33239c9cda9..00000000000 --- a/vector-stores/spring-ai-couchbase-store/src/main/resources/application.properties +++ /dev/null @@ -1 +0,0 @@ -spring.application.name=demo \ No newline at end of file diff --git a/vector-stores/spring-ai-couchbase-store/src/test/java/org/springframework/ai/vectorstore/CouchbaseSearchVectorStoreIT.java b/vector-stores/spring-ai-couchbase-store/src/test/java/org/springframework/ai/vectorstore/CouchbaseSearchVectorStoreIT.java index b670b9e605c..3484dae49f5 100644 --- a/vector-stores/spring-ai-couchbase-store/src/test/java/org/springframework/ai/vectorstore/CouchbaseSearchVectorStoreIT.java +++ b/vector-stores/spring-ai-couchbase-store/src/test/java/org/springframework/ai/vectorstore/CouchbaseSearchVectorStoreIT.java @@ -1,11 +1,11 @@ /* - * Copyright 2023 - 2024 the original author or authors. + * 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 + * 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, @@ -13,37 +13,43 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.ai.vectorstore; +import java.time.Duration; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.UUID; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + import com.couchbase.client.java.Cluster; import org.awaitility.Awaitility; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; +import org.testcontainers.containers.wait.strategy.Wait; +import org.testcontainers.couchbase.CouchbaseContainer; +import org.testcontainers.couchbase.CouchbaseService; +import org.testcontainers.junit.jupiter.Container; +import org.testcontainers.junit.jupiter.Testcontainers; + import org.springframework.ai.document.Document; import org.springframework.ai.embedding.EmbeddingModel; import org.springframework.ai.openai.OpenAiEmbeddingModel; import org.springframework.ai.openai.api.OpenAiApi; import org.springframework.ai.vectorstore.filter.Filter; +import org.springframework.ai.vectorstore.testcontainer.CouchbaseContainerMetadata; import org.springframework.boot.SpringBootConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.context.annotation.Bean; -import org.testcontainers.containers.wait.strategy.Wait; -import org.testcontainers.couchbase.CouchbaseContainer; -import org.testcontainers.couchbase.CouchbaseService; -import org.testcontainers.junit.jupiter.Container; -import org.testcontainers.junit.jupiter.Testcontainers; - -import java.time.Duration; -import java.util.*; -import java.util.concurrent.TimeUnit; -import java.util.stream.Collectors; import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.ai.vectorstore.testcontainer.CouchbaseContainerMetadata.*; /** * @author Laurent Doguin @@ -55,11 +61,12 @@ public class CouchbaseSearchVectorStoreIT { // Define the couchbase container. @Container - final static CouchbaseContainer couchbaseContainer = new CouchbaseContainer(COUCHBASE_IMAGE_ENTERPRISE) - .withCredentials(USERNAME, PASSWORD) + final static CouchbaseContainer couchbaseContainer = new CouchbaseContainer( + CouchbaseContainerMetadata.COUCHBASE_IMAGE_ENTERPRISE) + .withCredentials(CouchbaseContainerMetadata.USERNAME, CouchbaseContainerMetadata.PASSWORD) .withEnabledServices(CouchbaseService.KV, CouchbaseService.QUERY, CouchbaseService.INDEX, CouchbaseService.SEARCH) - .withBucket(bucketDefinition) + .withBucket(CouchbaseContainerMetadata.bucketDefinition) .withStartupAttempts(4) .withStartupTimeout(Duration.ofSeconds(90)) .waitingFor(Wait.forHealthcheck()); diff --git a/vector-stores/spring-ai-couchbase-store/src/test/java/org/springframework/ai/vectorstore/testcontainer/CouchbaseContainerMetadata.java b/vector-stores/spring-ai-couchbase-store/src/test/java/org/springframework/ai/vectorstore/testcontainer/CouchbaseContainerMetadata.java index 0b9a2e62190..ff772bc96e7 100644 --- a/vector-stores/spring-ai-couchbase-store/src/test/java/org/springframework/ai/vectorstore/testcontainer/CouchbaseContainerMetadata.java +++ b/vector-stores/spring-ai-couchbase-store/src/test/java/org/springframework/ai/vectorstore/testcontainer/CouchbaseContainerMetadata.java @@ -1,11 +1,11 @@ /* - * Copyright 2023 - 2024 the original author or authors. + * 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 + * 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, @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.ai.vectorstore.testcontainer; import org.testcontainers.couchbase.BucketDefinition; @@ -22,7 +23,7 @@ * @author Laurent Doguin * @since 1.0.0 */ -public class CouchbaseContainerMetadata { +public final class CouchbaseContainerMetadata { public static final String BUCKET_NAME = "springBucket"; @@ -36,4 +37,8 @@ public class CouchbaseContainerMetadata { .asCompatibleSubstituteFor("couchbase/server") .withTag("enterprise-7.6.1"); + private CouchbaseContainerMetadata() { + // Avoids instantiation + } + } diff --git a/vector-stores/spring-ai-couchbase-store/src/test/resources/application.properties b/vector-stores/spring-ai-couchbase-store/src/test/resources/application.properties index 33239c9cda9..2109a440d84 100644 --- a/vector-stores/spring-ai-couchbase-store/src/test/resources/application.properties +++ b/vector-stores/spring-ai-couchbase-store/src/test/resources/application.properties @@ -1 +1 @@ -spring.application.name=demo \ No newline at end of file +spring.application.name=demo diff --git a/vector-stores/spring-ai-milvus-store/src/main/java/org/springframework/ai/vectorstore/milvus/MilvusSearchRequest.java b/vector-stores/spring-ai-milvus-store/src/main/java/org/springframework/ai/vectorstore/milvus/MilvusSearchRequest.java index 25e95e6876c..78ab382b969 100755 --- a/vector-stores/spring-ai-milvus-store/src/main/java/org/springframework/ai/vectorstore/milvus/MilvusSearchRequest.java +++ b/vector-stores/spring-ai-milvus-store/src/main/java/org/springframework/ai/vectorstore/milvus/MilvusSearchRequest.java @@ -1,3 +1,19 @@ +/* + * 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. + */ + package org.springframework.ai.vectorstore.milvus; import org.springframework.ai.vectorstore.SearchRequest; diff --git a/vector-stores/spring-ai-milvus-store/src/test/java/org/springframework/ai/vectorstore/milvus/MilvusSearchRequestTest.java b/vector-stores/spring-ai-milvus-store/src/test/java/org/springframework/ai/vectorstore/milvus/MilvusSearchRequestTest.java index a3c9555c5a9..7f77d94c46e 100644 --- a/vector-stores/spring-ai-milvus-store/src/test/java/org/springframework/ai/vectorstore/milvus/MilvusSearchRequestTest.java +++ b/vector-stores/spring-ai-milvus-store/src/test/java/org/springframework/ai/vectorstore/milvus/MilvusSearchRequestTest.java @@ -1,10 +1,26 @@ +/* + * Copyright 2023-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. + */ + package org.springframework.ai.vectorstore.milvus; import org.junit.jupiter.api.Test; +import org.springframework.ai.vectorstore.SearchRequest; + import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.ai.vectorstore.SearchRequest.DEFAULT_TOP_K; -import static org.springframework.ai.vectorstore.SearchRequest.SIMILARITY_THRESHOLD_ACCEPT_ALL; /** * Test class for verifying the functionality of the {@link MilvusSearchRequest} class. @@ -41,8 +57,8 @@ void shouldBuildMilvusSearchRequestWithDefaults() { MilvusSearchRequest request = MilvusSearchRequest.milvusBuilder().build(); assertThat(request.getQuery()).isEmpty(); - assertThat(request.getTopK()).isEqualTo(DEFAULT_TOP_K); - assertThat(request.getSimilarityThreshold()).isEqualTo(SIMILARITY_THRESHOLD_ACCEPT_ALL); + assertThat(request.getTopK()).isEqualTo(SearchRequest.DEFAULT_TOP_K); + assertThat(request.getSimilarityThreshold()).isEqualTo(SearchRequest.SIMILARITY_THRESHOLD_ACCEPT_ALL); assertThat(request.getNativeExpression()).isNull(); assertThat(request.getSearchParamsJson()).isNull(); } diff --git a/vector-stores/spring-ai-milvus-store/src/test/java/org/springframework/ai/vectorstore/milvus/MilvusVectorStoreTest.java b/vector-stores/spring-ai-milvus-store/src/test/java/org/springframework/ai/vectorstore/milvus/MilvusVectorStoreTest.java index 003e60c86c7..203b725b49b 100644 --- a/vector-stores/spring-ai-milvus-store/src/test/java/org/springframework/ai/vectorstore/milvus/MilvusVectorStoreTest.java +++ b/vector-stores/spring-ai-milvus-store/src/test/java/org/springframework/ai/vectorstore/milvus/MilvusVectorStoreTest.java @@ -1,5 +1,23 @@ +/* + * 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. + */ + package org.springframework.ai.vectorstore.milvus; +import java.util.List; + import io.milvus.client.MilvusServiceClient; import io.milvus.grpc.SearchResultData; import io.milvus.grpc.SearchResults; @@ -14,13 +32,12 @@ import org.mockito.MockedConstruction; import org.mockito.MockedStatic; import org.mockito.junit.jupiter.MockitoExtension; + import org.springframework.ai.document.Document; import org.springframework.ai.embedding.EmbeddingModel; import org.springframework.ai.model.EmbeddingUtils; import org.springframework.ai.vectorstore.SearchRequest; -import java.util.List; - import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock;