- 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>
* 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>
This commit makes several improvements to the OpenAiImageOptions class:
1. Remove all deprecated methods from OpenAiImageOptions.Builder:
- Removed withN(), withModel(), withQuality(), withResponseFormat(),
withWidth(), withHeight(), withStyle(), and withUser() methods
- These were marked as @Deprecated(forRemoval = true, since = "1.0.0-M8")
2. Align OpenAiImageOptions structure with OpenAiChatOptions:
- Added fromOptions() static method for creating copies
- Added copy() instance method
- Updated Builder class to match pattern in OpenAiChatOptions
- Changed Builder field from private final to protected
- Added Builder constructor that takes an existing options object
3. Enhance setSize() method to maintain consistency:
- Updated setSize() to parse the size string and update width/height properties
- Added proper error handling for invalid formats
- Ensures consistent state between size, width, and height properties
4. Comprehensive test coverage improvements:
- Added tests for builder pattern with all fields
- Added tests for copy functionality
- Added tests for all setter methods
- Added tests for default values
- Added tests for equals(), hashCode(), and toString() methods
- Added specific tests for the updated setSize() behavior
- Fixed test expectations to match actual implementation behavior
These changes improve code consistency, maintainability, and test coverage
while removing deprecated methods that were scheduled for removal.
Signed-off-by: jonghoonpark <dev@jonghoonpark.com>
* 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>
This PR introduces support for streamUsage in the AzureOpenAiChatOptions.
- Set com.azure.ai.openai.models.ChatCompletionStreamOptions#includeUsage via AzureOpenAiChatOptions.
Additionally:
- Updates the unit test AzureOpenAiChatOptionsTests to reflect the changes.
- Updates the documentation in azure-openai-chat.adoc.
Signed-off-by: Andres da Silva Santos <40636137+andresssantos@users.noreply.github.com>
- Add new connections.[name].sse-endpoint property with default value /sse
- Update table format to include default values column
- Clarify that connections.[name].url is a base URL endpoint
Related to #2724
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
- Move evaluation core classes (Request, Response, Evaluator) to spring-ai-commons.
- Move chat-specific evaluators (FactChecking, Relevancy) to spring-ai-client-chat#evaluation package.
- Move OutputConverter implementations and related classes to spring-ai-model#converter package.
- Move MetadataEnricher transformer classes to spring-ai-model#transformer package.
- Move PromptAssert utility to spring-ai-rag#util package.
- Update relevant pom.xml files and adjust imports in affected classes.
- Document class movements in upgrade-notes.adoc for M8 release.
This refactoring improves module organization and separation of concerns.
Signed-off-by: Mark Pollack <mark.pollack@broadcom.com>
Renames the ambiguous overloaded `tools` methods in `ChatClient.PromptRequestSpec`
to `toolNames` and `toolCallbacks` respectively. This improves clarity
and prevents potential issues with method dispatching based on argument types.
Updates relevant code examples and adds documentation to upgrade notes.
Signed-off-by: Mark Pollack <mark.pollack@broadcom.com>
- Extend the ChatClient with a new templateRenderer() method to pass a custom TemplateRenderer object used to render user and system templates.
- Evolve the QuestionAnswerAdvisor to accept a PromptTemplate for customising the RAG prompt and templating logic while maintaining backward compatibility.
- Introduce integration tests for the QuestionAnswerAdvisor.
- Document the TemplateRenderer API and how to use it to build PromptTemplate with custom templating logic.
- Document how to customise the templating logic used internally by the ChatClient via the TemplateRendererAPI.
Add validation tests and improve PromptTemplate resource handling
Enhance robustness and reliability of the PromptTemplate class with better
resource handling and comprehensive input validation:
- Add dedicated validation tests for builder methods with null/invalid inputs
- Improve renderResource method to gracefully handle edge cases:
- Null resources return empty string
- ByteArrayResource handling with proper charset (UTF-8)
- Empty resources check with proper existence test
- Better error handling with logging instead of exception propagation
- Add input validation assertions to all Builder methods
- Fix typo in deprecated annotation comment ("fahvor" → "favor")
Update documentation to clarify template rendering in different contexts:
- Add clear notes about TemplateRenderer usage in ChatClient vs Advisors
- Document how advisor template customization differs from ChatClient template rendering
- Add comprehensive API upgrade notes for template-related deprecations
- Include detailed migration examples for PromptTemplate and QuestionAnswerAdvisor
Fixes gh-355, gh-1687, gh-2448, gh-1849, gh-1428
Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
fix: correct name typo from 'AsynClients' to 'AsyncClients'
fix: correct name typo from 'Autoconfiguration' to 'AutoConfiguration', 'optoins' to 'options'
fix: correct name typo from 'Differnt' to 'Different'
fix: correct name typo from 'Compatability' to 'Compatibility'
fix: correct name typo from 'Evalutaor' to 'Evaluator'
fix: correct name typo from 'Empyt' to 'Empty'
fix: correct name typo from 'Chroma Vecor Store' to 'Chroma Vector Store'
fix: correct name typo from 'Specificaiton' to 'Specification'
fix: correct name typo from 'applicaiton' to 'application'
fix: correct name typo from 'apropriate' to 'appropriate'
fix: correct name typo from 'asigned' to 'assigned'
fix: correct name typo from 'capabilitity' to 'capability'
fix: correct name typo from 'configuraiton' to 'configuration'
fix: correct name typo from 'conntection' to 'connection'
fix: correct name typo from 'curent' to 'current'
fix: correct name typo from 'customised' to 'customized'
Signed-off-by: Changho Kim <dukso4885@gmail.com>
docs: add Maven mirror config note for Spring AI snapshots
Add documentation about Maven mirror configuration when using Spring AI
snapshots, including examples of correct mirrorOf settings to allow
access to Spring repositories.
Signed-off-by: shishuiwuhen2009 <90782280+shishuiwuhen2009@users.noreply.github.com>
The DocumentPostProcessor API has been introduced to implement post-retrieval components in a Modular RAG architecture, superseding the DocumentCompressor, DocumentRanker, DocumentSelector APIs that are now deprecated.
Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
Introduce defining Media objects from a URI, deprecating the previous URL support.
Fixes gh-1147
Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
* The new spring.ai.model.* properties introduced in M7 were missing Spring Boot configuration metadata.
* Furthermore, the breaking change was not documented as the previous properties have been completely removed. Documentation has been added in the upgrade notes for this change.
Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
* ChatClient observations now include the full prompt content instead of just the userText and systemText. Furthermore, they include consistent telemetry for the tools passed via the ChatClient and a first-class conversation ID when using memory advisors. Incomplete or unsafe attributes have been deprecated.
* Adopted the new robust Advisor APIs for BaseAdvisor and RetrievalAugmentationAdvisor.
* Improved the prompt augmentation facilities in ChatClientRequest and Prompt for performance and immutability.
* Fixed integration test racing condition.
* Updated the documentation for ChatClient and Observability accordingly.
* Documented changes in upgrade notes.
* Introduced `prompt.augmentUserMessage(String text)` to directly replace the user message content.
* Added `prompt.augmentUserMessage(Function<UserMessage, UserMessage> augmenter)` for more granular updates using the `userMessage.mutate()` pattern, allowing modification of text, media, and metadata.
Relates to gh-2655
Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
- Remove the deprecated FunctionCallback related classes, references
- Replace them with the corresponding ToolCallback usage
Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
The vector-index-name in the MongoDB configuration options should be wrong, but it's okay when I'm trying index-name (no warning)
Signed-off-by: qwp_p <70431503+RobinElysia@users.noreply.github.com>
Add documentation about Maven mirror configuration when using Spring AI
snapshots, including examples of correct mirrorOf settings to allow
access to Spring repositories.
Signed-off-by: shishuiwuhen2009 <90782280+shishuiwuhen2009@users.noreply.github.com>
* ChatMemory will become a generic interface to implement different memory management strategies. It’s been moved from the “”spring-ai-client-chat” package to “spring-ai-model” package while retaining the same package, so it’s transparent to users.
* A MessageWindowChatMemory has been introduced to provide support for a chat memory that keeps at most N messages in the memory.
* A ChatMemoryRepository interface has been introduced to support different storage strategies for the chat memory. It’s meant to be used as part of a ChatMemory implementation. This is different than before, where the storage-specific implementation was directly tied to the ChatMemory. This design is familiar to Spring users since it’s used already in the ecosystem. The goal was to use a programming model similar to Spring Session and Spring Data.
* The JdbcChatMemory has been supersed by JdbcChatMemoryRepository.
* A ChatMemory bean is auto-configured for you whenever using one of the Spring AI Model starters. By default, it uses the MessageWindowChatMemory implementation and stores the conversation history in memory. If a different repository is already configured (e.g., Cassandra, JDBC, or Neo4j), Spring AI will use that instead.
* First-class documentation has been introduced to describe the ChatMemory API and related features.
* All the changes introduced in this PR are backward-compatible.
Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
- Introduce new TemplateRenderer API providing the logic for rendering an input template.
- Update the PromptTemplate API to accept a TemplateRenderer object at construction time.
- Move ST logic to StTemplateRenderer implementation, used by default in PromptTemplate. Additionally, make start and end delimiter character configurable.
Relates to gh-2655
Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>