Commit Graph

147 Commits

Author SHA1 Message Date
Thomas Vitale
81137cae54 MCP ToolCallbackProvider autoconfig should use concrete class
Currently, the MCP Tool autoconfiguration defines the SyncMcpToolCallbackProvider and AsyncMcpToolCallbackProvider beans returning the ToolCallbackProvider interface. That generates autowiring warnings in IDEs when trying to inject the specific class.

The Spring Boot project recommends being specific. 'When declaring a @Bean method, provide as much type information as possible in the method’s return type. For example, if your bean’s concrete class implements an interface the bean method’s return type should be the concrete class and not the interface. Providing as much type information as possible in @Bean methods is particularly important when using bean conditions as their evaluation can only rely upon to type information that is available in the method signature.'

See https://docs.spring.io/spring-boot/reference/features/developing-auto-configuration.html#features.developing-auto-configuration.condition-annotations.bean-conditions

This PR ensures concrete classes are used.

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2025-05-18 21:26:37 +02:00
Christian Tzolov
9ed7535ba0 feat(mcp): Add request timeout configuration for MCP server
Add support for configuring request timeout in MCP server with a default of 20 seconds.
This timeout applies to all requests made through the client, including tool calls,
resource access, and prompt operations.

- Add requestTimeout property to McpServerProperties with default of 20s
- Configure server builder with the timeout value
- Add tests for default and custom timeout configurations
- Update documentation with the new property

Resolves #3205

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-05-17 12:41:48 +02:00
Soby Chacko
8b8fb4f02d GH-886: feat(opensearch): Add path prefix configuration support
Fixes: #886

Add ability to configure path prefix for OpenSearch API endpoints via properties.
This allows connecting to OpenSearch instances running behind a reverse proxy
with a non-root path, similar to Spring Elasticsearch's path-prefix property.

- Add pathPrefix property to OpenSearchVectorStoreProperties
- Apply pathPrefix to OpenSearchClient when configured
- Add documentation and unit tests

Signed-off-by: Soby Chacko <soby.chacko@broadcom.com>
2025-05-17 09:59:49 +01:00
Mark Pollack
0147d3bd55 Fix typos
Signed-off-by: Ji To Kim <jitokim@users.noreply.github.com>
Signed-off-by: Mark Pollack <mark.pollack@broadcom.com>
2025-05-16 12:45:08 -04:00
Yanming Zhou
bb3556e8d1 Fix that spring.ai.mcp.server.base-url is ignored
Signed-off-by: Yanming Zhou <zhouyanming@gmail.com>
2025-05-16 17:30:32 +02:00
Christian Tzolov
4bde57790d fix checkstyle
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-05-16 10:08:23 -04:00
Christian Tzolov
327cf40e97 feat(mcp): Add granular control over MCP server capabilities
- Add capability configuration to enable/disable tools, resources, prompts, and completions individually
- Refactor server configuration to conditionally register capabilities based on configuration
- Add support for server instructions configuration
- Update documentation with new capability options and completion management
- Add tests for new capabilities and configurations

Resolves #3207

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-05-16 10:08:23 -04:00
Soby Chacko
368be3a04f Fixing miscellaneous checkstyle errors
Enabling checkstyle by default in the project build

Signed-off-by: Soby Chacko <soby.chacko@broadcom.com>
2025-05-16 11:08:33 +01:00
Jonatan Ivanov
3fb66928f5 Add missing observability tests
Some tests were missing from gh-3003, this change adds them

See gh-3003
2025-05-15 10:09:31 +02:00
Yanming Zhou
0bcb2e138b Fix outdated configuration key include-completion and include-query-response
Fixes GH-3151

Follow-up of commit ca843e85887aa1da6300c77550c379c103500897,`includeCompletion` is renamed to `logCompletion`.

