Commit Graph

591 Commits

Author SHA1 Message Date
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
Soby Chacko
d4a6e1e619 CosmosDB vector store builder refactoring 2024-12-19 13:40:18 -05:00
Soby Chacko
71584e5238 Add builder pattern to HanaCloudVectorStore and refactor package name 2024-12-19 13:21:29 -05: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
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
Soby Chacko
48bcbd1555 Add builder pattern to QdrantVectorStore
Introduces a builder pattern for configuring QdrantVectorStore instances to
provide a more flexible and type-safe way to create and configure vector stores.
This change:

- Makes configuration more intuitive through fluent builder methods
- Improves validation by enforcing required parameters at compile time
- Deprecates old constructors in favor of the builder pattern
- Adds comprehensive builder tests to ensure reliability
- Updates reference documentation with builder usage examples
- Maintains backward compatibility while providing a clear migration path

The builder pattern simplifies QdrantVectorStore configuration by providing
clear method names, proper validation, and better IDE support through method
chaining. This makes the API more user-friendly and helps prevent configuration
errors at compile time rather than runtime.
2024-12-17 16:44:08 -05: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
Soby Chacko
8edf1bea47 Add builder pattern to MariaDBVectorStore and refactor package name
Introduces a builder pattern for configuring MariaDBVectorStore instances and
improves the overall implementation. This change:

- Makes configuration more flexible and type-safe through builder methods
- Deprecates old constructors and builder in favor of the new builder pattern
- Adds comprehensive validation of configuration options
- Improves documentation with clear examples and better structure
- Updates all test classes to use the new builder pattern
- Adds comprehensive builder tests
- Updated reference documentation

The builder pattern provides a more maintainable and user-friendly way to
configure vector stores while ensuring configuration validity at compile time.
This aligns with the project's move towards using builder patterns across all
vector store implementations.
2024-12-17 15:56:45 -05:00
Soby Chacko
8877672846 Add builder pattern to TypesenseVectorStore and refactor package name
Introduces a builder pattern for configuring TypesenseVectorStore instances and
moves the implementation to the org.springframework.ai.vectorstore.typesense
package. This change:

- Makes configuration more flexible and type-safe through builder methods
- Improves code organization by moving to a dedicated vector store package
- Deprecates old constructors in favor of the builder pattern
- Adds comprehensive validation of configuration options
- Enhances documentation with clear usage examples
- Adds dedicated builder test class for better test coverage
- Add builder tests
- update reference docs

The builder pattern simplifies TypesenseVectorStore configuration while ensuring
proper validation of all settings. The package move aligns with Spring AI's
architectural patterns and improves maintainability by grouping related classes
together.

review
2024-12-17 15:09:16 -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
Soby Chacko
d77c950ea6 Add builder pattern to WeaviateVectorStore and refactor package name
Introduces a builder pattern for configuring WeaviateVectorStore instances and
moves the implementation to the org.springframework.ai.vectorstore.weaviate
package. This change:

- Makes configuration more flexible and type-safe through builder methods
- Improves code organization by moving to a dedicated vector store package
- Deprecates old constructors in favor of the builder pattern
- Adds builder tests
- Enables better IDE support through method chaining
2024-12-16 16:26:59 -05:00
Soby Chacko
25123a5364 Add builder pattern to CassandraVectorStore and refactor package name
Introduces a builder pattern for configuring CassandraVectorStore instances and
moves the implementation to the org.springframework.ai.vectorstore.cassandra
package. This change:

- Makes configuration more flexible and type-safe through builder methods
- Improves code organization by moving to a dedicated vector store package
- Deprecates old constructors in favor of the builder pattern
- Adds comprehensive validation of configuration options
- Enables better IDE support through method chaining
- The builder pattern provides a more maintainable and user-friendly way to
  configure vector stores while ensuring configuration validity at compile time.
2024-12-16 15:38:20 -05:00
Soby Chacko
d3d34c9215 Add builder pattern to OpenSearchVectorStore and refactor package name
Add builder pattern to OpenSearchVectorStore

Introduces a builder pattern for OpenSearchVectorStore configuration and
refactors the package structure to org.springframework.ai.vectorstore.opensearch
for better organization and consistency with other vector stores.

The builder pattern improves usability by:

