Commit Graph

591 Commits

Author SHA1 Message Date
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
Bruno Oliveira
1453198c5b Update Anthropic3ChatOptions.java 2024-12-20 12:43:32 -05:00
Christian Tzolov
e941bc572d feat(bedrock): deprecate model-specific chat implementations in favor of Converse API
Following Amazon Bedrock's recommendations, deprecate individual model chat implementations (Anthropic, Cohere, Llama, Titan, etc.)
in favor of the unified BedrockProxyChatModel. This change promotes the use of Bedrock's Converse API which offers
benefits like model flexibility, extended functionality, and native tool support.

The Converse API does not support embedding operations, so these will remain in the current API and the embedding
model functionality in the existing InvokeModel API will be maintained
2024-12-20 12:25:33 -05:00
Christian Tzolov
c5bf644039 fix(mistral) Fix the PaymentStatusFunctionCallingIT configuraiton
Resolves #1853
2024-12-20 15:09:15 +01:00
Thomas Vitale
f2820cd8af Mistral: Support Vision Modality
Introduce multimodality support for Mistral AI, which currently supports text and vision modalities.
Added integration tests and documentation for the new capability.

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2024-12-20 14:41:01 +01:00
Mark Pollack
2e5ee4316f Ignore embedding field for Document deserialization
- VectorStore implementations may still be returning the embedding values and mapping onto
  Document.class with Jackson

This change ignores that field, but vector store implementations should change to not return
the embedding data that is no longer stored in Document
2024-12-19 15:40:09 -05:00
Dennys Fredericci
95eb9fd6a3 Fix OpenAI image dimension handling
The OpenAiImageOptions class previously had inconsistent behavior when
setting width and height properties. This change ensures that the size
property is only computed when both dimensions are available, preventing
invalid states in the API requests.

Key changes:
- Update setWidth/setHeight to only set size when both are non-null
- Add test cases to verify null size when dimensions are incomplete
- Improve code organization with proper import conventions

This change aligns with OpenAI's API requirements for image generation
where both dimensions must be specified for valid requests.
2024-12-19 15:03:58 -05:00
Ilayaperumal Gopinathan
adefca13f8 Fix EmbeddingOptions
- Remove the explicit EMPTY check when merging the default embedding options
 - Use the builder to build the default embedding options
2024-12-19 10:28:58 -05:00
Ilayaperumal Gopinathan
1c72f14a69 Refactor ModerationResult builder methods
- Deprecate the existing builder methods to remove the prefix `with`
 - Update references
2024-12-19 09:13:39 -05:00
Ilayaperumal Gopinathan
5f300c237e Fix javadoc error/warnings 2024-12-19 07:55:44 +00:00
Ilayaperumal Gopinathan
7e4a187f0d Refactor Ollama builder API
The Ollama options builder API has been refactored to follow standard Java
builder pattern conventions. This change deprecates all builder methods
prefixed with 'with' in favor of more concise method names, improving API
consistency and usability.

The deprecated methods are marked for removal in version 1.0.0-M5, giving
users time to migrate to the new builder pattern. This change aligns with
our goal of providing a more intuitive and maintainable API surface.

Breaking Changes:

* builder() method now returns Builder instead of OllamaOptions
* Clients using the old fluent API will need to migrate to the new builder pattern
Refactor Ollama options builder methods
2024-12-18 22:39:42 -05:00
Ilayaperumal Gopinathan
99a44fbab8 Fix builder methods not to use deprecated methods 2024-12-18 12:14:43 +00:00
Thomas Vitale
6ab7e20616 Support Ollama JSON Structured Output
Ollama has recently introduced native support for JSON structured output, as described in https://ollama.com/blog/structured-outputs.
This PR introduces support for it, both for directly passing a JSON schema and when using the Spring AI output conversion APIs.

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2024-12-18 11:43:57 +01:00
Alexandros Pappas
eccf33a6ec Refactor WatsonxAiChatOptions 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.
- Update WatsonxAi documentation
2024-12-17 22:00:36 +00:00
Alexandros Pappas
1d38fd11fd Refactor AnthropicChatOptions 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.
- Update AnthropicChatOptions builder documentation
2024-12-17 21:51:10 +00:00
Alexandros Pappas
de29df7c58 Refactor MistralAiChatOptions 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.
- Update MistralAiChatOptions builder documentation
2024-12-17 21:48:10 +00:00
Alexandros Pappas
19e61bf71a Refactor ChatResponseMetadata Builder methods
- Refactor builder methods in `ChatResponseMetadata` to remove `with` prefixes and introduce new methods with updated naming conventions.
- Deprecate existing `with*` methods while maintaining backward compatibility.
- Ensure dependent files and tests are compatible with the updated `ChatResponseMetadata` class.
2024-12-17 21:28:19 +00:00
Alexandros Pappas
8c51f7a84c Refactor MoonshotChatOptions 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.
- Update the `copy()` method to use the new builder methods.
- Update MoonshotChatOptions builder documentation
2024-12-17 21:10:24 +00:00
Ilayaperumal Gopinathan
b25d6e8d2d Refactor FunctionCallingOptions Builder
- Deprecate existing FunctionCallingOptionsBuilder
  - Create FunctionCallingOptions.Builder which extends ChatOptions.Builder
  - Create DefaultFunctionCallingOptions which extends DefaultChatOptions and implements FunctionCallingOptions to serve the default FunctionCalling options
  - Create DefaultFunctionCallingOptionsBuilder to build the default functioncalling options
  - Update the usage of functioncalling options builder to use the newly added builder including the tests