Signed-off-by: Yanming Zhou <zhouyanming@gmail.com>
2025-05-15 09:30:45 +02:00
Ilayaperumal Gopinathan
f2940cffce Next development version 2025-05-13 19:06:16 +01:00
Ilayaperumal Gopinathan
30a9638de8 Release version 1.0.0-RC1 2025-05-13 19:05:52 +01:00
Linar Abzaltdinov
77be609c4a updated docs for new OpenSearch vector-store properties (#3140)
Signed-off-by: Linar Abzaltdinov <abzaltdinov@gmail.com>
2025-05-13 17:37:53 +01:00
Thomas Vitale
9ff6d3b364 Update memory docs and ensure consistent naming
Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2025-05-13 11:33:44 -04:00
Soby Chacko
f346092648 HttpHost regression issues in OpenSearchVectorStoreAutoConfiguration
Changes introduced for https://github.com/spring-projects/spring-ai/issues/2954
introduced a regression in the way OpenSearch works with test containers.

Restore the retrieval of HttpHost from OpenSearchConnectionDetails insted of getting
them directly from properties.

Signed-off-by: Soby Chacko <soby.chacko@broadcom.com>
2025-05-13 09:45:27 -04:00
mck
87b680af7c Optimise CassandraChatMemoryRepository for MessageWindowChatMemory usage pattern
Time-series each chat window in Cassandra, keeping past (and deleted) windows still in the db.
Add ability to store different MessageTypes.

Signed-off-by: mck <mck@apache.org>
2025-05-13 10:13:44 +01:00
Soby Chacko
868e288e01 GH-1949: Align CassandraVectorStore API naming with other vector stores
Fixes: #1949

- Rename 'disallowSchemaChanges(boolean)' to 'initializeSchema(boolean)' for consistency
  with other vector store implementations
- Maintain semantic meaning by inverting the default value (from disallowSchemaChanges=false
  to initializeSchema=true) in the CassandraVectorStore implementation
- Keep default behavior in auto-configuration consistent with other vector stores
- Remove unused 'returnEmbeddings' functionality and related code
- Update test cases to use the new initialization parameter
- Ref docs and javadocs updates

This change improves API consistency across Spring AI vector stores while
preserving the same behavior in the Cassandra implementation.

Signed-off-by: Soby Chacko <soby.chacko@broadcom.com>
2025-05-12 22:54:05 -04:00
Ilayaperumal Gopinathan
2d517eec5c Refactor chat memory repository artifacts for clarity
- Rename the artifact ID of the chat memory repository artifacts:

    - `spring-ai-model-chat-memory-jdbc` -> `spring-ai-model-chat-memory-repository-jdbc`
    - `spring-ai-model-chat-memory-cassandra` -> `spring-ai-model-chat-memory-repository-cassandra`
    - `spring-ai-model-chat-memory-neo4j` -> `spring-ai-model-chat-memory-repository-neo4j`

 - Rename the package names to include "repository". Example: org.springframework.ai.chat.memory.repository.jdbc.JdbcChatMemoryRepository
    - This package renaming also requires to change the default schema location for the jdbc repository to include "repository"
      - Update the docs

 - Update the artifact IDs in the parent POM, BOM, autoconfiguration and starters
 - Update upgrade notes and docs to describe the changes

Fix JdbcChatMemoryRepositoryPostgresqlIT
 - Make sure to set the dialect via datasource

Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
2025-05-12 13:02:26 -04:00
Yanming Zhou
e10fbde7a1 Align JdbcChatMemoryRepositoryProperties with other modules in Spring Boot
Such as `BatchProperties.Jdbc`, `IntegrationProperties.Jdbc`, `JdbcSessionProperties` and `QuartzProperties.Jdbc`

1. Reuse Spring Boot's `DatabaseInitializationMode`
2. Allow to customize platform
3. add `OnJdbcChatMemoryRepositoryDatasourceInitializationCondition` for `JdbcChatMemoryRepositorySchemaInitializer`

Signed-off-by: Yanming Zhou <zhouyanming@gmail.com>
2025-05-12 16:18:11 +01:00
Tran Ngoc Nhan
7aa440e6bc Fix typos
Signed-off-by: Tran Ngoc Nhan <ngocnhan.tran1996@gmail.com>
2025-05-12 13:31:40 +01:00
HYUNSANG HAN (한현상, Travis)
49209d1d76 Enable auto complete for 'spring.ai.vertex.ai.gemini.chat.options' (#3101)
Signed-off-by: Hyunsang Han <gustkd3@snu.ac.kr>
2025-05-12 13:10:39 +01:00
lambochen
7739e1e54c OpenAiImageModel support configure imagesPath
Signed-off-by: lambochen <lambochen@yeah.net>
2025-05-12 17:31:49 +08:00
Thomas Vitale
30eb3ce3f2 Micrometer instrumentation for tool calling
Introduce instrumentation for tool calling using the Micrometer Observation API.

By default, metadata about tool calling are exported as metrics and traces.
Optionally, the actual tool call input and result can be exported as well by enabling the dedicated feature flag.

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2025-05-11 07:26:44 +02:00
Mark Pollack
11e3c8f9a6 refactor(cassandra): Remove CassandraChatMemory implementation
- Removed the CassandraChatMemory class and its usages, now using CassandraChatMemoryRepository.
- Updated configuration, repository, and test classes to rely on CassandraChatMemoryRepository.
- Cleaned up related configuration and integration tests.
- Minor doc update to reflect the removal.

Fixes #3090

Signed-off-by: Mark Pollack <mark.pollack@broadcom.com>
2025-05-10 17:34:13 -04:00
Ilayaperumal Gopinathan
f6dba1bf08 Refactor chat memory repository autoconfigurations and Spring Boot starters for clarity
- Rename chat memory repository autoconfiguration modules to include the "repository" suffix:
    - spring-ai-autoconfigure-model-chat-memory-cassandra -> spring-ai-autoconfigure-model-chat-memory-repository-cassandra
    - spring-ai-autoconfigure-model-chat-memory-jdbc -> spring-ai-autoconfigure-model-chat-memory-repository-jdbc
    - spring-ai-autoconfigure-model-chat-memory-neo4j -> spring-ai-autoconfigure-model-chat-memory-repository-neo4j
- Update Spring Boot starter modules to match the new naming convention.
- Rename packages to include `.repository.` for improved clarity and consistency.
- Rename configuration and related classes to use the `ChatMemoryRepository` suffix.
- Update Spring AI BOM and parent POM files to reference the new artifact names.
- Update all imports, references, and configuration to use the new package and class names.

BREAKING CHANGE:
These changes require users to update their dependencies, imports, and configuration to use the new artifact, package, and class names. See the upgrade notes for migration instructions.

Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
2025-05-10 14:56:08 -04:00
Jonatan Ivanov
ca843e8588 feat(observability): refactor content observation to use logging instead of tracing
This removes the possible large amount of data that was attached
to spans and it logs the data out. This change also removes the direct
dependency on the OTel SDK. approach for content in Spring AI.

Refactors the observability approach for content in Spring AI:

- Replace content observation filters with logging handlers
- Rename configuration properties to better reflect their purpose:
  - `include-prompt` → `log-prompt`
  - `include-completion` → `log-completion`
  - `include-query-response` → `log-query-response`
- Add TracingAwareLoggingObservationHandler for trace-aware logging
- Replace micrometer-tracing-bridge-otel with micrometer-tracing
- Remove event-based tracing in favor of direct logging
- Update documentation to reflect these changes (add breaking-changes section)
- Rename includePrompt to logPrompt in observation properties. Updated in ChatClientBuilderProperties, ChatObservationProperties, and ImageObservationProperties.

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-05-10 19:36:11 +02:00
PSriVarshan
a36c70976c Add observability to Bedrock Titan Embedding model
Signed-off-by: PSriVarshan <psvvarshan@gmail.com>
2025-05-10 16:38:37 +01:00
Mark Pollack
0bd0cddc29 Fix CassandraChatMemoryAutoConfigurationIT
Added .repository to property name in test
2025-05-10 10:55:29 -04:00
Linar Abzaltdinov
f30ab261b4 GH-2954: Opensearch vector store transport improvements
Fixes: #2954

* fixed authorization to multiple hosts
* ability to provide SSL certs via `SslBundles`
* ability to set connectTimeout/readTimeout

Signed-off-by: Linar Abzaltdinov <abzaltdinov@gmail.com>
2025-05-10 10:02:51 -04:00
Christian Tzolov
c0062dd3b5 Enable MCP tool callback by default
- Change the default value of `toolcallback.enabled` property to `true` in both configuration and documentation.
- Update `McpClientCommonProperties.Toolcallback` to default `enabled` to `true` and refactor from record to class.
- Adjust `@ConditionalOnProperty` in `McpToolCallbackAutoConfiguration` to `matchIfMissing = true` for tool callback.
- Update tests to reflect new default behavior: tool callback is now enabled by default when the property is missing.
- Update documentation to indicate the new default value for `toolcallback.enabled` is `true`.

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-05-10 01:15:37 -04:00
mck
2450ae592e Implement CassandraChatMemoryRepository
ref: https://github.com/spring-projects/spring-ai/issues/2998
Signed-off-by: mck <mck@apache.org>
2025-05-09 16:44:29 -04:00
Mark Pollack
08958af670 Add flexible support for multiple database variations in JdbcChatMemory
Add SQL Server dialect support with new SqlServerChatMemoryDialect class

Create schema-sqlserver.sql script for SQL Server table creation

Refactor database schema initialization with new JdbcChatMemorySchemaInitializer

Standardize table names across databases to SPRING_AI_CHAT_MEMORY

Implement ChatMemoryDialect abstraction for database-specific operations

Add dialect implementations for PostgreSQL, MySQL/MariaDB, HSQLDB

Update configuration properties with more flexible schema initialization options

Enhance documentation with detailed information about dialect support and configuration

Add integration tests for HSQLDB and SQL Server

Signed-off-by: Mark Pollack <247466+markpollack@users.noreply.github.com>
2025-05-09 20:30:53 +01:00
Temuu-jin
972eb49349 Add custom text-property and set default to previously used "text"
Add property to auto config and properties class

Signed-off-by: Temucin Damdinjamts-Kintaert <temucin.d.k@gmail.com>
2025-05-09 16:28:23 +01:00
Soby Chacko
f3b4624494 GH-3029: Remove HanaDB vector store autoconfiguration
Fixes: #3029

- Remove HanaDB vector store autoconfiguration
- Remove the corresponding starter
- Update docs
- Update maven configuration
- Remove autoconfiguration and starter entries from Spring AI BOM

Signed-off-by: Soby Chacko <soby.chacko@broadcom.com>
2025-05-08 16:55:48 +01:00
Mark Pollack
ebfa5b9b2c refactor: remove inter package dependency cycles in spring-ai-model
Remove circular dependencies:

Move utility classes from various packages to dedicated support packages:
- Move ToolCallbacks from ai.tool to ai.support
- Move UsageUtils to UsageCalculator in ai.support
- Move tool.util to tool.support
- Create new ToolDefinitions utility class

Support packages for the classes in question is more idomatic in spring than util packages.

Signed-off-by: Mark Pollack <mark.pollack@broadcom.com>
2025-05-08 12:20:27 +01:00
Christian Tzolov
e010899fbe fix(tool): handle non-existing tool callbacks gracefully
- Add error handling to SpringBeanToolCallbackResolver to return null
  instead of throwing exceptions when resolving non-existing tools.
  This make is consitent with other tool resolver implementations
  and centralize the error handling in the tool calling manager.
- Add test to verify that the ToolCallbackResolver correctly
  returns null for non-existing tools.

Related to #2667

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-05-08 10:24:47 +01:00
GR
c54dfd35d5 feat: add deepseek starter and docs - fix pom module ordering
- Add remaining deepseek modules
- Fix build order to put autoconfig modules after model modules to fix javadoc build

Signed-off-by: GR <gr@fastball.dev>
2025-05-07 23:38:07 -04:00
Dariusz Jędrzejczyk
97f90b19d6 Fix mutating global RestClient and WebClient builders (#3020)
Since the builders for HTTP clients are mutable and shared, they should
only be configured with globally applicable settings. The current use
leaks specific details into other usages and affects newly instantiated
clients. This PR applies the clone() method right before mutation
happens as it probably is the strategy that avoids multiple unnecessary
copies.

feat: improve RestClient and WebClient instantiation and configuration across AI modules

- Ensure RestClient.Builder and WebClient.Builder are properly cloned before setting base URLs and headers in Mistral, OpenAI, and Ollama API classes to prevent side effects.
- Add WebClientAutoConfiguration to auto-configuration classes for Anthropic and Mistral AI modules.
- Update Mistral AI auto-configuration to inject and use WebClient.Builder.
- Clean up test and annotation usage (remove unnecessary @Nullable, fix test builder usage in AnthropicApiIT).
- Improve consistency and reliability of HTTP client configuration across model integrations.

Signed-off-by: Dariusz Jędrzejczyk <dariusz.jedrzejczyk@broadcom.com>
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
Co-authored-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-05-07 18:15:55 +02:00
jonghoonpark
09a6a6e1e5 Upgrade chroma vector database api version to V2
- Update to use Chroma 1.0.0
 - Update Chroma vector store implementation to use V2 API

Signed-off-by: jonghoonpark <dev@jonghoonpark.com>
2025-05-07 14:11:23 +01:00
Ilayaperumal Gopinathan
61d160442b Fix OpenSearchVectorStoreAutoConfigurationIT
- Set spring.ai.vectorstore.opensearch.aws.enabled=false to enable non AWS condition to instantiate OpenSearch client

Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
2025-05-07 14:00:30 +01:00
Mark Pollack
f329d71b7b Improve OpenSearch AWS/non-AWS auto-configuration and document fallback logic
- Add OpenSearchNonAwsCondition to robustly activate non-AWS OpenSearch auto-configuration if either:
    - AWS SDK classes are missing, OR
    - spring.ai.vectorstore.opensearch.aws.enabled=false
- Update OpenSearchVectorStoreAutoConfiguration to use the new condition for non-AWS configuration.
- Ensure AWS-specific auto-configuration is only active when AWS SDKs are present and the property is true (default).
- Add Javadoc to OpenSearchNonAwsCondition and clarify Javadoc on AWS config.
- Update integration test (OpenSearchVectorStoreNonAwsFallbackIT) to verify fallback logic works with AWS SDKs present.
- Add and refine documentation in opensearch.adoc:
    - Explain the purpose and usage of the spring.ai.vectorstore.opensearch.aws.enabled property.
    - Document the fallback logic and how to explicitly select AWS or non-AWS OpenSearch support.

Fixes #1901

Signed-off-by: Mark Pollack <mark.pollack@broadcom.com>
2025-05-06 18:18:47 -04:00
enricorampazzo
43aa8939d2 Enhance Neo4jChatMemoryRepository, expand integration tests, improve configuration, and update documentation
- Enhanced Neo4jChatMemoryRepository to correctly restore custom metadata for SystemMessage using SystemMessage.Builder.
- Refactored and clarified Neo4jChatMemoryRepository implementation code.
- Added comprehensive integration tests for Neo4jChatMemoryConfig and Neo4jChatMemoryRepository, including:
-- Index creation verification
-- Custom label support
-- Getter validation for all configuration properties
-- Tests for saving and retrieving SystemMessage metadata
-- Tests ensuring saveAll(conversationId, Collections.emptyList()) clears all messages and removes the conversation node
-- Tests for handling of messages with empty content and empty metadata
-- Improved overall test coverage for Neo4j persistence and configuration edge cases
- Fixed resource management bugs in test classes (ensured proper driver/session closure).
- Improved index creation logic in Neo4jChatMemoryConfig for reliability and logging.
- Updated documentation to include Neo4jChatMemoryRepository usage and configuration

Signed-off-by: enricorampazzo <enrico.rampazzo@live.com>
Signed-off-by: Mark Pollack <mark.pollack@broadcom.com>
2025-05-06 15:31:11 -04:00
enricorampazzo
4ec067641b updates from spring-ai
Signed-off-by: enricorampazzo <enrico.rampazzo@live.com>
2025-05-06 15:31:11 -04:00
Thomas Vitale
4fe74d886e Remove deprecations in ChatClient and Advisors
* Update remaining Advisors and related classes to use the new APIs.
* In AbstractChatMemoryAdvisor, the “doNextWithProtectFromBlockingBefore()” protected method has been changed from accepting AdvisedRequest to ChatClientRequest. It’s a breaking change since the alternative was not part of M8.
* MessageAggregator has a new method to aggregate messages from ChatClientRequest. The previous method aggregating messages from AdvisedRequest has been removed. Warning since it wasn’t marked as deprecated in M8.
* In SimpleLoggerAdvisor, the “requestToString” input argument needs to be updated to use ChatClientRequest. It’s a breaking change since the alternative was not part of M8. Same thing about the constructor.
* The “getTemplateRenderer” method has been removed from BaseAdvisorChain. Each Advisor is encouraged to accept a PromptTemplate to achieve self-contained prompt augmentation operations.
* Remove deprecations in ChatClient and Advisors, and update tests accordingly.
* When building a Prompt from the ChatClient input, the SystemMessage passed via systemText() is placed first in the message list. Before, it was put last, resulting in errors with several model providers.

Relates to gh-2655

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2025-05-06 09:58:06 +01:00
Mark Pollack
a2975a6cec Switch to mcp sdk 0.10.0-SNAPSHOT
Signed-off-by: Mark Pollack <mark.pollack@broadcom.com>
2025-05-06 06:54:59 +02:00
Thomas Vitale
356a68f15e Remove deprecations in JdbcChatMemory
* Remove deprecated APIs for JdbcChatMemory.
* Improve documentation about chat memory vs. chat history.
* Fix mismatch between docs vs code for max messages in MessageWindowChatMemory.

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2025-05-06 00:40:08 -04:00
Mark Heckler
3dc86d33ce Added Entra ID identity management for Azure OpenAI, clean autoconfiguration, and updated docs to reflect changes.
Signed-off-by: Mark Heckler <mark.heckler@gmail.com>
2025-05-05 21:03:43 -04:00
Ilayaperumal Gopinathan
228ef10bfb Remove deprecated methods from Media
- Remove deprecated constructor method Media(MimeType mimeType, URL url) from Media
 - Remove deprecated builder method data(URL url) from Media builder
 - Update references to use the builder and the data(URI) methods

Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
2025-05-05 01:47:45 +01:00
Ilayaperumal Gopinathan
06edee4069 Remove deprecated UserMessage constructors
- Remove deprecated constructor methods
 - Replace them with the builder methods

Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
2025-05-05 01:06:21 +01:00
Ilayaperumal Gopinathan
46be8987d6 Remove deprecations from OllamApi and AnthropicApi
- Remove deprecated constructors from OllamaApi and AnthropicApi
 - Modify AnthropicApi's public constructor to be private so that only the builder method can use it to construct
 - Update OllamApiAutoConfiguration and AnthropicChatAutoconfiguration to use the builder methods to construct the respective
 Apis
 - Fix other constructor usages to builder methods

Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
2025-05-05 00:21:34 +01:00