* Providing a fluent API for configuring store instances
* Making configuration options more discoverable through method names
* Enabling better validation of configuration parameters
* Supporting optional parameters with sensible defaults
* The package refactoring aligns with the project's standard package naming
conventions and improves code organization. All constructors are deprecated
in favor of the new builder pattern to guide users toward the preferred
configuration approach.
2024-12-15 13:09:15 -05:00
Soby Chacko
f69d879ec9 Add builder pattern to RedisVectorStore and refactor package name
Refactors RedisVectorStore to use the builder pattern for improved
configuration and usability. The changes include:

* Move classes to org.springframework.ai.vectorstore.redis package
* Add RedisBuilder with comprehensive configuration options
* Deprecate RedisVectorStoreConfig in favor of builder pattern
* Enhance documentation with detailed usage examples
* Improve error handling and parameter validation

This change makes RedisVectorStore configuration more intuitive and
consistent with other vector stores in the project.
2024-12-14 18:40:41 -05:00
Soby Chacko
cde8f7446c Add builder pattern and refactor Neo4jVectorStore
The Neo4j vector store implementation has been enhanced with a builder
pattern to be more intuitive than using ctors and follows spring ai builder
conventions.  Current constructors have been deprecated to maintain
backward compatibility for one releaes cycle.

The change includes:

* Move classes to dedicated neo4j package for better organization
* Add comprehensive builder pattern implementation with validation
* Improve documentation with detailed usage examples
* Deprecate but maintain old configuration approach for compatibility
* Update integration tests to demonstrate new builder pattern
* Enhance code readability and maintainability
2024-12-14 17:53:15 -05:00
Soby Chacko
2d3bdcddbd Add builder pattern to MongoDBAtlasVectorStore and refactor package name
The MongoDBAtlasVectorStore implementation has been enhanced with a builder
pattern to provide a more flexible and type-safe way to configure the vector
store. This change improves the developer experience by making the API more
intuitive and less error-prone.

The old constructors and configuration classes have been deprecated in favor
of the builder pattern. This aligns with Spring's best practices for
configuration APIs.

Additionally, the package has been refactored to
org.springframework.ai.vectorstore.mongodb.atlas to avoid having
multiple vector store modules share the same package name.

Documentation has been updated to reflect these changes and provide
examples of using the new builder pattern.review
2024-12-14 17:19:25 -05:00
Soby Chacko
fc1f92d11c Add builder pattern and refactor Elasticsearch store package
The changes introduce a fluent builder pattern for ElasticsearchVectorStore
configuration, making it easier to create and customize instances with
optional parameters. All Elasticsearch-related classes are moved to a
dedicated elasticsearch package for better organization.

Key changes:

* Add ElasticsearchVectorStore.builder() with comprehensive options
* Move classes to org.springframework.ai.vectorstore.elasticsearch package
* Deprecate old constructors in favor of builder pattern
* Add support for configurable batching strategies
* Enhance documentation with usage examples and best practices
2024-12-14 16:21:14 -05:00
Soby Chacko
257b963da9 PgVectorStore package rename and builder support
- Move PgVectorStore and related classes to org.springframework.ai.pg.vectorstore package
 - Update builder pattern to use more idiomatic method names (e.g. withSchemaName -> schemaName)
 - Deprecate existing constructors and old Builder class in favor of new static builder() method
 - Update tests to reflect the new builder style usage
 - Update docs
2024-12-14 15:24:14 -05:00
Christian Tzolov
9e18652bb8 docs: Update mcp diagram 2024-12-13 15:12:28 +01:00
Mark Pollack
5b11501cbe Update usage of Document::getContent to getText 2024-12-12 14:43:51 -05:00
Christian Tzolov
dda86808b7 docs: improve mcp docs 2024-12-12 11:24:44 +01:00
Christian Tzolov
7b9da084dd Add a doc page about MCP 2024-12-12 11:12:06 +01:00
Christian Tzolov
a474b1294e docs(bedrock-converse): add list of supported models to converse api docs
The commit adds a note to the bedrock-converse.adoc document that lists the supported models for the Converse API, including:
Amazon Titan, Amazon Nova, AI21 Labs, Anthropic Claude, Cohere Command, Meta Llama, Mistral AI
2024-12-10 11:40:53 +01: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
Christian Tzolov
c4ca5826f7 feat(ollama): Add streaming support for function calls and improve OllamaApi
- Implement streaming tool call support in OllamaApi and OllamaChatModel
- Add OllamaApiHelper to manage merging of streaming chat response chunks
- Remove @Disabled annotations for streaming function call tests
- Update documentation to reflect new streaming function call capabilities
- Add a new default constructor for ChatResponse
- Update Ollama chat documentation to clarify streaming support requirements
- Deprecated withContent(), withImages(), and withToolCalls() methods
- Replaced with content(), images(), and toolCalls() methods

