Commit Graph

1618 Commits

Author SHA1 Message Date
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
cf846688af Add deprecated with* methods to FunctionCallingOptions
Add backwards compatibility methods from FunctionCallingOptionsBuilder
to the Builder interface in FunctionCallingOptions. This allows users
to gradually migrate from the old builder style (with* methods) to the
new style while maintaining the same functionality.

Each deprecated method is marked for removal in 1.0.0-M5 and includes
proper Javadoc directing users to the new method names. The methods
are implemented as default methods that delegate to their new
counterparts.
2024-12-21 19:38:01 -05:00
Christian Tzolov
8ad90621c4 docs(mcp) Update the MCP documentation to latewt 0.2.0 release 2024-12-21 19:44:56 +01: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
Soby Chacko
d697e58c05 Update vector store builder examples
Update documentation examples to show correct builder usage across all vector store implementations.
Demonstrate passing required parameters directly in builder() method.
2024-12-21 11:28:39 -05:00
Soby Chacko
f9d741dd85 Standardize builder class names in vector stores
- Rename all specific builder inner classes (PineconeBuilder, MongoDBBuilder, etc.)
  to simply Builder for consistency across vector store implementations
- Update code references to use the new standardized Builder class names

The change establishes a consistent naming convention for builder classes
across the vector store implementations, improving code uniformity.
2024-12-21 11:28:39 -05:00
Ilayaperumal Gopinathan
a55d09aa7a Update document for SearchRequest builder changes 2024-12-21 11:18:06 -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
776dc51b8b Fix javadoc for Document
- Remove references of embedding from Document
 - Update the javadoc for Document#score to reflect the embedding of either text/media instead of Document embedding
2024-12-21 01:39:52 +00:00
WonJun Lee
636f3aee4f GH-1913: Add line separator override for text formatting
Fixes: #1913

Issue: https://github.com/spring-projects/spring-ai/issues/1913

- Add lineSeparator field to ExtractedTextFormatter with configurable override
- Update deleteTopTextLines and deleteBottomTextLines methods to use custom separator
- Mark old methods as deprecated in favor of new ones with separator parameter
- Update PDF test to use explicit line separator for Windows compatibility
2024-12-20 20:19:28 -05:00
Ilayaperumal Gopinathan
1dd9de422d Fix javadoc errors 2024-12-21 00:13:06 +00:00
Ilayaperumal Gopinathan
80317e2de6 Fix CassandraVectorStore
- Remove non-null session check from CassandraBuilder constructor
2024-12-20 22:34:16 +00:00
Ilayaperumal Gopinathan
a0ef1179c4 Fix PgVectorStoreWithChatMemoryAdvisorIT
- Use the PgVectorStoreBuilder to create the instance of PgVectorStore
2024-12-20 20:38:41 +00:00
Ilayaperumal Gopinathan
1e68862142 Fix SimpleVectorStore' deprecated constructor use
- Use SimpleVectorStoreBuilder for SimpleVectorStore instance creation
2024-12-20 20:29:40 +00:00
Ilayaperumal Gopinathan
2804604933 Refactor SearchRequest builder methods
- Add a new Builder inner class to move all the builder methods and deprecate the existing builder methods
 - Update docs and references
2024-12-20 19:35:17 +00:00
Sylvain Blanc
699a075e1c Update prompt.adoc
Remove `this.` in code example as it's local variables and not fields
2024-12-20 14:33:10 -05:00
Thomas Vitale
c7fd7c729e Refine and document initial Modular RAG
* Introduce CompressionQueryTransformer and RewriteQueryTransformer in the Pre-Retrieval Module.
* Extend Query with conversation history and context.
* Remove QueryRouter sub-module. New design will be considered in the next milestone.
* Update RetrievalAugmentationAdvisor accordingly.
* Add initial documentation for Modular RAG, and establish dedicated page for RAG content.

Fixes gh-1850

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2024-12-20 13:43:12 -05:00
Thomas Vitale
97e58ccfc4 Fix Qdrant failing test
Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2024-12-20 13:35:00 -05: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
Alexandros Pappas
164d281261 Add Examples section linking to Spring AI examples repository 2024-12-20 12:41:37 -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
Soby Chacko
1a6e79cbb9 Enhance vector stores with consistent APIs and null safety
- Replace Document.getContent() with getText() across all vector store implementations
- Fix incorrect package declarations in package-info.java files
- Make builder constructors private and implement proper builder patterns
- Add @Nullable annotations for better null safety
- Simplify PineconeVectorStore builder API by requiring essential parameters in factory method
- Make static Map fields final
- Clean up code and improve JavaDoc documentation

The changes focus on making the vector store APIs more consistent,
type-safe, and maintainable while following best practices for
builder patterns and null safety.
2024-12-20 12:19:12 -05:00
Soby Chacko
ee8bf37359 Require essential dependencies in vector store builder constructors
This commit refactors the builder pattern implementation across all VectorStore
implementations to make the EmbeddingModel a required constructor parameter
rather than an optional builder method. Key changes include:

