Commit Graph

2070 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
砚池/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
努力的小雨
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
Mark Pollack
783e21966b Remove deprecated code in observation context
-  The commit removes deprecated methods and parameters, including
-  requestOptions in image observation context and proxyToolCalls in Vertex AI
-  Gemini options. Updates code to use ImagePrompt.getOptions() instead of
-  the separate parameter for more consistent API design.
2025-04-28 13:21:51 -04: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
Eddú Meléndez Gonzales
22c778f8cc Switch CassandraContainer implementation (#2663)
`org.testcontainers.containers.CassandraContainer` is deprecated.

Signed-off-by: Eddú Meléndez <eddu.melendez@gmail.com>
2025-04-28 17:08:27 +01:00
Alexandros Pappas
dc5922fe9a feat: Add equals, hashCode, deep copy, and tests to OCICohereChatOptions (#2361)
This commit enhances OCICohereChatOptions by:

- Updating equals and hashCode methods for proper object comparison.
- Updating copy() method, creating new instances of mutable collections (List, Set, Map, Metadata) to prevent shared state.
- Adding OCICohereChatOptionsTests to verify copy(), builders, setters, and default values.

Signed-off-by: Alexandros Pappas <apappascs@gmail.com>
2025-04-28 17:03:53 +01: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
Soby Chacko
f18aac07b7 GH-2518: Remove requestOptions from observation context objects
Fixes: #2518

Issue: https://github.com/spring-projects/spring-ai/issues/2518

This commit removes the deprecated requestOptions field from ChatModelObservationContext
and EmbeddingModelObservationContext classes. Instead of passing options separately,
the code now retrieves them directly from the request objects (prompt.getOptions() or
embeddingRequest.getOptions()).

Key changes:
- Removed requestOptions parameter from observation context builders
- Updated all model implementations to stop passing options separately
- Fixed EmbeddingRequest handling in several model implementations
- Added buildEmbeddingRequest method in models to properly merge options

This change simplifies the API and removes duplication, as options are already
available in the request objects themselves.

Signed-off-by: Soby Chacko <soby.chacko@broadcom.com>
2025-04-28 16:44:13 +01:00
Ilayaperumal Gopinathan
4eeeb83d3f Add default ChatOptions to Prompt
- Remove @Nullable on ChatOptions
 - By default, pass the default ChatOptions from the DefaultChatOptionsBuilder

Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
2025-04-28 11:41:31 -04:00
Ilayaperumal Gopinathan
363ebf8de6 Fix Spring AI BOM flatten maven plugin configuration
- Make sure to keep the dependencyManagement entries

Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
2025-04-28 16:06:18 +01:00
Ilayaperumal Gopinathan
8deb23afe1 Removing deprecated constructors and methods
- VectorStoreChatMemoryAdvisor constructors
- "withX" methods in AnthropicApi
- Deprecated function methods in VertexAiGeminiChatOptions
- Deprecated test methods
- Removed deprecation from Document.getContentFormatter
- Removed withEmbedding method in SimpleVectorStoreContent")

Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
2025-04-28 10:28:22 -04:00
Ilayaperumal Gopinathan
35ed49bf24 Update EvaluationResponse
- Remove deprecation from EvaluationResponse's constructor as it is still being used

Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
2025-04-28 14:20:24 +01:00
Łukasz Jernaś
c726005a5b Add autoconfiguration processor for autoconfigure modules
Signed-off-by: Łukasz Jernaś <lukasz.jernas@allegro.com>
2025-04-28 12:49:53 +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
He-Pin(kerr)
283a41fd13 chore: Fix typo in toolContext. (#2854)
Signed-off-by: 虎鸣 <hepin.p@alibaba-inc.com>
2025-04-28 10:51:12 +01:00
Ilayaperumal Gopinathan
7f0a97d4a7 Remove FunctionCallbackResolver from chat model autoconfigurations
- FunctionCallbackResolver is deprecated and replaced by ToolCallingManager's ToolCallbackResolver

Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
2025-04-28 08:01:59 +01:00
Ilayaperumal Gopinathan
acd986e59c Add maven plugins to Spring AI BOM
Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
2025-04-28 07:53:40 +01:00
LiujunjieALiling
4e313a9dc6 feat(mcp): Add SSE endpoint parameter to WebFlux and WebMvc transport providers
Add serverProperties.getSseEndpoint() parameter to both WebFluxSseServerTransportProvider
and WebMvcSseServerTransportProvider constructors.

Signed-off-by: liujunjie <smartliujunjie@gmail.com>
2025-04-28 07:50:40 +03:00