Improve extensibility of DefaultChatOptionsBuilder

 - Enable DefaultChatOptionsBuilder to accommodate any other sub types
   - Introduce generics to support sub types that extend DefaultChatOptionsBuilder
   - Update builder methods to return the sub type

 - Make FunctionCallingOptions' builder()'s return type to accommodate sub types which can extend FunctionCallingOptions.Builder
2024-12-17 11:58:50 -05:00
Ilayaperumal Gopinathan
627fb79e5e Refactor ImageOptions builder method
- Deprecate the builder method with the prefix 'with' and add new methods
2024-12-17 11:55:38 -05:00
Ilayaperumal Gopinathan
18bc0cff25 Refactor QianFan model option builder methods
- Deprecate the builder methods with the prefix `with` and add the new methods
 - Update docs and references
2024-12-17 11:51:59 -05:00
Ilayaperumal Gopinathan
071b897951 Refactor Zhipu AI options builder methods
- Deprecate builder methods with the prefix `with`
 - Update docs and references
2024-12-17 11:46:27 -05:00
Ilayaperumal Gopinathan
3e82e3117f Refactor Vertex AI embedding/Gemini options builder methods
- Deprecate the builder methods with the prefix `with`
 - Update references and docs
2024-12-17 11:41:36 -05:00
Ilayaperumal Gopinathan
9748820727 Refactor Stability AI Image options builder methods
- Deprecate builder methods with the prefix `with`
 - Update docs and references
2024-12-17 11:25:01 -05:00
Ilayaperumal Gopinathan
18eb4c3c61 Refactor PostgresML embedding options builder
- Deprecate the builder methods with the prefix `with`
 - Update the docs and references
2024-12-17 11:20:47 -05:00
Ilayaperumal Gopinathan
95c32f05a3 Refactor OCI Gen AI builder methods
- Deprecate the builder methods with the prefix `with`
   - Fix OCI cohere chat model options and OCI Embedding model options
 - Update references and docs
2024-12-17 11:17:24 -05:00
Ilayaperumal Gopinathan
429bd2af35 Refactor Advisor builder methods
- Deprecate the builder methods with the prefix `with`
 - Update references and docs
2024-12-17 11:13:24 -05:00
Ilayaperumal Gopinathan
da45244d99 Refactor Azure model options builder methods
- Deprecate builder methods with the prefix `with` and add them without the prefix
 - Update references and docs
2024-12-17 09:26:24 -05:00
Ilayaperumal Gopinathan
93a7ba4c84 Refactor Minimax model builder methods
- Refactor minimax chat and embedded options builder methods to remove the prefix `with`
 - Update references and docs
2024-12-17 09:18:18 -05:00
Ilayaperumal Gopinathan
65e7a1ddd9 Refactor Spring AI Bedrock options
- Refactor the options builder methods to remove `with` as the suffix
   - Update all the models under spring-ai-bedrock

 - Deprecate the existing methods
 - Update references and docs
2024-12-17 09:11:16 -05:00
Ilayaperumal Gopinathan
58efee6d90 Refactor OpenAI chat options
- Deprecate existing OpenAI chat options
 - Add the options' methods by removing the prefix "with"
   - Update the following options
    - OpenAI chat options
    - OpenAI image options
    - OpenAI moderation options
    - OpenAI embedding options
    - OpenAI audiospeech options
    - OpenAI audio transcription options
 - Update referecens and docs
 - Deprecate 'with' methods in builders
2024-12-17 09:06:06 -05:00
Tyler Russell
c14618fe9a feat(gemini) Support Safety Settings for VertexAiGeminiChatModel
feat(gemini) not null checks on safetySettings

feat(gemini) check safety settings not empty instead of not null

feat(gemini) Add VertexAiGeminiSafetySetting wrapper class

feat(gemini) Update documentation with new property

feat(gemini) Update equals, hashCode, and toString
2024-12-17 13:05:32 +01:00
Ilayaperumal Gopinathan
7bbd3ef593 Fix Azure OpenAI chat model function calling token usage
- Fix Azure OpenAI chat model's functioncalling to report accumulated token usage
   - Fix both call() and stream() operations
     - For streaming operation, use buffering to store the usage from the last response when stream option include usage is enabled
   - Add tests
2024-12-17 13:00:11 +01:00
Ilayaperumal Gopinathan
cadea8b730 Fix Anthropic chat model functioncalling token usage
- Accumulate the token usage when functioncalling is used
   - Fix both call() as well as stream() operations

 - Add/update tests
2024-12-17 12:56:53 +01:00
Ilayaperumal Gopinathan
81dfd3b6b5 Fix Mistral AI Chat model function call usage calculation
- Fix the chat model's call() to calculate the cumulative usage
   - Use an explicit internalCall to pass the previous chat response so that accumulation can be done

 - Fix the chat model's stream() to calculate the cumulative usage
   - Fix MistralAi API to include usgae in ChatCompletionChunk
   - Use internalStream() to accumulate the usage

Add/update tests
2024-12-17 12:27:51 +01:00
chenwei
187360d132 Fix OpenAI API Tool Choice type
Resolves: https://github.com/spring-projects/spring-ai/issues/1899
2024-12-17 12:11:51 +01:00
Ilayaperumal Gopinathan
f252b2417a Refactor ChatOptions Builder
- Deprecate existing ChatOptionsBuilder and its inner class DefaultChatOptions
- Create a new builder interface ChatOptions.Builder for building the Chat options
- Create an explicit DefaultChatOptions
- Create DefaultChatOptionBuilder which can create DefaultChatOptions
- Add javadoc for the deprecated Builder

Resolves #1875
2024-12-12 10:06:16 -05:00
Gareth Evans
e7bd8d5da1 feat: allow stream usage to be set for azure openai requests 2024-12-11 21:32:45 +00:00