The RelevancyEvaluator is key for validating RAG flows. This pull request improves it by making the PromptTemplate configurable, improving the format of the default one, introducing a Builder, and extending the documentation with more details on how to use it.
I added some unit tests. The RelevancyEvaluator is used in lots of integration tests in the project to test the QuestionAnswerAdvisor and RetrievalAugmentationAdvisor, that also help assessing the evaluator itself.
Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
* Add context about reactive/imperative applications
* Fix typos and improve formatting
* Highlight Spring Boot 3.4 bug as IMPORTANT note
* Clarify tool calling impact on Micrometer observations
- Update Observability section with details about tool calling observability support
- Move "Migrating to ToolCallback API" guide from Tool Calling section to Upgrade Notes
- Update Observability section with details about tool calling observability support
Related to #3230
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
Fixes: #3187
This commit addresses the issue with Spring environment variables that directly
mirror Spring AI application properties, which can confuse users into thinking
they should always set environment variables that match Spring property names.
Instead, we've replaced all instances of SPRING_* prefixed environment variables
in the documentation with custom-named alternatives that are referenced using
Spring Expression Language (SpEL) or retrieved programmatically.
Each documentation section now shows multiple configuration approaches:
- Direct property setting in application.properties/yml
- Using custom environment variables with SpEL
- Accessing environment variables programmatically
This gives users more flexibility while making it clear that using SPRING_*
prefixed environment variables is not required or recommended.
Signed-off-by: Soby Chacko <soby.chacko@broadcom.com>
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>
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>
- 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>
- Restructure navigation with clearer hierarchy using "Reference" and "Guides" sections
- Remove deprecated model-specific function calling documentation
- Update all model references to point to centralized Tool Calling documentation
- Rename "Docker Compose" to "Development-time Services" for clarity
- Move "Testing" under Reference section
- Add link to "Awesome Spring AI" community resources
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
* The defaultConversationId was configurable, but not used. It’s now being used correctly when a custom defaultConversationId is defined.
* The memory advisors were missing the required configuration of a Schedule due to a default value missing. Now as default Scheduler is used, automatically protecting from blocking. It can be customised via “scheduler()”, replacing the old “protectFromBlocking()” method.
* The new defaultTopK options in VectorStoreChatMemoryAdvisor were documented, but not implemented. That is fixed now.
* The memory advisors were not null-safe. Now they are.
* Improved tests to check the null-safe behaviour.
* Updated the documentation accordingly.
Fixes gh-3133
Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
- Add introduction explaining common scenarios where multiple chat models are useful.
- Restructuring the content into clear subsections:
- Multiple ChatClients with a Single Model Type
- ChatClients for Different Model Types
- Multiple OpenAI-Compatible API Endpoints
Signed-off-by: Mark Pollack <mark.pollack@broadcom.com>
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>
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>
- Remove deprecated ChatMemory.get(String conversationId, int lastN) method
- Replace AbstractChatMemoryAdvisor with BaseChatMemoryAdvisor interface in api package
- Make constructors private in all memory advisor implementations to enforce builder usage
- Rename CHAT_MEMORY_CONVERSATION_ID_KEY to CONVERSATION_ID and move to ChatMemory interface
- In VectorStoreChatMemoryAdvisor:
- Rename DEFAULT_CHAT_MEMORY_RESPONSE_SIZE (100) to DEFAULT_TOP_K (20)
- Rename builder method chatMemoryRetrieveSize() to topK()
- Remove systemTextAdvise() builder method
- In PromptChatMemoryAdvisor:
- Remove systemTextAdvise() builder method
- Fix bug where only the last user message was stored from prompts with multiple messages
- Enhance logging in memory advisors to aid in debugging
- Add comprehensive tests for all advisor implementations:
- Unit tests for builder behavior
- Integration tests for the various chat memory advisors
Signed-off-by: Mark Pollack <mark.pollack@broadcom.com>
- 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>
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>
Fixes: #1831
- Document auto-truncation configuration with high token limits
- Add integration tests for auto-truncation behavior
- Include Spring Boot and manual configuration examples
- Test large documents and batching scenarios
Enables proper use of embedding model auto-truncation while avoiding batching strategy exceptions.
Signed-off-by: Soby Chacko <soby.chacko@broadcom.com>
- 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>
- 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>
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>
- 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>
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>
Update the documentation of spring property from `spring.ai.vectorstore.neo4j.dimensions` to `spring.ai.vectorstore.neo4j.embedding-dimension` to reflect what the code reads.
Without this change, changes to the property `dimensions` are not propagated to runtime code, resulting in discrepancies if an embedding model that has a different number of dimensions is used
Signed-off-by: Vinay Balamuru <balamuru@gmail.com>
- 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>
The built-in advisors that perform prompt augmentation have been updated to use self-contained templates. The goal is for each advisor to be able to perform templating operations without affecting nor being affected by templating and prompt decisions in other advisors.
* QuestionAnswerAdvisor
* PromptChatMemoryAdvisor
* VectorStoreChatMemoryAdvisor
Documentation and upgrade notes have been updated accordingly
Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
The DocumentPostProcessor is one of the modular RAG components introduce in M8. You can now use this API from within the RetrievalAugmentationAdvisor to post-process the retrieved documents before passing them to the model. For example, you can use such an interface to perform re-ranking of the retrieved documents based on their relevance to the query, remove irrelevant or redundant documents, or compress the content of each document to reduce noise and redundancy.
Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
- 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>
- 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>