Commit Graph

450 Commits

Author SHA1 Message Date
Eddú Meléndez
e1d9bfc616 Add MongoDB Atlas support for TestContainers and Docker Compose
Implement service connection support for MongoDB Atlas using both
TestContainers and Docker Compose. This change enables easier
integration testing and local development with MongoDB Atlas.

- Leverage TestContainers 1.20.2 which introduces MongoDBAtlasLocalContainer
- Add TestContainers support using MongoDBAtlasLocalContainer
- Implement Docker Compose configuration for MongoDB Atlas
- Create connection details factories for both TestContainers and Docker Compose
- Update dependency management for MongoDB Atlas integration
- Add integration tests for both TestContainers and Docker Compose setups
- Update documentation to include MongoDB Atlas support
2024-10-03 12:58:53 -04:00
Christian Tzolov
6fc76b7f9b Refactor advisor architecture in Spring AI
This commit introduces a major overhaul of the advisor system in Spring AI,
improving modularity, type safety, and consistency

Core Changes:
- Replace RequestAdvisor and ResponseAdvisor with CallAroundAdvisor and StreamAroundAdvisor
- Introduce AdvisedRequest and AdvisedResponse classes for better encapsulation
- Deprecate RequestResponseAdvisor in favor of new advisor types
- Remove AdvisorObservableHelper class

Advisor Implementation Updates:
- Update AbstractChatMemoryAdvisor, MessageChatMemoryAdvisor, PromptChatMemoryAdvisor,
QuestionAnswerAdvisor, SafeGuardAroundAdvisor, SimpleLoggerAdvisor, and
VectorStoreChatMemoryAdvisor to implement new advisor interfaces
- Remove CacheAroundAdvisor (functionality likely moved elsewhere)
- Make CallAroundAdvisor and StreamAroundAdvisor extend Ordered interface

Client and Chain Management:
- Modify DefaultChatClient to use new advisor chain approach
- Refactor DefaultAroundAdvisorChain for better ordering and observation
- Implement builder pattern for advisor chain construction in DefaultChatClient
- Separate call and stream advisors in DefaultAroundAdvisorChain

Observation and Context Handling:
- Update observation conventions and context handling in advisors
- Add order field to AdvisorObservationContext
- Modify DefaultAdvisorObservationConvention to include order in high cardinality key values

Testing and Integration:
- Refactor ChatClientAdvisorTests and add new AdvisorsTests
- Update integration tests to reflect new advisor structure
- Enhance AdvisorsTests to verify correct advisor execution order

New Features:
- Generalize the Protect From Blocking functionality across all advisors
- Add (experimental) Re2 advisor to enhance reasoning capabilities of LLMs
- Add disabled Re2 test in OpenAiChatClientIT

Documentation:
- Add Advisors documentation
- Enhance advisors documentation with order explanation and Re2 example

Advisor Ordering:
- Introduce Advisor constants for precedence ordering
- Update AbstractChatMemoryAdvisor to use new precedence constant
- Improve advisor ordering and management in DefaultAroundAdvisorChain.Builder
- Remove redundant reordering logic from DefaultAroundAdvisorChain

These changes aim to provide a more flexible and powerful advisor system,
allowing for easier implementation of complex AI-driven interactions

Co-authored-by: Dariusz Jędrzejczyk <dariusz.jedrzejczyk@broadcom.com>
2024-10-01 15:08:21 -04:00
Christian Tzolov
140bcabaf8 Docs: Deprecate maxTokens in favor of maxCompletionTokens for OpenAI chat options
- Add new option 'maxCompletionTokens' to spring.ai.openai.chat.options
 - Mark 'maxTokens' as deprecated
 - Update documentation to reflect these changes in OpenAI chat configuration

 Related to #1411 and #1412
2024-10-01 11:16:03 +02:00
Soby Chacko
4c8a6ee8b0 Document BatchingStrategy and enhance TokenCountBatching
This commit adds comprehensive documentation for the BatchingStrategy
in vector stores and enhances the TokenCountBatchingStrategy class.

Key changes:
- Explain batching necessity due to embedding model thresholds
- Describe BatchingStrategy interface and its purpose
- Detail TokenCountBatchingStrategy default implementation
- Provide guidance on using and customizing batching strategies
- Note pre-configured vector stores with default strategy
- Add new constructor for custom TokenCountEstimator in
  TokenCountBatchingStrategy
