Commit Graph

2090 Commits

Author SHA1 Message Date
Hari Ohm Prasth Rajagopal
f4d4dddf9d Add tests for McpWebFluxServerAutoConfiguration
Add unit tests to verify that the WebFlux server transport is properly configured
with a custom ObjectMapper that ignores unknown properties. This ensures that the
MCP server can handle JSON payloads containing fields not defined in the model
classes, which is important for forward compatibility.

Signed-off-by: Hari Ohm Prasath <hariohmprasath@gmail.com>
Signed-off-by: Hari Ohm Prasth Rajagopal <harrajag@amazon.com>
2025-05-01 14:45:31 +03:00
Christian Tzolov
3ceeb27101 feat(docs): add SSE endpoint configuration property to MCP client docs
- 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>
2025-05-01 14:19:20 +03:00
YunKui Lu
c2843f1990 Fix: Prevent exceptions when disabling Mcp server
- Prevent projects depending on `mcp-server-webmvc` or `mcp-server-webflux` from exceptions when `spring.ai.mcp.server.enabled` is set to `false`.
- Add unit tests to verify.

Signed-off-by: YunKui Lu <luyunkui95@gmail.com>
2025-05-01 14:01:41 +03:00
Christian Tzolov
04249e8257 feat(mcp): Add configurable SSE endpoint support for MCP client transports
Enhance MCP client transports with configurable SSE endpoint support:

- Add sseEndpoint parameter to SseParameters record
- Update HttpClientSseClientTransport to use builder pattern with sseEndpoint support
- Update WebFluxSseClientTransport to use builder pattern with sseEndpoint support
- Set default SSE endpoint to /sse when not explicitly configured
- Add tests for MCP client properties
- Enhance MCP client transport tests and refactor config

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-05-01 13:34:55 +03:00
Ilayaperumal Gopinathan
781e85dc2d Configuration updates to Spring AI BOM
Add repository element to the distributionManagement for Spring AI BOM

Add sonatype profile to Spring AI BOM

Add developer info to Spring AI BOM

Remove javadoc skip at spring-ai-spring-boot-testcontainers POM

Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
2025-05-01 08:05:27 +01:00
Ilayaperumal Gopinathan
3acc206eb2 Next development version 2025-04-30 17:51:20 +01:00
Ilayaperumal Gopinathan
b657cf3bae Release version 1.0.0-M8 2025-04-30 17:51:07 +01:00
Sun Yuhan
788fc3afe5 Rename the option skipBuiltInFunctionsValidation of StTemplateRenderer to supportStFunctions.
- Add javadocs

Signed-off-by: Sun Yuhan <1085481446@qq.com>
2025-04-30 12:33:34 -04:00
Sun Yuhan
af29a795b0 Added a "skipBuiltInFunctionsValidation" option to StTemplateRenderer, which defaults to false. When enabled, it skips validation of built-in functions in the template, preventing these built-in functions from being validated as variables to be replaced.
Signed-off-by: Sun Yuhan <1085481446@qq.com>
2025-04-30 12:13:33 -04:00
Mark Pollack
b39805af30 clean up upgrade-notes.adoc 2025-04-30 12:09:15 -04:00
Mark Pollack
c347c6feaf Refactor: Move evaluation, converter, transformer, and util classes
- 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>
2025-04-30 11:45:06 -04:00
Mark Pollack
aa24a56f9b Add deprecated tools(String...) method for backwards compat on ChatClient 2025-04-30 10:54:44 -04:00
Mark Pollack
e939295b03 Make DefaultToolCallingManager final 2025-04-30 10:46:45 -04:00
Mark Pollack
091fca2d16 refactor(client): rename overloaded tools methods in prompt builder
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>
2025-04-30 10:42:46 -04:00
Ilayaperumal Gopinathan
ec95eeb250 Revert "Add default ChatOptions to Prompt"
This reverts commit 4eeeb83d3f.

Revert "Make ImageOptions non-null when constructing ImagePrompt"

This reverts commit 0c0787b849.

