- 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>
- Replace model-specific enabled properties with unified spring.ai.model.embedding property
- Update documentation for Bedrock Cohere and Titan embedding models
- Add missing dependency information for RAG advisors in documentation
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
- Update MCP SDK version to 0.9.0
- Add baseUrl and sseEndpoint properties to McpServerProperties
- Update WebFlux and WebMvc server transport providers to use new URL configuration properties
- Remove deprecated backward compatibility code and related tests
- Remove deprecated methods from McpToolUtils
- Update MCP SDK version to 0.9.0-SNAPSHOT
- Add tool filtering capability to MCP Tool Callback Providers
Introduces a BiPredicate-based filtering mechanism for both Sync and Async
MCP Tool Callback Providers, allowing selective tool discovery based on
custom criteria. This enables filtering tools by name, client, or
any combination of properties.
* Apply filter in getToolCallbacks() methods for both providers
* Add tests for various filtering scenarios
- Add utility method to retrieve MCP exchange from tool context
* Add constant TOOL_CONTEXT_MCP_EXCHANGE_KEY to replace hardcoded exchange string
* Implement getMcpExchange utility method to safely retrieve the MCP exchange object
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
- Docker Desktop 4.40 has released a Docker Model Runner, which is OpenAI compatible.
- Add docs for Docker Model Runner
Signed-off-by: Eddú Meléndez <eddu.melendez@gmail.com>
This change modifies the voice parameter in OpenAI Audio Speech API from using the
Voice enum directly to using the string value of the enum. This provides more
flexibility for handling voice options, especially for custom voices or when voice
names come from configuration.
- Change voice parameter type from Voice enum to String
- Add overloaded methods to accept both enum and string values
- Update tests and documentation to reflect these changes
Signed-off-by: jonghoon park <dev@jonghoonpark.com>
Introduce a new ToolExecutionEligibilityChecker interface to provide a more flexible way to determine
when tool execution should be performed based on model responses. This abstraction replaces the
hardcoded logic previously scattered across the codebase.
- Adds a new ToolExecutionEligibilityChecker interface in spring-ai-core
- Integrates the checker into OpenAiChatModel with appropriate defaults
- Updates OpenAiChatAutoConfiguration to support the new interface
- Provides a default implementation that maintains backward compatibility
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
refactor: Replace ToolExecutionEligibilityChecker with ToolExecutionEligibilityPredicate
- Replacing ToolExecutionEligibilityChecker with ToolExecutionEligibilityPredicate
- Changing from Function<ChatResponse, Boolean> to BiPredicate<ChatOptions, ChatResponse>
- Adding a DefaultToolExecutionEligibilityPredicate implementation
- Updating AnthropicChatModel and OpenAiChatModel to use the new predicate
- Updating auto-configurations to inject the new predicate
- Adding comprehensive tests for the new predicate implementation
The new approach provides a cleaner and more consistent way to determine when tool execution should be performed based on both prompt options and chat responses.
Add Bedrock Converse support
add mistral support
Add ollama and vertex gemini
add ToolExecutionEligibilityPredicate docs
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>