- Implement null checks with Spring's Assert utility
- Update docs with new customization options and code examples
2024-09-28 17:34:21 -04:00
Anders Swanson
ccf190c77c Add OCI GenAI embedding model support
This commit introduces support for Oracle Cloud Infrastructure (OCI)
GenAI embedding models in Spring AI. It includes:

* New OCIEmbeddingModel class for interacting with OCI GenAI API
* Auto-configuration for easy setup and integration
* Properties for configuring OCI connection and embedding options
* Documentation updates explaining usage and configuration
* Integration tests to verify functionality

Signed-off-by: Anders Swanson <anders.swanson@oracle.com>
2024-09-26 17:04:05 -04:00
cboy
5da44c4b45 Fix code example in ollama-embeddings documentation
Correct the OllamaEmbeddingModel initialization and options syntax in
the ollama-embeddings.adoc file. Remove unnecessary .toMap() call and
fix typo in withTruncate method name.
2024-09-25 14:56:54 -04:00
ashni
c5f07e5402 Enhance MongoDB docs with additional tutorials
Update mongodb.adoc to include links to both beginner and intermediate
content for Spring AI and MongoDB integration. Add a new section
"Tutorials and Code Examples" with:

- Link to the Getting Started guide for basic integration
- Link to a detailed RAG tutorial for more advanced usage

This change provides users with a clear path from initial setup to
more complex implementations using the MongoDB Atlas Vector Store.
2024-09-24 17:34:58 -04:00
Christian Tzolov
c98caf26d2 Minor test fixtures fixes 2024-09-23 23:03:56 +02:00
Christian Tzolov
501774925c Add proxy tool calls option to chat models
This commit introduces a new proxyToolCalls option for various chat
 models in the Spring AI project. When enabled, it allows the client to
 handle function calls externally instead of being processed internally
 by Spring AI.

 The change affects multiple chat model implementations, including:
  AnthropicChatModel
  AzureOpenAiChatModel
  MiniMaxChatModel
  MistralAiChatModel
  MoonshotChatModel
  OllamaChatModel
  OpenAiChatModel
  VertexAiGeminiChatModel
  ZhiPuAiChatModel

 The proxyToolCalls option is added to the respective chat options
 classes and integrated into the AbstractToolCallSupport class for
 consistent handling across different implementations.

 The proxyToolCalls option can be set either programmatically via
 the <ModelName>ChatOptions.builder().withProxyToolCalls() method
 or the spring.ai.<model-name>.chat.options.proxy-tool-calls
 application property.

 Documentation for the new option is also updated in the relevant
 Antora pages.

 Added ITs for proxy tool calls

 Remove ChatClientPromptRequestSpec and all ChatClient.prompt() overloads can how take advantage of the full fluent API.  Docs updated

 Resolves #1367
2024-09-23 16:22:58 -04:00
Thomas Vitale
acb31e7b75 Add prompt(String) method to ChatClient
This commit introduces a new overloaded method prompt(String content)
to the ChatClient API. It provides a convenient way to create prompts
using only a string of user content, simplifying the process for basic
chat interactions.

Fixes gh-1286

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2024-09-23 10:40:10 -04:00
PabloSanchi
035036c7f2 Add support for watsonx.ai embedding model
This commit introduces support for the Watsonx.ai embedding model.
It includes:

- Watsonx embedding options class with tests
- Watsonx embedding model implementation
- Auto-configuration and properties for the embedding model
- Tests for the Watsonx embedding model
- Documentation for using the Watsonx embedding model

Also removed use of deprecated APIs in WatsonAIChatModel
2024-09-19 11:45:04 -04:00
Eray Ocak
49b5ff5cc4 Update apache-cassandra.adoc to fix typo in initialize-schema property 2024-09-19 10:44:13 -04:00
Mark Pollack
9910ccc41e fix docs to remove use of 'f' for temperature chat option 2024-09-18 08:50:59 -04:00
Peter Dolukhanov
4f6274e0a8 Change references from PaLm2 to Gemini in Gemini docs 2024-09-17 18:58:50 -04:00
Ignasi
8d31a57698 Add metadataFieldsToFilter property for MongoDB store
Introduce a new property for the MongoDB vector store:
spring.ai.vectorstore.mongodb.metadata-fields-to-filter

