Commit Graph

2259 Commits

Author SHA1 Message Date
Thomas Vitale
f9f71a805d RAG - Document joiner should sort by score
The current implementation of ConcatenationDocumentJoiner should sort the final document list by score in descending order, so to keep the most relevant documents at the front of the list. This PR fixes that.

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2025-05-18 18:01:49 -04:00
Thomas Vitale
46491c0426 Relaxed toolCallArguments validation
There seems to be some models not handling correctly the non-nullability of toolCallArguments when defining a tool call. For example, the Ollama implementation is always null-safe (if no tool argument, then '{}' is used). Other implementations might produce a null value.

This PR relaxes the toolCallArguments validation to support null toolCallArguments within ToolCallingObservationContext.

Fixes gh-3234

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2025-05-18 18:00:04 -04:00
Thomas Vitale
81137cae54 MCP ToolCallbackProvider autoconfig should use concrete class
Currently, the MCP Tool autoconfiguration defines the SyncMcpToolCallbackProvider and AsyncMcpToolCallbackProvider beans returning the ToolCallbackProvider interface. That generates autowiring warnings in IDEs when trying to inject the specific class.

The Spring Boot project recommends being specific. 'When declaring a @Bean method, provide as much type information as possible in the method’s return type. For example, if your bean’s concrete class implements an interface the bean method’s return type should be the concrete class and not the interface. Providing as much type information as possible in @Bean methods is particularly important when using bean conditions as their evaluation can only rely upon to type information that is available in the method signature.'

See https://docs.spring.io/spring-boot/reference/features/developing-auto-configuration.html#features.developing-auto-configuration.condition-annotations.bean-conditions

This PR ensures concrete classes are used.

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2025-05-18 21:26:37 +02:00
Christian Tzolov
14972f981f docs: minor adivsor docs update
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-05-18 19:10:32 +02:00
Christian Tzolov
36c597798d docs: reorganize tool calling documentation and add observability details
- Update Observability section with details about tool calling observability support
- Move "Migrating to ToolCallback API" guide from Tool Calling section to Upgrade Notes
- Update Observability section with details about tool calling observability support

Related to #3230

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-05-18 08:37:57 -04:00
Yanming Zhou
769cf10326 JdbcChatMemoryRepository should use the provided JdbcTemplate
Before this commit, the underlying `JdbcTemplate` is created like `new JdbcTemplate(providedJdbcTemplate.getDataSource())`, it means that settings on provided `JdbcTemplate` will lose.

Signed-off-by: Yanming Zhou <zhouyanming@gmail.com>
2025-05-17 11:51:55 -04:00
Yanming Zhou
b83a162506 JdbcChatMemoryRepository should use the provided JdbcTemplate
Before this commit, the underlying `JdbcTemplate` is created like `new JdbcTemplate(providedJdbcTemplate.getDataSource())`, it means that settings on provided `JdbcTemplate` will lose.

Signed-off-by: Yanming Zhou <zhouyanming@gmail.com>
2025-05-17 11:50:39 -04:00
Yanming Zhou
bbc2bbf661 Improve JdbcChatMemoryRepository to simplify findConversationIds()
Signed-off-by: Yanming Zhou <zhouyanming@gmail.com>
2025-05-17 11:11:13 -04:00
Mark Pollack
4ae26547db Remove file not intended to be in repo 2025-05-17 10:53:19 -04:00
Soby Chacko
b2d5ff0693 GH-3187: Replace Spring environment variables with custom alternatives
Fixes: #3187

This commit addresses the issue with Spring environment variables that directly
mirror Spring AI application properties, which can confuse users into thinking
they should always set environment variables that match Spring property names.

Instead, we've replaced all instances of SPRING_* prefixed environment variables
in the documentation with custom-named alternatives that are referenced using
Spring Expression Language (SpEL) or retrieved programmatically.

Each documentation section now shows multiple configuration approaches:

- Direct property setting in application.properties/yml
- Using custom environment variables with SpEL
- Accessing environment variables programmatically

This gives users more flexibility while making it clear that using SPRING_*
prefixed environment variables is not required or recommended.

