Commit Graph

2148 Commits

Author SHA1 Message Date
Andres da Silva Santos
fb402a6718 Support reasoning_effort in AzureOpenAiChatOptions
* Adds reasoningEffort field to AzureOpenAiChatOptions builder, copy, equals, hashCode
* Propagates value to ChatCompletionsOptions

Fixes #2703

Signed-off-by: Andres da Silva Santos <40636137+andresssantos@users.noreply.github.com>
2025-05-08 17:45:58 +01:00
BeomSeogKim
69c081c778 fix(jsonparser): support scientific notation parsing for int/long
Fixes: #2995

Replaces direct parseInt/parseLong with BigDecimal-based parsing to handle
scientific notation safely and accurately.

Signed-off-by: BeomSeogKim <kbs4520@daum.net>
2025-05-08 17:02:59 +01:00
Soby Chacko
f3b4624494 GH-3029: Remove HanaDB vector store autoconfiguration
Fixes: #3029

- Remove HanaDB vector store autoconfiguration
- Remove the corresponding starter
- Update docs
- Update maven configuration
- Remove autoconfiguration and starter entries from Spring AI BOM

Signed-off-by: Soby Chacko <soby.chacko@broadcom.com>
2025-05-08 16:55:48 +01:00
Mark Pollack
ebfa5b9b2c refactor: remove inter package dependency cycles in spring-ai-model
Remove circular dependencies:

Move utility classes from various packages to dedicated support packages:
- Move ToolCallbacks from ai.tool to ai.support
- Move UsageUtils to UsageCalculator in ai.support
- Move tool.util to tool.support
- Create new ToolDefinitions utility class

Support packages for the classes in question is more idomatic in spring than util packages.

Signed-off-by: Mark Pollack <mark.pollack@broadcom.com>
2025-05-08 12:20:27 +01:00
Ilayaperumal Gopinathan
548abed3c1 Update Chroma doc to use 1.0.0 version
Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
2025-05-08 10:36:37 +01:00
Christian Tzolov
e010899fbe fix(tool): handle non-existing tool callbacks gracefully
- Add error handling to SpringBeanToolCallbackResolver to return null
  instead of throwing exceptions when resolving non-existing tools.
  This make is consitent with other tool resolver implementations
  and centralize the error handling in the tool calling manager.
- Add test to verify that the ToolCallbackResolver correctly
  returns null for non-existing tools.

Related to #2667

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-05-08 10:24:47 +01:00
Mikhail Mazurkevich
e6fbc28a5b [anthropic] fix issue #1370 with tool call duplication
Without this fix during the stream event handling when `EventType.MESSAGE_STOP` occurs, the latest content block was resent again and it caused to the additional tool call(if it was the latest event)

[anthropic] Replace `switchMap` -> `flatMap` to avoid cancellation of the original request

Previously, internalStream used switchMap to process ChatCompletionResponses,
which caused the active stream (including potential recursive calls) to be
canceled whenever a new response arrived. This led to incomplete processing
of streaming tool calls and unexpected behavior when handling tool_use events.

Replaced switchMap with flatMap to ensure that each response is fully processed
without being interrupted, allowing recursive internalStream calls to complete
as expected.

Without this fix during the stream event handling when `EventType.MESSAGE_STOP` occurs, the latest content block was resent again and it caused to the additional tool call(if it was the latest event)

Signed-off-by: Mikhail Mazurkevich <Mikhail.Mazurkevich@jetbrains.com>
2025-05-08 10:12:07 +01:00
Jakub
b5c3216b76 Update mcp-server-boot-starter-docs.adoc
Signed-off-by: Jakub <jakub@jpomykala.com>
2025-05-07 23:43:15 -04:00
GR
c54dfd35d5 feat: add deepseek starter and docs - fix pom module ordering
- Add remaining deepseek modules
- Fix build order to put autoconfig modules after model modules to fix javadoc build

Signed-off-by: GR <gr@fastball.dev>
2025-05-07 23:38:07 -04:00
Thomas Vitale
d619e25cb5 Self-contained prompt templates in advisors
The built-in advisors that perform prompt augmentation have been updated to use self-contained templates. The goal is for each advisor to be able to perform templating operations without affecting nor being affected by templating and prompt decisions in other advisors.