This property accepts comma-separated values specifying which metadata
fields can be used for filtering when querying the vector store. It
ensures that metadata indexes are created if they don't already exist.

This addition enhances query performance and flexibility by allowing
users to define filterable fields in advance.

Co-authored-by: Eddú Meléndez <eddu.melendez@gmail.com>
2024-09-17 18:53:07 -04:00
Thomas Vitale
0ddf331fd4 Improve docs for OpenAI, Mistral AI and Ollama chat models and clients
* Improve docs for OpenAI, Mistral AI, and Ollama chat models and function calling
* Improve docs for the Chat Client

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2024-09-17 17:51:02 -04:00
GR
326bd21a09 Minimax doc fixes
- Add web search docs
- Fix minimax chat docs links
2024-09-16 23:38:08 -04:00
Thomas Vitale
4b123a7516 Use Double instead of Float for portable ChatOptions
This change updates the type of portable chat options from Float to
Double. Affected options include:
- frequencyPenalty
- presencePenalty
- temperature
- topP

The motivation for this change is to simplify coding. In Java, Float
values require an "f" suffix (e.g., 0.5f), while Double values don't
need any suffix. This makes Double easier to type and reduces
potential errors from forgetting the "f" suffix.

APIs, tests, and documentation have been updated to reflect this
change.

Fixes gh-712

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2024-09-16 15:35:51 -04:00
Laura Trotta
4f62ac1cee GH-1316: Elasticsearch vector store - Wrong error reported fix
Fixes: https://github.com/spring-projects/spring-ai/issues/1316