Add token and duration aggregation for Ollama chat responses

- Modify OllamaChatModel to support accumulating tokens and durations across multiple responses
- Update ChatResponse metadata generation to aggregate usage and duration metrics
- Add tests to verify metadata aggregation behavior

Refactor Ollama duration fields and tests

- Replace Duration fields in OllamaApi.ChatResponse with Long to represent durations in nanoseconds, ensuring precision and compatibility.
- Update methods to convert Long nanoseconds to Duration objects (getTotalDuration, getLoadDuration, getEvalDuration, getPromptEvalDuration).
- Adjust merge logic in OllamaApiHelper to sum Long values for duration fields.
- Modify test cases in OllamaChatModelTests to align with Long duration representation and Duration.ofNanos conversions.
- Add new test class OllamaDurationFieldsTests to validate JSON deserialization and Duration conversion for duration fields.

Resolves #1847
Related to #1800
Resolves #1796
Related to #1307

test: Update OllamaWithOpenAiChatModelIT integration tests

- Remove @Disabled annotation for streamFunctionCallTest
- Add inputType for function callback in stream function call test
2024-12-08 21:28:10 +00:00
wstever
81a63910ac Update openai-embeddings.adoc
update azure openai to openai
2024-12-01 07:27:29 +01:00
Christian Tzolov
6792707d07 docs: update model/concepts diagram 2024-11-30 14:12:24 +01:00
Christian Tzolov
cdffc72c14 feat(openai) - Support for audio output in OpenAI chat model
- Introduced new options for audio output modalities in ChatCompletionRequest
- Added AudioParameters configuration for voice and audio format selection
- Enhanced OpenAiChatModel to handle audio generation and embedding
- Updated AssistantMessage and Media classes to support audio media
- Added integration tests for audio output functionality
- Implemented support for text and audio multi-modal responses
- Updated Spring AI's chat model comparison table to clarify OpenAI's input/output modalities
- Added new configuration properties for audio output:
  * spring.ai.openai.chat.options.output-modalities
  * spring.ai.openai.chat.options.output-audio
- Extended documentation to explain audio output generation with the gpt-4o-audio-preview model
- Updated Spring Boot configuration metadata to support new audio-related properties
- Included auto-configuration integration test for chat model with audio response generation

Resolves #1841
2024-11-28 20:27:02 +00:00
Christian Tzolov
6a195ee9fe refactor(core): extract common function callback builder functionality
Extracts shared function callback builder functionality into DefaultCommonCallbackInvokingSpec
base class, reducing code duplication across builder implementations.
Makes FunctionInvokingSpec and MethodInvokingSpec extend CommonCallbackInvokingSpec for better
code organization. Also fixes function/description builder order in Anthropic tests.

- Introduced a common base class for function callback builders to centralize shared logic
- Standardized the order of method chaining for function and description in multiple AI model test classes
- Refactored test cases across various AI model integrations
- Corrected builder method order from .description().function() to .function().description()
  and .description().method() to .method().description()
- Updated multiple test files to consistently use .function() before .description()
- Updated documentation examples to reflect new builder method order
- Modified DefaultFunctionCallbackResolver to maintain new builder method order
- Updated DefaultChatClient and ChatClient test classes to reflect new builder pattern
- Simplified callback specification by removing parent spec reference
- Removed cascading getter logic for description, schema type, and other properties
- Minor adjustments to function callback builder and invoking specs
2024-11-28 19:28:08 +00:00
Alexandros Pappas
dcc8d5b620 feat: Add Perplexity AI integration and documentation updates
- Introduced `PerplexityWithOpenAiChatModelIT` integration test for Perplexity AI with OpenAI Chat Model.
  - Includes various test cases for role-based prompts, streaming responses, token usage validation, and output converters.
  - Added tests for function calls and metadata validation.
