If the input to JsonParser.toJson is a String that is already a valid JSON (e.g. a JSON array or object),
the method now returns the string as-is, instead of re-serializing it into a quoted string.
This avoids issues with deserialization errors, especially when tools expect structured types like List<T>.
test(json): add unit test to ensure toJson skips serialization of valid JSON strings
Signed-off-by: Ahmed Maruf <81756975+ohMaruf@users.noreply.github.com>
- Convert non-primitive metadata values to JSON strings in ChromaApi.AddEmbeddingsRequest for compatibility
- Add tests to verify metadata conversion and complex metadata handling in Chroma vector store integration
- Ensure OpenAiChatModel always returns annotations as a list of maps in metadata
- Add test dependency on spring-ai-advisors-vector-store for advisor-related tests
- Add json-unit-assertj for improved JSON assertions and validating JSON content in tests
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
Older STDIO transports can't be pulled, this should be a milestone version and should use `spring-ai-starter-mcp-server`.
Signed-off-by: Yang Buyi <52228969+yangbuyiya@users.noreply.github.com>
Adds a new configuration property `spring.ai.tools.throw-exception-on-error` that controls how tool execution errors are handled:
- When false (default): errors are converted to messages and sent back to the AI model
- When true: errors are thrown as exceptions for the caller to handle
The implementation:
- Adds the property to ToolCallingProperties
- Updates ToolCallingAutoConfiguration to use the property
- Improves error handling in MCP tool callbacks to use ToolExecutionException
- Adds tests to verify both behaviors
- Updates documentation with the new property
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
The RelevancyEvaluator is key for validating RAG flows. This pull request improves it by making the PromptTemplate configurable, improving the format of the default one, introducing a Builder, and extending the documentation with more details on how to use it.
I added some unit tests. The RelevancyEvaluator is used in lots of integration tests in the project to test the QuestionAnswerAdvisor and RetrievalAugmentationAdvisor, that also help assessing the evaluator itself.
Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
* Add context about reactive/imperative applications
* Fix typos and improve formatting
* Highlight Spring Boot 3.4 bug as IMPORTANT note
* Clarify tool calling impact on Micrometer observations
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>
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>
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>
- 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>
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>
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>
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>
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>
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>
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
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>
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>
Replaces redundant or conflicting stylePreset assignments with a single mergeOption call using runtime style and default stylePreset.
Signed-off-by: Jhzlo <kjh0010703@naver.com>