Signed-off-by: Soby Chacko <soby.chacko@broadcom.com>
2025-05-17 12:56:02 +01:00
Christian Tzolov
c2a694900c docs: Document the MCP ToolContext support
Resolves #3209

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-05-17 13:53:24 +02:00
Christian Tzolov
9ed7535ba0 feat(mcp): Add request timeout configuration for MCP server
Add support for configuring request timeout in MCP server with a default of 20 seconds.
This timeout applies to all requests made through the client, including tool calls,
resource access, and prompt operations.

- Add requestTimeout property to McpServerProperties with default of 20s
- Configure server builder with the timeout value
- Add tests for default and custom timeout configurations
- Update documentation with the new property

Resolves #3205

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-05-17 12:41:48 +02:00
Soby Chacko
8b8fb4f02d GH-886: feat(opensearch): Add path prefix configuration support
Fixes: #886

Add ability to configure path prefix for OpenSearch API endpoints via properties.
This allows connecting to OpenSearch instances running behind a reverse proxy
with a non-root path, similar to Spring Elasticsearch's path-prefix property.

- Add pathPrefix property to OpenSearchVectorStoreProperties
- Apply pathPrefix to OpenSearchClient when configured
- Add documentation and unit tests

Signed-off-by: Soby Chacko <soby.chacko@broadcom.com>
2025-05-17 09:59:49 +01:00
Andrei Shakirin
0bbccf8ca0 fix: #2146 getting default AWS region using DefaultAwsRegionProviderChain
Signed-off-by: Andrei Shakirin <andrei.shakirin@gmail.com>
2025-05-17 09:11:36 +02:00
Jonatan Ivanov
cd3fc2f816 Change log level from DEBUG to INFO for ObservationHandlers
The features are disabled by default and users need to explicitly
enable them. Probably it makes more sense to log on INFO level so that
users don't need to change the log level if they use the default
behavior of Spring Boot.

See gh-3003
See gh-3127
2025-05-17 08:02:45 +02:00
Christian Tzolov
5d6bbd9368 refactor: update dependencies to use spring-ai-model and spring-ai-commons
Replace spring-ai-client-chat dependency with spring-ai-model in model implementations
and memory repositories, and with spring-ai-commons in document readers. This change
improves the dependency structure by having components depend on the appropriate
abstraction level.

Additional changes:
- Add slf4j-api dependency to pdf-reader and spring-ai-retry
- Move spring-ai-client-chat to test scope in spring-ai-ollama
- Fix XML formatting in some pom.xml files

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-05-16 19:58:11 +02:00
Jhzlo
8a5f68d655 refactor: remove redundant samples() method
samples() duplicates N(), both setting the same field.
Keeping only N() simplifies the builder API and aligns with ImageOptions.

Signed-off-by: Jhzlo <kjh0010703@naver.com>
2025-05-16 12:57:47 -04:00
Jhzlo
2721c9e676 refactor: simplify stylePreset merge logic in StabilityAiImageOptions builder
Replaces redundant or conflicting stylePreset assignments with a single mergeOption call using runtime style and default stylePreset.

Signed-off-by: Jhzlo <kjh0010703@naver.com>
2025-05-16 12:50:20 -04:00
Mark Pollack
0147d3bd55 Fix typos
Signed-off-by: Ji To Kim <jitokim@users.noreply.github.com>
Signed-off-by: Mark Pollack <mark.pollack@broadcom.com>
2025-05-16 12:45:08 -04:00
Yanming Zhou
bb3556e8d1 Fix that spring.ai.mcp.server.base-url is ignored
Signed-off-by: Yanming Zhou <zhouyanming@gmail.com>
2025-05-16 17:30:32 +02:00
Christian Tzolov
d1ead23aa0 minor test name spelling fix
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-05-16 16:55:15 +02:00
Christian Tzolov
4bde57790d fix checkstyle
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-05-16 10:08:23 -04:00
Christian Tzolov
327cf40e97 feat(mcp): Add granular control over MCP server capabilities
- Add capability configuration to enable/disable tools, resources, prompts, and completions individually
- Refactor server configuration to conditionally register capabilities based on configuration
- Add support for server instructions configuration
- Update documentation with new capability options and completion management
- Add tests for new capabilities and configurations

