Commit Graph

628 Commits

Author SHA1 Message Date
Thomas Vitale
01632c5d20 Add merge for missing Ollama options
When fields in OllamaOptions are marked as ignored in Jackson, they require explicit merge of runtime and default options.
Added tests to validate the different merge combinations for all tool-related options.

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2025-02-06 10:13:40 +01:00
Thomas Vitale
ecae493704 Fix handling of nullable fields in OllamaChatModel deprecated constructor (#2174)
Fix gh-2172

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2025-02-05 23:29:01 -05:00
Ilayaperumal Gopinathan
1c6132caf4 Update to Spring Boot 3.4.2 for dependency management (#2176)
- Spring AI's dependencies management to derive from Spring Boot 3.4.2
    - Remove explicit versioning of dependencies
  - Update upgrade notes for Spring Boot 3.4.2
  - Fix ElasticSearch client changes with the latest dependency derived from Spring Boot 3.4.2
2025-02-05 23:25:18 -05:00
Mark Pollack
fc2690cdf8 Add flexible API key management for OpenAI
Introduces a new API key interface that allows users to customize how
API keys are provided and managed in their Spring AI applications. This
change improves security and flexibility by:

- Adding core ApiKey interface and SimpleApiKey implementation
- Adding builder pattern for OpenAiApi creation
- Deprecating public constructors in favor of builder API (since 1.0.0.M6)
- Added docs

The new system enables users to implement their own key management
strategies while maintaining backward compatibility with property-based
configuration.
2025-02-05 14:57:41 -05:00
Ricken Bazolo
45421b1c93 improved ability to use openAiApi to support DeepSeek
Signed-off-by: Ricken Bazolo <ricken.bazolo@gmail.com>
2025-02-05 16:13:50 +00:00
Alexandros Pappas
35101e75ae feat: Add reasoningEffort parameter to OpenAI API and Chat Options
This commit introduces the `reasoningEffort` parameter to the OpenAI API integration, allowing control over the reasoning effort used by models like `o1-mini`.

Changes:
- Adds `reasoningEffort` field to `OpenAiApi.ChatCompletionRequest`.
- Adds `reasoningEffort` field and builder method to `OpenAiChatOptions`.

Signed-off-by: Alexandros Pappas <apappascs@gmail.com>

Signed-off-by: Alexandros Pappas <apappascs@gmail.com>
2025-02-05 13:01:29 +00:00
Alexandros Pappas
74178b9f0e feat: Update OpenAI Chat Models to Latest Versions and Improve Documentation
This commit comprehensively updates the OpenAiApi `ChatModel` enum to include all the latest OpenAI chat completion models and enhances the documentation.

Signed-off-by: Alexandros Pappas <alexandros.pappas@yiluhub.com>
2025-02-05 10:40:09 +00:00
Thomas Vitale
560baaae5a Advancing Tool Support - Part 5
* Introduced new ToolParam annotation for defining a description for tool parameters and marking them as (non)required.
* Improved the JSON Schema generation for tools, solving inconsistencies between methods and functions, and ensuring a predictable outcome.
* Added support for returning tool results directly to the user instead of passing them back to the model. Introduced new ToolExecutionResult API to propagate this information.
* Consolidated naming of tool-related options in ToolCallingChatOptions.
* Fixed varargs issue in ChatClient when passing ToolCallback[].
* Introduced new documentation for the tool calling capabilities in Spring AI, and deprecated the old one.
* Bumped jsonschema dependency to 4.37.0.

Relates to gh-2049

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2025-02-04 12:59:17 +01:00
Ilayaperumal Gopinathan
c5becf7429 Fixes for Integration Tests
- Multi modality image tests to assert with containsAny instead of contains specific values
 - Expand Mistral functionCall test's usage metrics range
2025-02-03 23:42:37 +00:00
Ilayaperumal Gopinathan
2932769883 Switch back to use slf4j logging
- Revert the changes to update to use Apache Commons Logging and re-add the previously used slf4j logging
2025-02-03 15:31:43 -05:00
Ilayaperumal Gopinathan
54463e6622 Fix EmbeddingIT#defaultEmbedding test
- Use text-embedding-ada-002-v2 as OpenAI routes to text-embedding-ada-002-v2 by default
2025-02-03 14:03:42 +00:00
Ilayaperumal Gopinathan
ca27895da4 Remove deprecated Amazon Bedrock chat models
- Amzon Bedrock chat models were deprecated to support Amazon Bedrock Converse API for the chat models.
 - This PR removes all the references of the deprecated Amazon Bedrock chat models
   - Remove Amazon Bedrock chat models for anthropic, anthropic3, cohere, jurassic2, titan
      - Remove API, chat options and model
      - Remove tests and doc references
   - Update the doc to reflect the changes
   - Update upgrade notes

Resolves #2124

Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
2025-01-31 16:11:52 -05:00
Mark Pollack
cc730268e7 Fix race condition waiting for status of ollama model pull success status 2025-01-31 11:11:44 -05:00
Ilayaperumal Gopinathan
a61437df6e Fix usage metrics for the MistralAiChatModelIT tests 2025-01-31 14:40:46 +00:00
Thomas Vitale
b902ca2afb Advancing Tool Support - Part 4
* Adopted new tool calling logic in OllamaChatModel, while maintaining full API backward compatibility thanks to the LegacyToolCallingManager.
* Improved efficiency and robustness of merging options in prompts for Ollama.
* Update Ollama Autoconfiguration to use the new ToolCallingManager.
* Improved troubleshooting for new tool calling APIs and finalised changes for full backward compatibility.
* Updated Ollama Testcontainers dependency to 0.5.7.

Relates to gh-2049

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2025-01-30 17:34:24 +01:00
Ilayaperumal Gopinathan
97f7768054 Fix required POM attributes for maven staging deployment 2025-01-29 18:58:38 +00:00
Christian Tzolov
bb3fde3622 Fix logger reformating error 2025-01-29 19:57:46 +01:00
Christian Tzolov
f36b73cce2 refactor: migrate from functions to tools terminology
Refactors the test codebase to use tools instead of functions.

- Rename FunctionCallback to FunctionToolCallback
- Rename FunctionCallingOptions to ToolCallingChatOptions
- Update API methods from functions() to tools()
- Deprecate function-related methods in favor of tool alternatives
- Refactor MethodToolCallback implementation with improved builder pattern
- Update all tests to use new tool-based APIs
- Add funcs to tools migration guide

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
2025-01-29 19:50:41 +01:00
Assassinxc
62ce753b12 Add dimensions option for ZhiPuAi embedding model
- Add dimentions options
 - Add doc for ZhiPuAi embedding dimensions option

Signed-off-by: Assassinxc <330109311@qq.com>
2025-01-29 11:51:30 +00:00
Ilayaperumal Gopinathan
14ec6b2dc0 Use Usage#getCompletionTokens instead of deprecated Usage#getGenerationTokens 2025-01-29 10:58:57 +00:00
Ilayaperumal Gopinathan
78a58a15e8 Update commons logging for the latest changes 2025-01-29 10:21:20 +00:00
Ilayaperumal Gopinathan
b03a6c9ef8 Fix the default value of OpenAI chat option
- The OpenAI chat option metadata can be set only when the store value is enabled.
 - Change the default value from empty map to null
2025-01-28 20:01:12 +00:00
Ilayaperumal Gopinathan
fe323fbad1 Support store and metadata OpenAI chat options
- Add store and metadata as OpenAI Chat options
 - Add test

Resolves #2103
2025-01-28 12:39:36 -05:00
Ilayaperumal Gopinathan
8303a52611 Use Apache Commons Logging
- Remove existing spring-boot-starter-logging
 - Update to use Springframework's LogAccessor to use commons logging

Resolves #2095
2025-01-28 11:00:05 +00:00
Alexandros Pappas
bada403643 Add documentation how to use the OpenAI client to access DeepSeek
Signed-off-by: Alexandros Pappas <alexandros.pappas@yiluhub.com>
2025-01-27 16:45:00 -05:00
Ilayaperumal Gopinathan
4b64aa0ca6 Refactor Usage handling
- Remove model specific Usage implementations
- Add `Object getNativeUsage()` to Usage interface
  - This will allow the model specific Usage data to be returned
  - At the client side, client needs to cast the return type of `getNativeUsage` into the corresponding Usage returned by the model API
- Rename `generationTokens` to `completionTokens`
  - Since `completion` token name is more common among the models, renaming generation tokens into completion tokens
  - Maintain JSON deserialization compatibility for legacy `generationTokens` field
  - Remove deprecated Long-based constructors to avoid API ambiguity
- Change the prompt, completion and total token return types from Long to Integer
  - This is a breaking change that requires updating all constructor calls
  - Integer is sufficient for token counts and aligns better with most model APIs
- Use DefaultUsage for most of the model specific usage handling
  - When initializing set the native usage to the model specific usage type
  - Ensure immutability by making all fields final and removing setters
  - Add comprehensive test coverage for all functionality including edge cases

Resolves #1407
2025-01-27 16:29:07 -05:00
Christian Tzolov
39be9aeba2 Fix tools test configuration 2025-01-26 07:28:51 +01:00
Mark Pollack
7521cab9db Remove deprecated methods/classes from spring-ai-core 2025-01-24 13:37:14 -05:00
Alexandros Pappas
bb6b8cc20f Refactor OpenAIAudio builder methods
- Refactor the builder methods to remove `with` as the prefix.
- Introduce new methods with updated naming conventions.
- Deprecate the existing `with*` methods to maintain backward compatibility.

Signed-off-by: Alexandros Pappas <alexandros.pappas@yiluhub.com>
2025-01-24 11:47:04 +00:00
Ilayaperumal Gopinathan
f5761de087 Fix Moonshot Chat model toolcalling token usage
- Accumulate the token usage when toolcalling is invoked
   - Fix both call() and stream() methods
     - Add `usage` field to the Chat completion choice as the usage is returned via Choice
 - Add Mootshot chatmodel ITs for functioncalling tests

Move the tests into MoonshotChatModelFunctionCallingIT
2025-01-21 11:28:29 +00:00
Alexandros Pappas
1280c2a3ba feat(minimax): add support for MiniMax-Text-01 model
This commit adds support for the MiniMax-Text-01 model,
which is recommended for general scenarios due to its
longer context window.

The new model is added to the ChatModel enum as MiniMax_Text_01.

Signed-off-by: Alexandros Pappas <alexandros.pappas@yiluhub.com>
2025-01-20 10:24:29 +00:00
Ricken Bazolo
a0e0508cc0 Resolve Mistral AI Function Call issue and activate testing.
Signed-off-by: Ricken Bazolo <ricken.bazolo@gmail.com>
2025-01-20 10:01:56 +00:00
dafriz
9d95f0f7c9 Add o1 model to OpenAI ChatModel enum 2025-01-17 16:17:06 +00:00
jitokim
18a1bc1821 Add New Version of Minimax ChatModel
Signed-off-by: jitokim <pigberger70@gmail.com>
2025-01-17 16:08:29 +00:00
pir
7e303a06e5 Add additional OpenAI TTS Voice options
- Add OpenAI TTS Voice Unit Test
2025-01-17 13:31:39 +00:00
Andreas Köninger
510d51a5e6 Azure OpenAI: add logprobs to ChatGenerationMetadata
Signed-off-by: Andreas Köninger <andiveloper1@gmail.com>
2025-01-17 13:10:10 +00:00
Alexandros Pappas
7d53ef2056 chore: replace all instances of 'final static' with 'static final' 2025-01-15 15:16:12 +00:00
Ilayaperumal Gopinathan
3c539a37a3 Remove deprecated methods from models 2025-01-06 16:59:33 -05:00
Ilayaperumal Gopinathan
977500f7a1 Remove deprecated classes and methods in spring-ai-core
* Remove use of Document.getContext method from spring-ai-core, use getText
* Remove deprecated ChatOptionsBuilder class
* Remove deprecated FunctionCallingOptionsBuilder class
2025-01-06 16:57:55 -05:00
Ilayaperumal Gopinathan
823766f436 Fix OpenAiChatModelIT#streamingWithTokenUsage
- Modify the streaming vs call usage assertion to match the close to 25% value
   - This change is done because the OpenAI chat response for call and stream invocation results in slight change in usage.
2025-01-02 15:38:18 +00:00
Ilayaperumal Gopinathan
7fe3b389c4 Fix checkstyle errors 2025-01-02 13:43:58 +00:00
Mark Pollack
d7fe07b0f1 Next development version 2024-12-23 14:25:21 -05:00
Mark Pollack
ab022fa956 Release version 1.0.0-M5 2024-12-23 14:24:55 -05:00
Mark Pollack
3ffcfdc215 Fix VertexAiMultimodalEmbeddingModelIT test by separating documents
The Document class requires exactly one of text or media to be specified.
Updated textImageAndVideoEmbedding test to create separate Document
instances for text, image, and video content instead of combining them
in a single document.
2024-12-21 21:15:46 -05:00
Mark Pollack
92cba5d759 Fix VertexAiMultimodalEmbeddingModelIT test by separating documents
The Document class requires exactly one of text or media to be specified.
Updated textImageAndVideoEmbedding test to create separate Document
instances for text, image, and video content instead of combining them
in a single document.
2024-12-21 20:48:44 -05:00
Mark Pollack
ecfdfabb41 Add deprecated with* methods to OllamaOptions Builder
Add backwards compatibility methods to the Builder class in OllamaOptions
to maintain compatibility with code using the old withX style methods.
Each deprecated method delegates to its new counterpart and includes
proper Javadoc directing users to the new method name.

All deprecated methods are marked for removal in 1.0.0-M5, giving users
time to migrate to the new style while maintaining functionality.
2024-12-21 19:45:36 -05:00
Mark Pollack
0765b2ca88 Simplify builder pattern for options
This change streamlines the builder implementation by removing generics
that was complicating the implementation and providing hard to
debug checkstyle warnings.

It adopts a simpler, more direct builder pattern. Key changes:

- Remove generic type parameters from builder interfaces
- Switch to concrete builder implementations with direct field access
- Make all collection getters return unmodifiable views
- Ensure proper copy semantics in builders and options
- Add comprehensive test coverage for builder behavior
2024-12-21 13:35:15 -05:00
jitokim
6477c0ccfc Fix missing inferenceConfig in ConverseStreamRequest builder
Signed-off-by: jitokim <pigberger70@gmail.com>
2024-12-21 09:15:27 +01:00
Ilayaperumal Gopinathan
1e68862142 Fix SimpleVectorStore' deprecated constructor use
- Use SimpleVectorStoreBuilder for SimpleVectorStore instance creation
2024-12-20 20:29:40 +00:00
Bruno Oliveira
2aaa57fc7a Ensure matching enum id to value for multilingual cohere embedding model 2024-12-20 12:59:36 -05:00