* Handling missing index case
* Docs update
* User header for observability
* Same exception management for delete
2024-09-09 11:58:29 -04:00
Thomas Vitale
37c34507cf Improve docs for foundational topics (#1279)
* Improve syntax and grammar
* Fix examples using latest APIs
* Add missing info about newer features

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2024-08-27 16:47:22 -04:00
Mark Pollack
e1884d1d92 Next development version 2024-08-23 18:47:37 -04:00
Mark Pollack
43ad2bdb97 Release version 1.0.0-M2 2024-08-23 18:46:58 -04:00
Mark Pollack
449790f73a Update to Boot 3.3.3
Add to docs that spring ai supports 3.2.x and 3.3.x
2024-08-23 12:37:01 -04:00
Szymon Ochnio
197fe8105c Fix Azure chat client image handling for byte arrays
Resolve issue with AzureOpenAiChatModel processing non-public images as
byte arrays. Implement handling for both URL strings and byte arrays,
converting latter to base64 encoded data URLs. Add test case for
resource-based media data. Update documentation with sample for
classpath resources.
2024-08-23 10:50:24 -04:00
Mark Pollack
793052c2e9 Add googleSearchRetrieval as an option for VertexAIGeminiChatOptions
- Add test
2024-08-22 19:26:36 -04:00
KimMinjeong
bc55bc7196 Add responseMimeType option in VertexAiGeminiChatOptions
- Add test
2024-08-22 18:48:59 -04:00
Mohammed, Ahmed yousri salama (Canada)
189468127c Implement OpenAI Moderation model
This commit introduces the OpenAiModerationModel and related classes:

- Add OpenAiModerationModel for content moderation
- Create OpenAiModerationOptions for configuration
- Implement OpenAiModerationProperties for Spring Boot setup
- Add integration tests in OpenAiModerationModelIT
- Add documentation

Co-authored-by: hemeda3 <hemeda3@users.noreply.github.com>
2024-08-22 17:39:16 -04:00
Piotr Olaszewski
56e678c487 Add Markdown document reader with enhanced features
This commit introduces a new Markdown document reader with several
key features and improvements:

* Add support for text with various formatting elements
* Implement handling for horizontal rules and hard line breaks
* Add functionality for inline and block code sections
* Incorporate blockquote handling
* Support ordered and unordered lists
* Introduce additional metadata capabilities
* Include JavaDocs

Update ETL documentation to reflect these new features and usage.

Fixes #105
2024-08-22 13:35:44 -04:00
Soby Chacko
a0ee10fa91 Docs for Tanzu genai cloud bindings 2024-08-22 13:25:30 -04:00
Soby Chacko
72011baf50 Adding ref docs for cloud bindings 2024-08-22 13:09:45 -04:00
Mark Pollack
9ecd9c0940 Add docs for Vector Store observability 2024-08-22 11:07:35 -04:00
Christian Tzolov
9587cb0dfb Add ChatClient input data section to Observability docs 2024-08-22 09:49:32 +02:00
Mark Pollack
99d679f232 Add documentation for Observability 2024-08-21 17:26:03 -04:00
Christian Tzolov
3b014db165 Add ChatClient Advisor Observability support
- Add advisor context, convetions and documentation
- Add ObservableRequestResponseAdvisor wrapper.
- Add Tests

Resolves #1258
2024-08-21 14:28:24 -04:00
Christian Tzolov
e881fefc39 Add spring-ai-test to MongoDB pom 2024-08-20 13:41:21 +02:00
Christian Tzolov
46893b0a99 Add documentation for NVIDIA LLM API integration
Add NVIDIA LLM API - OpenAI Integration Test.
2024-08-19 21:53:20 +02:00
uzhuraul
c2b6e85608 Fix OpenAiAudioSpeechOptions speed description
formatting
2024-08-19 15:26:41 -04:00
Jerry
72369d515f Fix typos in openai-transcriptions.adoc (#1217) 2024-08-15 10:28:52 -04:00
Christian Tzolov
d538e00643 Replace the Embedding format from List<Double> to float[]
- Adjust all affected classes including the Document.
 - Update docs.

Related to #405
2024-08-13 11:53:08 -04:00
jo-kim
656fa8b4fe Update chroma docs (#1171) 2024-08-12 16:39:19 -04:00
JayPark7821
9f5ed055d4 Docs: fix pinecone example (#1170) 2024-08-12 16:38:52 -04:00
ChanYeong
e02c691cec docs: Edit Auto-configuration Example (#1169)
* docs: Edit Auto-configuration Example

* docs: Edit Azure Example

* docs: Edit Oracle Example
2024-08-12 16:37:44 -04:00
Tim Kelly
568d90a92a Update mongodb.adoc (#1181) 2024-08-12 16:31:35 -04:00
dongfeng
aeba9c26ac docs(onnx): Add a note when the onnxruntime_gpu dependency is missing. 2024-08-12 01:27:40 +02:00
Thomas Vitale
bf84d5945e Streamline ChatOptions
* Surface more configuration APIs to ChatOptions
* Use abstraction in Observations directly instead of dedicated implementation
* Simplify metadata config in observations for defined models
* Improve merging of runtime and default options in OpenAI
* Fix missing option in Mistral AI

Relates to gh-1148

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2024-08-10 14:48:05 +02:00
Christian Tzolov
af25430054 Update OpenAI chat UML diagram 2024-08-09 10:05:39 +02:00
Christian Tzolov
2da161cfb1 Improve OpenAI structured outputs support
- Add `TEXT` to the supported ResponseFormat types
- Add JsonSchema record for structured output configuration
- Update OpenAI chat documentation with details on Structured Outputs
- Clarify usage of JSON_SCHEMA response format in properties and code examples
- Update Structured Output Converter docs to mention OpenAI Structured Outputs
2024-08-09 08:22:58 +02:00
Christian Tzolov
91afed5ae5 OpenAi: Add support for structured outputs and JSON schema
- Added support for OpenAI's structured outputs feature, which allows specifying a JSON schema for the model to match
- Introduced new record to configure the desired response format
- Added support for configuring the response format via application properties or the chat options builder
- Extend teh BeanOutputConverter to help generate JSON schema from a target domain object and convert the response.
- Added comprehensive tests to cover the new response format functionality

Resolves #1196
2024-08-08 17:00:18 -04:00
Dave Syer
e2c5208e3e Correct some grammar typos with 'latter' 2024-08-08 13:08:24 +02:00
JayPark7821
689e458648 Docs: Edit pinecone example (#1154)
```
// Add the documents
vectorStore.add(List.of(document));
```
To
```
// Add the documents
vectorStore.add(documents);
```
2024-08-05 13:35:36 -04:00