Commit Graph

746 Commits

Author SHA1 Message Date
Thomas Vitale
5527d037f2 Configure TemplateRenderer in ChatClient
- 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>
2025-04-29 16:21:10 -04:00
YunKui Lu
4a620815d3 GH-2743: Correct erroneous content in documents (#2744)
Fixes GH-2743 (https://github.com/spring-projects/spring-ai/issues/2743)

Revised the following files to ensure accuracy:
- `openai-chat.adoc`
- `openai-embeddings.adoc`
- `usage-handling.adoc`

Fixes #2743

Signed-off-by: YunKui Lu <luyunkui95@gmail.com>
2025-04-29 12:19:56 +01:00
jonghoon park
d48f4f63db apply builder pattern to OllamaApi
Signed-off-by: jonghoon park <dev@jonghoonpark.com>
2025-04-29 11:16:52 +01:00
Changho Kim
2e0017db49 fix: Typo at the codebase
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>
2025-04-29 10:13:21 +01:00
shishuiwuhen2009
f759883c6c Update getting-started.adoc
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>
2025-04-29 09:48:51 +01:00
Thomas Vitale
1e1ad41815 Introduce DocumentPostProcessor API for Modular RAG
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>
2025-04-28 17:59:58 -04:00
Thomas Vitale
5397108b5a Support URI in Media
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>
2025-04-28 17:54:30 -04:00
Thomas Vitale
688eab19f9 Add missing metadata for spring.ai.model.* properties
* 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>
2025-04-28 17:49:31 -04:00
Thomas Vitale
faa8778b6a Make ChatClient and Advisor APIs more robust - Part 2
* 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>
2025-04-28 17:35:55 -04:00
jito
3b752bbb54 Update deprecated Media constructor usage in documentation example (#2762)
Signed-off-by: jitokim <pigberger70@gmail.com>
2025-04-28 18:57:16 +01:00
Shawn Yu
8f5dbc8963 fix typo(Egineering->Engineering) (#2797)
Signed-off-by: Shawn Yu <syyu2015@gmail.com>
2025-04-28 18:55:04 +01:00
jito
37351fbba4 Rename ToolRegistration to ToolSpecification (#2859)
Signed-off-by: jitokim <pigberger70@gmail.com>
2025-04-28 18:41:28 +01:00
jito
98ed0fbfd5 Remove broken example applications from list (#2689)
Signed-off-by: jitokim <pigberger70@gmail.com>
2025-04-28 18:36:47 +01:00
努力的小雨
967c1d6761 feat (#2749) 2025-04-28 18:34:08 +01:00
吴伟杰
51046c78dd Fix typo in retrieval-augmented-generation.adoc (#2652)
reulsts -> results

Signed-off-by: 吴伟杰 <wuweijie@apache.org>
2025-04-28 18:31:43 +01:00
Ilayaperumal Gopinathan
f0702c343b Remove deprecated FunctionCallback references
- Remove the deprecated FunctionCallback related classes, references
 - Replace them with the corresponding ToolCallback usage

Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
2025-04-28 12:19:52 -04:00
Jackie Gleason
e5faad5ea4 Docs don't show these as bullets because they are in a note block. Looking at the other code it should be like this. (#1810) 2025-04-28 17:00:55 +01:00
qwp_p
9489ace425 Update mongodb.adoc (#2809)
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>
2025-04-28 12:37:26 +01:00
shishuiwuhen2009
ffd8f1fa6f Update getting-started.adoc (#2880)
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>
2025-04-28 11:07:44 +01:00
David Frizelle
c95d5c05ba Bump org.apache.tika to 3.1.0 (#2900)
Signed-off-by: David Frizelle <david.frizelle@gmail.com>
2025-04-28 11:00:29 +01:00
Thomas Vitale
0024e4dd49 Chat Memory Enhancements
* 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>
2025-04-25 15:53:20 -04:00
Mark Pollack
98052624b1 Remove Qianfan and Moonshot model modules
Drop support for the Qianfan and Moonshot models by removing their modules from the build.

These integrations are now maintained in the community repositories:
https://github.com/spring-ai-community/qianfan
https://github.com/spring-ai-community/moonshot
2025-04-25 14:02:23 -04:00
Mark Pollack
ff52859b2d migrate remaining moonshot modules to community repo 2025-04-25 13:05:11 -04:00
Thomas Vitale
2bc29dab32 Introduce TemplateRenderer for prompt templating
- 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>
2025-04-24 17:17:40 -04:00
Theo van Kraay
e723371723 cosmos db entra id support and fixes
add doc changes

Signed-off-by: Theo van Kraay <theo.van@microsoft.com>
2025-04-21 14:20:34 -04:00
Ilayaperumal Gopinathan
c0bc6231a5 Remove FunctionCallback deprecations
- Remove the super type FunctionCallingOptions from ToolCallingChatOptions

        - Move toolContext builder methods into ToolCallingChatOptions

    - Remove Model chat options' function specific usages

        - Replace them with tooling:

              FunctionCallback -> ToolCallback
              functions -> toolNames
        - Remove proxyToolCalls use

        - Remove deprecated methods

     - Update ChatClient methods

        - Replace FunctionCallback -> ToolCallback

        - Remove deprecated methods

     - Update DefaultChatClient

        - functionNames -> toolNames
        - functionCallbacks -> toolCallbacks

     - Update AdviseRequest

        - functionNames -> toolNames
        - functionCallbacks -> toolCallbacks
        - Remove FunctionCallingOptions and replace it with ToolCallingOptions

      - Remove FunctionCallingHelper

      - Update DefaultToolCallingChatOptions, ToolCallbackResolvers, ToolCallbackProvider to use Tool calling types

     - Update documentation

     - Remove VertexAiGeminiChatModelFunctionCallingIT and adjust MistralAiApiToolFunctionCallIT

Resolves #2528
Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
2025-04-18 10:55:55 +02:00
可能
aaf1589669 Update tools.adoc , change colon to semicolon (#2741)
Signed-off-by: 可能 <contact@revengemission.com>
2025-04-15 10:28:13 +01:00
Tran Ngoc Nhan
257c91ccf2 Fix typo (#2719)
Signed-off-by: Tran Ngoc Nhan <ngocnhan.tran1996@gmail.com>
2025-04-14 16:35:06 +01:00
Christian Tzolov
def15f9295 (docs) minor PE patterns copyedit changes
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-04-14 11:46:45 +02:00
Christian Tzolov
d32e773c50 (docs) Add Prompt Egineering Patterns section
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-04-14 10:42:44 +01:00
Christian Tzolov
2dad4822cf refactor(docs): improve Berock embedding and RAG documentation
- 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>
2025-04-11 10:28:44 +02:00
Mark Pollack
d4a3f7a774 Update upgrade notes 2025-04-10 14:53:10 -04:00
Christian Tzolov
3409c1fd87 feat(mcp): update WebFlux and WebMvc server transport providers with URL configuration
- 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>
2025-04-10 19:30:49 +02:00
Mark Pollack
0aea1866e4 Update support boot versions in getting started doc 2025-04-10 12:56:18 -04:00
Eddú Meléndez
eef5f74b4c Add support for Docker Model Runner
- 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>
2025-04-10 11:58:25 -04:00
gongzhongqiang
923e09a1b0 feat(ollama): Add min_p parameter for improved sampling control
- Add min_p option
- Add qwq model

Signed-off-by: gongzhongqiang <gongzhongqiang@apache.org>
2025-04-10 11:20:13 +01:00
jonghoon park
14e7033a8e refactor(openai): change voice parameter to string in OpenAI Audio Speech API (#2395)
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>
2025-04-09 21:10:31 +02:00
Viacheslav Dobrynin
a43cdc8f79 fix: update MCP Java SDK docs link (#2660)
Signed-off-by: Viacheslav Dobrynin <49430239+viacheslav-dobrynin@users.noreply.github.com>
2025-04-08 15:38:44 +01:00
Emmanuel Ferdman
37dc443b84 Update OpenAiApiToolFunctionCallIT source (#2661)
Signed-off-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>
2025-04-08 15:37:01 +01:00
Christian Tzolov
0d748e2b87 feat(tool): Add ToolExecutionEligibilityChecker interface
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>
2025-04-08 15:22:53 +01:00
leijendary
4be10028b0 feat: JDBC implementation of ChatMemory
Signed-off-by: leijendary <jonathanleijendekker@gmail.com>

Remove references to spring-ai-core module in jdbc chat memory
2025-04-07 15:08:58 -04:00
Timo Salm
ef0a2025f2 Fix documentation for removed 'spring.ai.vectorstore.redis.uri' property 2025-04-07 08:21:25 +01:00
Alexandros Pappas
59fbd9e3eb fix: remove default temperature on all QueryTransformer implementations
Signed-off-by: Alexandros Pappas <apappascs@gmail.com>

update documentation

Signed-off-by: Alexandros Pappas <apappascs@gmail.com>
2025-04-07 07:52:17 +01:00
Soby Chacko
edc35667c1 Minor polishing in upgrade-notes
Signed-off-by: Soby Chacko <soby.chacko@broadcom.com>
2025-04-04 13:27:17 -04:00
Mark Pollack
dde01a56ef Add diagram for new module structure 2025-04-04 13:03:55 -04:00
Mark Pollack
4f63fdc305 Add upgrade notes 2025-04-04 12:43:23 -04:00
Mark Pollack
76d6e7d6d0 Update docs based on module refactorings 2025-04-04 12:43:22 -04:00
Yanming Zhou
25c584a783 Fix typo in ETL pipeline document (#2626)
Signed-off-by: Yanming Zhou <zhouyanming@gmail.com>
2025-04-03 10:35:50 +01:00
jonghoonpark
a50f80b7a6 update mcp-client-boot-starter-docs.adoc (#2624)
Signed-off-by: jonghoonpark <dev@jonghoonpark.com>
2025-04-03 07:37:39 +01:00
Xwh
49df62533d Update vectordbs doc,batching-strategy is remove (#2550)
Signed-off-by: Xwh <981800006@qq.com>
2025-04-01 11:11:45 +01:00