- Move embeddingModel from being a builder method to a required constructor parameter
- Make embeddingModel final in AbstractVectorStoreBuilder
- Remove redundant validate() methods since EmbeddingModel validation now happens
  in constructor
- Update all VectorStore builder instantiations to pass EmbeddingModel in builder
  creation
- Add @Nullable annotations to appropriate methods in VectorStore interface

This change improves the API design by:
1. Enforcing that EmbeddingModel is provided at builder creation time
2. Removing the possibility of forgotten EmbeddingModel configuration
3. Simplifying the builder implementation by moving validation to construction
4. Making the dependency on EmbeddingModel more explicit in the API

Breaking Changes:
- VectorStore builders must now be created with an EmbeddingModel parameter
- The embeddingModel() builder method has been removed from all implementations
2024-12-20 12:15:58 -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
Mark Pollack
f92a3f0fcb Add support for general LLMs in FactCheckingEvaluator
The FactCheckingEvaluator was initially designed for the Bespoke Minicheck
model which doesn't require explicit instructions. This change adds support
for general-purpose LLMs like Claude and GPT-4 that need clear evaluation
instructions in their prompts.

Key changes:
- Introduce separate prompts for Bespoke and general LLMs
- Add factory method for Bespoke Minicheck configuration
- Make evaluation prompt configurable via constructor

This maintains backward compatibility while enabling the evaluator to work
effectively with any LLM implementation.
2024-12-19 15:14:18 -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
0d122bb007 Remove embedding from Document
- This PR removes the reference of `embedding` from the `Document` object.
   - The Document is designed to contain the content and its metadata but not the embedding representation of its content. This provides clear separation of concern.
   - Prior to this change, all the vector stores are updated by not depending on the embedding from Document. Instead, use the embedding values returned by the Embedding Models directly: https://github.com/spring-projects/spring-ai/issues/1826

Resolves #1781
2024-12-19 14:38:35 -05:00
Ilayaperumal Gopinathan
bfc0b8285e Fix DefaultFunctionCallingOptionsBuilder inheritance
Removes duplicate state by reusing parent's options field for both function
calling and chat options. This simplifies the inheritance structure and
prevents potential state inconsistencies.

- Remove functionCallingOptions field from DefaultFunctionCallingOptionsBuilder
- Set parent class options with FunctionCallingOptions in child constructor
- Add protected constructor in DefaultChatOptionsBuilder for inheritance
- Initialize options through constructors instead of direct assignment
2024-12-19 13:57:52 -05:00
Mark Pollack
a4acd8e4fa Add builder pattern to PineconeVectorStore and refactor package name 2024-12-19 13:50:21 -05:00
Mark Pollack
d6d246096b reformatting 2024-12-19 13:44:38 -05:00
Soby Chacko
351dfc2f85 Pinecone vector store builder refactoring 2024-12-19 13:44:38 -05:00
Soby Chacko
d4a6e1e619 CosmosDB vector store builder refactoring 2024-12-19 13:40:18 -05:00
Soby Chacko
138e11a3e5 Add builder pattern to AzureVectorStore and refactor package name 2024-12-19 13:38:22 -05:00
Soby Chacko
8c28c6dc88 Gemfire vector store builder refactoring 2024-12-19 13:22:54 -05:00
Soby Chacko
71584e5238 Add builder pattern to HanaCloudVectorStore and refactor package name 2024-12-19 13:21:29 -05:00
Soby Chacko
7a7a914dc0 Add builder pattern to CoherenceVectorStore and refactor package name 2024-12-19 13:17:59 -05:00
Soby Chacko
08bf66cbd5 Oracle vector store builder refactoring 2024-12-19 13:12:37 -05:00
Mark Pollack
7e2cefc3aa Share options instance between DefaultFunctionCallingOptionsBuilder and parent class 2024-12-19 11:23:01 -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
69cd3173f7 Fix mariadb similarity search
- The similarity search doesn't need the embedding to be returned/stored back to Document
2024-12-19 10:24:51 -05:00
Mark Pollack
5caf1084a7 Add tests for DefaultFunctionCallingOptions 2024-12-19 10:17:20 -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
26fab03c2c Refactor VectorStoreObservationContext builder methods
This commit deprecates builder methods with the "with" prefix in the VectorStoreObservationContext class
and introduces new methods without the prefix for a cleaner API. For example:

withCollectionName() → collectionName()
withDimensions() → dimensions()
withNamespace() → namespace()

The old methods are marked as deprecated for maintaining backward compatibility.

All vector store implementations have been updated to use the new method names.
2024-12-18 18:15:09 -05:00
Ilayaperumal Gopinathan
8ce8374825 Add builder pattern to SimpleVectorStore
- Create SimpleVectorStoreBuilder which can be used to create the SimpleVectorStore instance
 - Remove the field embeddingModel from SimpleVectorStore as it can be retrieved from AbstractObservationVectorStore
 - Deprecate the existing SimpleVectorStore constructors and use the builder to instantiate it
 - Fix the tests
2024-12-18 18:01:41 -05:00
Ilayaperumal Gopinathan
99a44fbab8 Fix builder methods not to use deprecated methods 2024-12-18 12:14:43 +00:00