- Updated Antora navigation (`nav.adoc`) to include Perplexity AI documentation link.
- Enhanced chat model comparison documentation to highlight Perplexity AI integration.
- Added a dedicated `perplexity-chat.adoc` page under `spring-ai-docs` to provide detailed documentation for integrating Perplexity AI.
  - Covers API prerequisites, auto-configuration, and runtime options.
  - Explains configuration properties such as `spring.ai.openai.base-url`, `spring.ai.openai.chat.model`, and `spring.ai.openai.chat.options.*`.
  - Provides examples for environment variable setup and runtime overrides.
  - Highlights limitations like lack of multimodal support and explicit function calling.
  - Includes a sample Spring Boot controller demonstrating integration usage.
  - Links to Perplexity documentation for further reference.
2024-11-28 19:11:27 +01:00
diego
0b00e6f446 feat(vector-store) Add MariaDB Vector Store support to Spring AI
- Updated `org.springframework.boot.autoconfigure.AutoConfiguration.imports` to include MariaDB vector store auto-configuration
- Created MariaDB Vector Store autoconfiguration integration tests (`MariaDbStoreAutoConfigurationIT`)
- Added MariaDB store properties configuration and tests (`MariaDbStorePropertiesTests`)
- Introduced new Maven modules:
  - `spring-ai-mariadb-store`: Core MariaDB vector store implementation
  - `spring-ai-starter-mariadb-store`: Spring Boot starter for MariaDB vector store
- Added `MariaDBFilterExpressionConverter` to support JSON-based metadata filtering in MariaDB
- Implemented filter expression conversion for MariaDB vector store queries
- Added README.md with documentation link for MariaDB Vector Store
- Updated project dependencies to include MariaDB JDBC driver and test containers
- Configured integration testing with TestContainers for MariaDB
- Added observability support for MariaDB vector store operations
2024-11-28 17:25:32 +01:00
Thomas Vitale
33f431e4a7 feat(openai) - Support audio input and output modality
- Added support for audio input and output in OpenAI Chat Completion API
- Introduced new audio-related parameters, enums, and record types
- Updated ChatCompletionMessage, ChatCompletionChunk, and related classes
- Added new AudioParameters, AudioOutput, and InputAudio record types
- Implemented method to handle audio media content conversion
- Included new model enum for GPT-4o audio preview
- Extended existing API classes to accommodate audio modalities
- Modified usage tracking and metadata classes to handle audio-specific token details
- Improved ModelOptionsUtils with additional JSON utility methods

Tests:
- Updated test classes to validate audio input and output functionality
- Added integration tests for multimodal audio input with streaming and non-streaming methods
- Created parameterized tests for audio-enabled models
- Enhanced OpenAI API integration tests to cover audio-related scenarios

Docs:
- Updated documentation in spring-ai-docs to explain audio multimodality support

Resolves #1560
2024-11-27 12:46:43 +01:00
Jemin Huh
7b3f424ae1 Fix correct external link formatting for Ollama documentation
Signed-off-by: Jemin Huh <hjm1980@gmail.com>
2024-11-26 12:07:45 +01:00
Christian Tzolov
e543cd082d Update AnthropicChatModel and Spring AI Documentation for Multimodal Support
- Enhance AnthropicChatModel to support PDF and document content types
- Introduce getContentBlockTypeByMedia method for flexible media type handling
- Update ContentBlock handling to dynamically determine content type for media
- Add multimodal PDF support test case for Claude 3.5 Sonnet
- Update documentation to reflect PDF and multimodal capabilities
- Modify comparison chart to show PDF support for Anthropic Claude

Fixese #1819

review
2024-11-25 23:54:57 -05:00
Christian Tzolov
979de19162 docs(vertex-ai-gemini): Add Gemini PDF support docs and add IT
- Add test case for PDF document summarization using Gemini multimodal capabilities
- Update documentation to reflect PDF support in model comparison table
- Add PDF format to multimodal capabilities documentation
2024-11-25 14:09:54 +01:00
Christian Tzolov
87ff101946 docs: move Bedrock Converse to chat folder & add to comparison table
- Move bedrock-converse.adoc from api/ to api/chat/ directory
- Add Bedrock Converse to chat models comparison table
- Fix table entry formatting for OCI GenAI/Cohere width values

The move aligns with the documentation structure where chat-related content
is organized under the api/chat/ directory.
2024-11-25 12:41:17 +01:00