Need to review more the impact of making these options not null.

Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
2025-04-30 10:21:52 -04:00
Berjan Jonker
af0303f65a Make responseMessage in AzureOpenAiChatModel.buildGeneration null-safe
Signed-off-by: Berjan Jonker <berjanjonker@users.noreply.github.com>
2025-04-30 09:53:23 -04:00
Christian Tzolov
5634d892fa Add tests for McpToolUtils.getToolCallbacksFromSyncClients method
- Tests empty client list handling returns empty result
- Tests single client with multiple tools correctly generates tool callbacks with prefixed names
- Tests multiple clients properly combine their tool callbacks
- Tests duplicate tool names across clients throw appropriate exceptions

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-04-30 08:17:02 +03:00
Christian Tzolov
e05552f6eb refactor(mcp): disable completion features and downgrade MCP SDK to 0.9.0
- Comment out AsyncCompletionSpecification and SyncCompletionSpecification imports
- Comment out completion parameters and processing in both sync and async server creation methods
- Downgrade MCP SDK version from 0.10.0-SNAPSHOT to 0.9.0

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-04-30 03:10:56 +03:00
Kushagra Thapar
6c85aeabba Updated azure service dependencies to the latest versions
Signed-off-by: Kushagra Thapar <kuthapar@microsoft.com>
2025-04-29 16:49:48 -04:00
Mark Pollack
435cf13647 Update docs to mention NoOpTemplateRenderer 2025-04-29 16:35:09 -04:00
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
砚池/Ivan
b0d671944a feat(mcp): Add tool callback configuration to MCP client properties
Change-Id: Iefc9de0425ad0654175172b7f0bc220e74e3227b
Signed-off-by: 砚池/Ivan <yanchi.zyc@bytedance.com>
2025-04-29 19:05:51 +01:00
He-Pin(kerr)
5aa22c4187 chore: Use stream flatmap when build toolcallbacks. (#2802)
Signed-off-by: 虎鸣 <hepin.p@alibaba-inc.com>
2025-04-29 18:25:26 +01:00
jonghoonpark
c6ccc1a4a3 Make allow image url for Anthropic API
Signed-off-by: jonghoonpark <dev@jonghoonpark.com>
2025-04-29 18:12:08 +01:00
“claudio-code”
d7eb9bb32e Added the possibility to configure the path together with the base-url
Signed-off-by: “claudio-code” <suporte2424@outlook.com>
2025-04-29 17:39:16 +01:00
Linar Abzaltdinov
a1db00ab1e Fixed message order for JDBC Chat Memory
- set timestamp manually to prevent saving equal timestamps while batch insert
- return DESC order into get query (in `JdbcChatMemory`)
- Update similar changes for JdbcChatMemoryRepository

This PR solves some problems with message ordering:

JdbcChatMemory fetches rows in DESC order, and MessageChatMemoryAdvisor get and add all messages in that order - from last to first. So messages list needs to be reversed.
After batch insert without specifying timestamp manually all rows have the same timestamp (because database sets current_timestamp by default). Sooo after fetching rows from database the message order is unpredictable - they have same timestamp.

Signed-off-by: Linar Abzaltdinov <abzaltdinov@gmail.com>
2025-04-29 16:04:32 +01:00
jonghoonpark
f5ac94c8e8 Add a missing getter to the CategoryScores class (#2939)
Signed-off-by: jonghoon park <dev@jonghoonpark.com>
2025-04-29 14:32:06 +01:00
yangtuooc
19d7601437 fix: fix stdio typos in variable names (#2778)
Signed-off-by: Wenhao Ma <296232679@qq.com>
2025-04-29 12:29:31 +01: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
jonghoonpark
b8be96cf79 apply builder pattern to AnthropicApi
Signed-off-by: jonghoonpark <dev@jonghoonpark.com>
2025-04-29 12:18:50 +01:00
kimsunghyun1995
b20e802259 fix: typo specification (#2791)
Signed-off-by: kimsunghyun <tjdgus2319@gmail.com>
2025-04-29 12:06:22 +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
jito
53406c1dd3 Fix missing table name in exception message in CassandraVectorStore (#2842)
Updated the `Preconditions.checkState` call to include `this.schema.table`
as an argument.

Signed-off-by: jitokim <pigberger70@gmail.com>
2025-04-29 11:15:01 +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
Miloš Havránek
9e9980707a fix null systemText in PromptChatMemoryAdvisor
Signed-off-by: Miloš Havránek <MilosHavranek@users.noreply.github.com>
2025-04-29 08:02:58 +01:00
Nicolas KRIER
388068d481 Maven build issues fixes
Signed-off-by: Nicolas KRIER <7557886+nicolaskrier@users.noreply.github.com>
2025-04-29 07:29:18 +01:00
Christian Tzolov
1457dc800d feat(mcp): add support for completion specifications in MCP server
Add support for completion specifications in both sync and async MCP servers by:

- Adding parameters for SyncCompletionSpecification and AsyncCompletionSpecification
- Implementing registration of completion specifications in server builders
- Updating capabilities builders to include completions
- Upgrading MCP SDK version to 0.10.0-SNAPSHOT

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-04-29 07:54:59 +03:00
Linar Abzaltdinov
1bf5787865 Fix message order in Cassandra chat memory after retrieving from db
Fixes: https://github.com/spring-projects/spring-ai/issues/2815

Added integration tests

Replaced deprecated CassandraContainer test-container by actual one

Reordered imports in CassandraChatMemoryIT

Signed-off-by: Linar Abzaltdinov <abzaltdinov@gmail.com>

Fixing CassandraChatMemoryAutoConfigurationIT for the correct ordering

Signed-off-by: Soby Chacko <soby.chacko@broadcom.com>
2025-04-28 20:20:10 -04:00
Seunghyeon Ji
b74e30816c Add three request body parameters to Mistral AI Chat Completion
Add presence_penalty, frequency_penalty, and n parameters
Following Mistral AI API specifications as referenced in https://docs.mistral.ai/api/#tag/chat

Rename Builder method N() to n()

Signed-off-by: Seunghyeon Ji <3aroa2@gmail.com>
2025-04-28 19:05:51 -04: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
Ilayaperumal Gopinathan
0c0787b849 Make ImageOptions non-null when constructing ImagePrompt
- Pass non-null ImageOptions when instantiating ImagePrompt

Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
2025-04-28 19:07:37 +01: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
He-Pin(kerr)
637a6b85c0 chore: fix typo (#2827)
Signed-off-by: 虎鸣 <hepin.p@alibaba-inc.com>
2025-04-28 18:43:25 +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