Commit Graph

579 Commits

Author SHA1 Message Date
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
Ilayaperumal Gopinathan
f7e8e7f388 Use RequiresAwsCredentials in AWS credentials based tests
- Update Spring AI Bedrock tests to use the @RequiresAwsCredentials to check the AWS keys
2024-12-11 18:21:14 +00:00
Christian Tzolov
ad87c122d9 Fix duplicaiton 2024-12-10 15:39:59 +01:00
Ilayaperumal Gopinathan
37cf20dfe4 Fix OpenAI ChatResponse usage calculation when toolcalling is used
- Fix OpenAI ChatModel's call() operation

   - When toolcalling is used, calculate cumulative usage from the preceding ChatResponses

 - Fix OpenAI ChatModel's stream() operation

   - Make sure that cumulative usage is calculated from the ChatResponse which has a valid usage
     - Use overlapping buffer to check and store the usage from the response that holds the usage.

 - Add tests for both call() and stream()
2024-12-10 15:38:18 +01:00
Christian Tzolov
ebc91680f8 Improve OllamaWithOpenAiChatModelIT stability 2024-12-10 15:14:35 +01:00
Christian Tzolov
16a9d891aa tests Improve stability for PerplexityWithOpenAiChatModelIT 2024-12-10 14:29:50 +01:00
Mark Pollack
dfbc394f83 Make Document support single text or media content
The Document class previously allowed multiple media entries while also having a
text field, leading to ambiguity in content handling. This change enforces a
clear separation between text and media documents to prevent content type
confusion and simplify document processing.

A Document now must contain either text content or a single media entry, but
never both. This aligns with the class's primary use in ETL pipelines where
clear content type boundaries are essential for proper embedding generation and
vector database storage.

Additional architectural changes:
- Document now implements a cleaner API by removing deprecated methods
- Removed MediaContent interface implementation from Document class
- Document.getMedia() now returns a single Media object instead of Collection
- Removed EMPTY_TEXT constant in favor of proper null handling
- Constructor signatures simplified and streamlined
- Builder pattern improved to enforce single content type constraint

The breaking changes include:
- Media is now a single entry instead of a collection
- Content field renamed to text for clarity
- Removed support for mixed content types
- Simplified builder API to prevent ambiguous construction

Prefer using text-related methods over deprecated content methods to
better reflect the actual content type being handled and improve API clarity.
2024-12-09 23:25:38 -05:00
Christian Tzolov
9a5d61cc05 Bedrock Converse: Add multimodal support for documents, images and videos
- Add BedrockMediaFormat class to handle media format conversions for documents, images and videos
- Enhance Media class with builder pattern and comprehensive format constants
- Refactor BedrockProxyChatModel to support multimodal content handling
- Add integration tests for PDF, image and video processing
- Add unit tests for Media and BedrockMediaFormat classes
- Upgrade AWS SDK version from 2.26.7 to 2.29.29
- Remove redundant aws.sdk.version property in favor of awssdk.version

Documentation updates for Bedrock Converse API

- Added multimodal support documentation (images, video, documents)
- Added deprecation notices for existing Bedrock model implementations
- Updated feature comparison table
- Added warning notes about transitioning to Converse API
2024-12-09 22:54:53 -05:00
Mark Pollack
778752a14d Disable brittle IT that pulls models from hugging face for Ollama 2024-12-09 10:09:30 -05:00
Mark Pollack
87d5112fe0 Disable brittle IT that pulls models from hugging face for Ollama 2024-12-09 09:37:43 -05:00
Eddú Meléndez
d084916ac3 Polish PostgresMlEmbeddingModelIT 2024-12-09 09:25:19 +00:00
Christian Tzolov
9f775ab2c2 feat(ollama): upgrade to 0.5.1 and improve code quality
- Upgrade Ollama version used for IT from 0.3.14 to 0.5.1
- Fix string comparison pattern in OllamaModelManager
- Re-enable stream function calling test
- Improve multimodal test assertions
2024-12-09 10:08:07 +01:00
Mark Pollack
b9e4123b5d Temporarily disable Ollama streaming function calling tests 2024-12-08 22:15:49 -05:00