Resolves #3207

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-05-16 10:08:23 -04:00
Mark Pollack
9392485bd5 Fix VectorStoreChatMemoryAdvisor streaming bug
- Override adviseStream method in VectorStoreChatMemoryAdvisor to properly handle streaming responses
- Add tests to verify the fix works with both normal and problematic streaming scenarios

Fixes #3152

Signed-off-by: Mark Pollack <mark.pollack@broadcom.com>
2025-05-16 09:26:27 -04:00
Ilayaperumal Gopinathan
20ccd1f0ac Disable checkstlye check by default
Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
2025-05-16 14:10:59 +01:00
Mark Pollack
2f5d53fde0 Fix VectorStoreChatMemoryAdvisor streaming bug
- Override adviseStream method in VectorStoreChatMemoryAdvisor to properly handle streaming responses
- Add tests to verify the fix works with both normal and problematic streaming scenarios

Fixes #3152

Signed-off-by: Mark Pollack <mark.pollack@broadcom.com>
2025-05-16 14:08:20 +01:00
Soby Chacko
fa8f24633b GH-3160: Handle element types correctly in CassandraFilterExpressionConverter.doValue
Fixes: 3160

https://github.com/spring-projects/spring-ai/issues/3160

When using a filter expression with IN operator on a collection field in
CassandraVectorStore.similaritySearch, a ClassCastException was thrown because
the code attempted to format individual collection elements using the collection's
codec instead of the element type's codec.

This fix modifies doValue to detect when we are formatting elements inside a
collection type and use the appropriate element type codec. While Cassandra
does not support using the IN operator directly on collection columns, this fix
ensures we generate syntactically correct CQL rather than throwing a Java
exception.

The change specifically addresses ListType collections by using the element type
codec for individual elements within the list.

Signed-off-by: Soby Chacko <soby.chacko@broadcom.com>
2025-05-16 13:40:44 +01:00
Ilayaperumal Gopinathan
30add8089a Fix CassandraRichSchemaVectorStoreIT#ensureSchemaNoCreation
- Check index not existing exception

Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
2025-05-16 13:35:57 +01:00
Soby Chacko
9eeee6178c GH-3181: fix: Validate index name exists in CassandraVectorStore
Fixes: #3181

https://github.com/spring-projects/spring-ai/issues/3181

When using CassandraVectorStore with an invalid index name and
initializeSchema=false, the application would throw a generic
NoSuchElementException from Optional.get() with message "No value present"
when trying to access the index metadata.

Changes:
- Added explicit validation of index existence in checkSchemaValid() method
- Improved error handling in getIndexSimilarity() method to provide a clear
  error message when an index doesn't exist
- Added integration test to verify proper error handling with invalid index names