* QuestionAnswerAdvisor
* PromptChatMemoryAdvisor
* VectorStoreChatMemoryAdvisor

Documentation and upgrade notes have been updated accordingly

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2025-05-07 22:55:15 -04:00
Thomas Vitale
2ea518686f Support DocumentPostProcessors in RAG Advisor
The DocumentPostProcessor is one of the modular RAG components introduce in M8. You can now use this API from within the RetrievalAugmentationAdvisor to post-process the retrieved documents before passing them to the model. For example, you can use such an interface to perform re-ranking of the retrieved documents based on their relevance to the query, remove irrelevant or redundant documents, or compress the content of each document to reduce noise and redundancy.

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2025-05-07 21:34:37 -04:00
Mark Pollack
a5920a17fa Add core deepseek classes
Signed-off-by: Mark Pollack <mark.pollack@broadcom.com>
2025-05-07 21:27:39 -04:00
Soby Chacko
d781199b48 GH-1378: Add parameter warnings and implement penalty options for Vertex AI Gemini
Fixes: #1378

- Add warnings for unsupported frequency/presence penalty in Anthropic API
- Add warnings for unsupported frequency/presence penalty and topK in BedrockProxyChatModel
- Add warning for unsupported topK in OpenAI chat models
- Implement frequency and presence penalty parameters for Vertex AI Gemini model
- Update Vertex AI Gemini options and tests

Signed-off-by: Soby Chacko <soby.chacko@broadcom.com>
2025-05-07 17:44:31 -04:00
Mark Pollack
0e15197298 Refactor StTemplateRenderer: rename supportStFunctions to validateStFunctions and improve variable extraction
- Renamed all occurrences of supportStFunctions to validateStFunctions for clarity.
- Updated default field, constructor, and builder method to use new naming.
- Improved getInputVariables logic to better distinguish variables, function calls, and property access.
- Ensured built-in functions accessed as properties are only skipped when validateStFunctions is true.
- Enhanced builder usage to reflect new flag and naming.
- More tests added

Signed-off-by: Mark Pollack <mark.pollack@broadcom.com>
2025-05-07 17:01:44 -04:00
Dariusz Jędrzejczyk
97f90b19d6 Fix mutating global RestClient and WebClient builders (#3020)
Since the builders for HTTP clients are mutable and shared, they should
only be configured with globally applicable settings. The current use
leaks specific details into other usages and affects newly instantiated
clients. This PR applies the clone() method right before mutation
happens as it probably is the strategy that avoids multiple unnecessary
copies.

feat: improve RestClient and WebClient instantiation and configuration across AI modules

- Ensure RestClient.Builder and WebClient.Builder are properly cloned before setting base URLs and headers in Mistral, OpenAI, and Ollama API classes to prevent side effects.
- Add WebClientAutoConfiguration to auto-configuration classes for Anthropic and Mistral AI modules.
- Update Mistral AI auto-configuration to inject and use WebClient.Builder.
- Clean up test and annotation usage (remove unnecessary @Nullable, fix test builder usage in AnthropicApiIT).
- Improve consistency and reliability of HTTP client configuration across model integrations.

Signed-off-by: Dariusz Jędrzejczyk <dariusz.jedrzejczyk@broadcom.com>
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
Co-authored-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-05-07 18:15:55 +02:00
jonghoonpark
09a6a6e1e5 Upgrade chroma vector database api version to V2
- Update to use Chroma 1.0.0
 - Update Chroma vector store implementation to use V2 API

Signed-off-by: jonghoonpark <dev@jonghoonpark.com>
2025-05-07 14:11:23 +01:00
Ilayaperumal Gopinathan
61d160442b Fix OpenSearchVectorStoreAutoConfigurationIT
- Set spring.ai.vectorstore.opensearch.aws.enabled=false to enable non AWS condition to instantiate OpenSearch client

Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
2025-05-07 14:00:30 +01:00
Ilayaperumal Gopinathan
4910cab938 Comment out failing ModelOptionsUtilsTests#pojo_emptyStringAsNullObject object mapper configuration
- Need to investigate later via https://github.com/spring-projects/spring-ai/issues/3021

Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
2025-05-07 12:36:19 +01:00
Mark Pollack
10ff11da14 Add regression test for MessageChatMemoryAdvisor with Prompt message list (GH-2339)
- Adds an integration test to verify that MessageChatMemoryAdvisor works correctly when a Prompt is initialized with a List<Message>.
- References and confirms the fix for [https://github.com/spring-projects/spring-ai/issues/2339.](https://github.com/spring-projects/spring-ai/issues/2339.)

Signed-off-by: Mark Pollack <mark.pollack@broadcom.com>
2025-05-06 18:58:06 -04:00
Mark Pollack
b167f21e25 ModelOptionsUtils: Add ACCEPT_EMPTY_STRING_AS_NULL_OBJECT and ObjectMapper overloads
- Configure OBJECT_MAPPER to accept empty strings as null objects during deserialization.
- Add overloaded jsonToMap(String, ObjectMapper) for custom ObjectMapper usage.
- Add and update tests to verify correct handling of empty strings for both Map and POJO deserialization, including custom ObjectMapper scenarios.
- Clarify documentation and ensure extensibility without global side effects.

Fixes #2222

Signed-off-by: Mark Pollack <mark.pollack@broadcom.com>
2025-05-06 18:37:07 -04:00
Mark Pollack
f329d71b7b Improve OpenSearch AWS/non-AWS auto-configuration and document fallback logic
- Add OpenSearchNonAwsCondition to robustly activate non-AWS OpenSearch auto-configuration if either:
    - AWS SDK classes are missing, OR
    - spring.ai.vectorstore.opensearch.aws.enabled=false
- Update OpenSearchVectorStoreAutoConfiguration to use the new condition for non-AWS configuration.
- Ensure AWS-specific auto-configuration is only active when AWS SDKs are present and the property is true (default).
- Add Javadoc to OpenSearchNonAwsCondition and clarify Javadoc on AWS config.
- Update integration test (OpenSearchVectorStoreNonAwsFallbackIT) to verify fallback logic works with AWS SDKs present.
- Add and refine documentation in opensearch.adoc:
    - Explain the purpose and usage of the spring.ai.vectorstore.opensearch.aws.enabled property.
    - Document the fallback logic and how to explicitly select AWS or non-AWS OpenSearch support.

Fixes #1901

Signed-off-by: Mark Pollack <mark.pollack@broadcom.com>
2025-05-06 18:18:47 -04:00
enricorampazzo
43aa8939d2 Enhance Neo4jChatMemoryRepository, expand integration tests, improve configuration, and update documentation
- Enhanced Neo4jChatMemoryRepository to correctly restore custom metadata for SystemMessage using SystemMessage.Builder.
- Refactored and clarified Neo4jChatMemoryRepository implementation code.
- Added comprehensive integration tests for Neo4jChatMemoryConfig and Neo4jChatMemoryRepository, including:
-- Index creation verification
-- Custom label support
-- Getter validation for all configuration properties
-- Tests for saving and retrieving SystemMessage metadata
-- Tests ensuring saveAll(conversationId, Collections.emptyList()) clears all messages and removes the conversation node
-- Tests for handling of messages with empty content and empty metadata
-- Improved overall test coverage for Neo4j persistence and configuration edge cases
- Fixed resource management bugs in test classes (ensured proper driver/session closure).
- Improved index creation logic in Neo4jChatMemoryConfig for reliability and logging.
- Updated documentation to include Neo4jChatMemoryRepository usage and configuration

Signed-off-by: enricorampazzo <enrico.rampazzo@live.com>
Signed-off-by: Mark Pollack <mark.pollack@broadcom.com>
2025-05-06 15:31:11 -04:00
enricorampazzo
4ec067641b updates from spring-ai
Signed-off-by: enricorampazzo <enrico.rampazzo@live.com>
2025-05-06 15:31:11 -04:00
Ilayaperumal Gopinathan
b6ce7f3e4a Remove deprecations/cleanup
- Remove deprecated AbstractChatMemoryAdvisor#DEFAULT_CHAT_MEMORY_CONVERSATION_ID
 - Remove deprecated InMemoryChatMemory and replace it with MessageWindowChatMemory
   - Update references

 - Remove deprecated TemplateFormat

Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
2025-05-06 11:30:38 +01:00
Thomas Vitale
4fe74d886e Remove deprecations in ChatClient and Advisors
* Update remaining Advisors and related classes to use the new APIs.
* In AbstractChatMemoryAdvisor, the “doNextWithProtectFromBlockingBefore()” protected method has been changed from accepting AdvisedRequest to ChatClientRequest. It’s a breaking change since the alternative was not part of M8.
* MessageAggregator has a new method to aggregate messages from ChatClientRequest. The previous method aggregating messages from AdvisedRequest has been removed. Warning since it wasn’t marked as deprecated in M8.
* In SimpleLoggerAdvisor, the “requestToString” input argument needs to be updated to use ChatClientRequest. It’s a breaking change since the alternative was not part of M8. Same thing about the constructor.
* The “getTemplateRenderer” method has been removed from BaseAdvisorChain. Each Advisor is encouraged to accept a PromptTemplate to achieve self-contained prompt augmentation operations.
* Remove deprecations in ChatClient and Advisors, and update tests accordingly.
* When building a Prompt from the ChatClient input, the SystemMessage passed via systemText() is placed first in the message list. Before, it was put last, resulting in errors with several model providers.

Relates to gh-2655

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2025-05-06 09:58:06 +01:00
Christian Tzolov
88490b3dfc Fix broken docs snippet formatting
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-05-06 10:25:18 +02:00
Solomon Hsu
271d78142f Add 'capabilities' field to ShowModelResponse in OllamaApi
This update enables deserialization of the 'capabilities' field from the JSON response.

Signed-off-by: Solomon Hsu <solnone@gmail.com>
2025-05-06 01:19:06 -04:00
nlinhvu
39759b02ba Update vertexai-gemini-chat.adoc, VertexAi ChatModels docs and fix typo for spring-ai-vertex-ai-gemini
Signed-off-by: nlinhvu <nlinhvu.dev@gmail.com>
2025-05-06 01:17:32 -04:00
jonghoonpark
9ca3a7d15f Refactor OpenAiImageOptions and enhance test coverage
This commit makes several improvements to the OpenAiImageOptions class:

1. Remove all deprecated methods from OpenAiImageOptions.Builder:
   - Removed withN(), withModel(), withQuality(), withResponseFormat(),
     withWidth(), withHeight(), withStyle(), and withUser() methods
   - These were marked as @Deprecated(forRemoval = true, since = "1.0.0-M8")

2. Align OpenAiImageOptions structure with OpenAiChatOptions:
   - Added fromOptions() static method for creating copies
   - Added copy() instance method
   - Updated Builder class to match pattern in OpenAiChatOptions
   - Changed Builder field from private final to protected
   - Added Builder constructor that takes an existing options object

3. Enhance setSize() method to maintain consistency:
   - Updated setSize() to parse the size string and update width/height properties
   - Added proper error handling for invalid formats
   - Ensures consistent state between size, width, and height properties

4. Comprehensive test coverage improvements:
   - Added tests for builder pattern with all fields
   - Added tests for copy functionality
   - Added tests for all setter methods
   - Added tests for default values
   - Added tests for equals(), hashCode(), and toString() methods
   - Added specific tests for the updated setSize() behavior
   - Fixed test expectations to match actual implementation behavior

These changes improve code consistency, maintainability, and test coverage
while removing deprecated methods that were scheduled for removal.

Signed-off-by: jonghoonpark <dev@jonghoonpark.com>
2025-05-06 01:03:06 -04:00
Mark Pollack
a2975a6cec Switch to mcp sdk 0.10.0-SNAPSHOT
Signed-off-by: Mark Pollack <mark.pollack@broadcom.com>
2025-05-06 06:54:59 +02:00
The-Gamer-01
f93e2ae89f feat: fix readme
Signed-off-by: The-Gamer-01 <843497509@qq.com>
2025-05-06 00:42:57 -04:00
Łukasz Jernaś
81485e1603 Fix: Remove nonexisting parameter from javadoc
Signed-off-by: Łukasz Jernaś <lukasz.jernas@allegro.com>
2025-05-06 00:42:21 -04:00
Jemin Huh
b91777d15d Fix incorrect ChatMemory initialization example in chat-memory.adoc
Signed-off-by: Jemin Huh <hjm1980@gmail.com>
2025-05-06 00:41:48 -04:00
Thomas Vitale
356a68f15e Remove deprecations in JdbcChatMemory
* Remove deprecated APIs for JdbcChatMemory.
* Improve documentation about chat memory vs. chat history.
* Fix mismatch between docs vs code for max messages in MessageWindowChatMemory.

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2025-05-06 00:40:08 -04:00
ndoe
8acf4b99ff GH-2737 Returning logprobs in generation metadata when requested
Signed-off-by: ndoe <ndoe@interactions.com>
2025-05-05 23:34:00 -04:00
Mark Pollack
fef01edadf update .gitignore 2025-05-05 23:13:20 -04:00
ykoh42
0569df745e docs: fix azure-openai-chat gradle dependencies
Signed-off-by: ykoh42 <kohyounghwan@gmail.com>
2025-05-05 21:44:49 -04:00
Bart Veenstra
3a3439edc4 feat: enhance AzureOpenAiResponseFormat to support JSON schema and builder pattern
Signed-off-by: Bart Veenstra <bart.veenstra@gmail.com>
2025-05-05 21:37:35 -04:00
Mark Pollack
52675d854c remove left over TemplateRender interface after moving it 2025-05-05 21:24:00 -04:00
Mark Pollack
84ebaababf remove unused method 2025-05-05 21:08:41 -04:00
Mark Heckler
3dc86d33ce Added Entra ID identity management for Azure OpenAI, clean autoconfiguration, and updated docs to reflect changes.
Signed-off-by: Mark Heckler <mark.heckler@gmail.com>
2025-05-05 21:03:43 -04:00
Ilayaperumal Gopinathan
228ef10bfb Remove deprecated methods from Media
- Remove deprecated constructor method Media(MimeType mimeType, URL url) from Media
 - Remove deprecated builder method data(URL url) from Media builder
 - Update references to use the builder and the data(URI) methods

Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
2025-05-05 01:47:45 +01:00
Ilayaperumal Gopinathan
06edee4069 Remove deprecated UserMessage constructors
- Remove deprecated constructor methods
 - Replace them with the builder methods

Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
2025-05-05 01:06:21 +01:00
Ilayaperumal Gopinathan
722c77e812 Remove deprecated PromptTemplate constructors
- Remove the deprecated constructors from PromptTemplate and replace the references using the builder methods

Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
2025-05-05 00:57:39 +01:00
Ilayaperumal Gopinathan
46be8987d6 Remove deprecations from OllamApi and AnthropicApi
- Remove deprecated constructors from OllamaApi and AnthropicApi
 - Modify AnthropicApi's public constructor to be private so that only the builder method can use it to construct
 - Update OllamApiAutoConfiguration and AnthropicChatAutoconfiguration to use the builder methods to construct the respective
 Apis
 - Fix other constructor usages to builder methods

Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
2025-05-05 00:21:34 +01:00
Ilayaperumal Gopinathan
76bee8ceb2 Remove deprecations from 1.0.0-M8
Remove deprecated DocumentCompressor/Ranker/Selector

 - These are replaced by the org.springframework.ai.rag.postretrieval.document.DocumentPostProcessor

Remove deprecated Chatclient/DefaultChatClient methods

In ChatClient:
 - Remove defaultTools and tools as these are replaced by defaultToolCallbacks and defaultToolNames respectively.

In DefaultChatClient:
 - Remove tools method implementation
 - Remove unused DefaultCallPromptResponseSpec and DefaultStreamPromptResponseSpec

Remove deprecated addMessage from Prompt

Remove deprecated isInternalToolExecutionEnabled() from ToolCallingChatOptions

 - This is replaced by getInternalToolExecutionEnabled()

Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
2025-05-04 23:54:30 +01:00
Mark Pollack
9e71b163e3 Remove Waston text generation model 2025-05-03 18:36:02 -04:00
Mark Pollack
6ffbb3acc6 Add simple hello world test to reproduce issue #2957 with qwen/ollama 2025-05-03 18:22:05 -04:00
Mark Pollack
bfcaad7b54 Second pass to remove qianfan code 2025-05-03 17:15:18 -04:00
g00glen00b
d5423f26f1 added @JsonIgnore to ResponseFormat.schema to avoid exposing internal properties (#2969)
Signed-off-by: g00glen00b <4865705+g00glen00b@users.noreply.github.com>
2025-05-03 15:56:01 -04:00