Signed-off-by: Soby Chacko <soby.chacko@broadcom.com>
2025-05-16 12:45:30 +01:00
Yanming Zhou
eba7bde870 Polish dependencies (#3198)
Signed-off-by: Yanming Zhou <zhouyanming@gmail.com>
2025-05-16 12:23:26 +01:00
Mark Pollack
c0b9240c8d Fix VectorStoreDocumentRetriever to handle Filter.Expression objects directly
- Updated computeRequestFilterExpression to check if the context value is already
  a Filter.Expression object before attempting to parse it as a string
- Added docs for FILTER_EXPRESSION key that it accepts both String and Filter.Expression
- Added test

Fixes #3179
2025-05-16 11:34:47 +01:00
Soby Chacko
368be3a04f Fixing miscellaneous checkstyle errors
Enabling checkstyle by default in the project build

Signed-off-by: Soby Chacko <soby.chacko@broadcom.com>
2025-05-16 11:08:33 +01:00
Ilayaperumal Gopinathan
31feb4319b Remove duplicate dependency from spring-ai-model-chat-memory-repository-jdbc POM
Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
2025-05-16 11:00:09 +01:00
Christian Tzolov
b219c21723 docs: reorganize documentation structure
- Restructure navigation with clearer hierarchy using "Reference" and "Guides" sections
- Remove deprecated model-specific function calling documentation
- Update all model references to point to centralized Tool Calling documentation
- Rename "Docker Compose" to "Development-time Services" for clarity
- Move "Testing" under Reference section
- Add link to "Awesome Spring AI" community resources

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-05-15 18:06:37 -04:00
Jonatan Ivanov
6df84845a2 Do not trigger GHA workflows on forks
GHA workflows are automatically executed on forks where they fail.
This change prevents this (only for those workflows that are
automatically triggered, e.g.: on push or schedule).
2025-05-15 17:45:59 -04:00
Mark Pollack
008a760fa7 Add dataSource() method to JdbcChatMemoryRepository.Builder and improve dialect detection
- Added a dataSource(DataSource) method to the builder
- Now, if no dialect is specified, the implementation will attempt to detect it from the effective DataSource (either set directly or obtained from the JdbcTemplate).
- Updated builder logic to default to the DataSource from the JdbcTemplate if dataSource() is not called, ensuring dialect detection works out-of-the-box.
- The builder now prefers a directly provided DataSource, but remains backwards compatible with JdbcTemplate-based configuration.
- Added tests

Fixes #3148

Signed-off-by: Mark Pollack <mark.pollack@broadcom.com>
2025-05-15 16:44:56 -04:00
Sun Yuhan
31da8f3dbb fix: Fixed the incorrect SQL in getSelectMessagesSql of MysqlChatMemoryRepositoryDialect
- Added tests

Signed-off-by: Sun Yuhan <1085481446@qq.com>
2025-05-15 16:14:53 -04:00
Sun Yuhan
0e1bb52ab7 fix: Added transaction support for saveAll in JdbcChatMemoryRepository
- Add optional PlatformTransactionManager
- Add tests

Signed-off-by: Sun Yuhan <1085481446@qq.com>
2025-05-15 14:23:00 -04:00
Ilayaperumal Gopinathan
1a395e6847 Add Chat memory (in-memory chat memory repository) starter (#3185)
- Add Spring Boot starter for Chat memory with in-memory chat memory repository

Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
2025-05-15 11:27:31 -04:00
Ilayaperumal Gopinathan
48fb663c31 Fix qdrant vector store value factory (#3173)
- Fix the QdrantValueFactory to handle "java.util.List" type
 - Update the integration test to use List type values

Resolves #3164

Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
2025-05-15 11:26:23 -04:00
Jast
add7ca8489 fix doc (#3171)
Signed-off-by: Jast <745925668@qq.com>
2025-05-15 13:37:10 +01:00
Jonatan Ivanov
3fb66928f5 Add missing observability tests
Some tests were missing from gh-3003, this change adds them

See gh-3003
2025-05-15 10:09:31 +02:00
Yanming Zhou
0bcb2e138b Fix outdated configuration key include-completion and include-query-response
Fixes GH-3151

Follow-up of commit ca843e85887aa1da6300c77550c379c103500897,`includeCompletion` is renamed to `logCompletion`.

Signed-off-by: Yanming Zhou <zhouyanming@gmail.com>
2025-05-15 09:30:45 +02:00
ChoHadam
d5d907b266 Fix: Initialize TokenTextSplitter Builder fields with default values
Signed-off-by: ChoHadam <hadamcho97@gmail.com>
2025-05-14 17:38:16 +01:00
Jhzlo
e14e788a47 fix: add @JsonProperty for response_format
Ensures the response_format field is correctly serialized for Stability AI API.

Signed-off-by: Jhzlo <kjh0010703@naver.com>
2025-05-14 12:31:23 -04:00
Ricken BAZOLO
1beff75453 add mistral ai moderation doc (#3161) 2025-05-14 16:50:34 +01:00
LingXiao Qi
55ac78046d fix: OpenAiApi comment (#3165)
Signed-off-by: lingxiao <lotus0721@outlook.com>
2025-05-14 14:21:16 +01:00
Ricken BAZOLO
4d79ff5c56 openai-moderation.doc fix typo (#3162)
Signed-off-by: Ricken Bazolo <ricken.bazolo@gmail.com>
2025-05-14 14:17:05 +01:00
Mark Pollack
1ede66492f update upgrade-notes (#3142) 2025-05-13 19:32:50 +01:00
Ilayaperumal Gopinathan
f2940cffce Next development version 2025-05-13 19:06:16 +01:00