Commit Graph

472 Commits

Author SHA1 Message Date
Christian Tzolov
fe09b4ddce Bring antora packages up to date 2024-10-12 16:51:10 +02:00
Christian Tzolov
4c61e47621 Upgrade antora to v0.4.16 2024-10-12 14:31:17 +02:00
Mark Pollack
4c83fe8302 Guard against NPE in ZhiPu embedding model
- Update retry test to pass - needs investigation
2024-10-08 23:37:00 +02:00
Mark Pollack
4a892b5269 Release version 1.0.0-M3 2024-10-08 23:18:50 +02:00
Mark Pollack
cddb00a5f9 Minor doc improvements to observability 2024-10-08 14:46:25 +02:00
Christian Tzolov
13709f9542 Add builder pattern and order parameter to advisors
- Introduce builder pattern for MessageChatMemoryAdvisor, PromptChatMemoryAdvisor,
   QuestionAnswerAdvisor, SafeGuardAdvisor, and VectorStoreChatMemoryAdvisor.
 - Add 'order' parameter to control advisor execution priority
 - Modify constructors to include the new 'order' parameter
 - Update AbstractChatMemoryAdvisor to support the new 'order' parameter
 - Update docs
2024-10-08 13:30:58 +02:00
Mark Pollack
e712f6cc77 Udpate Spring AI Built-in Advisors documentation 2024-10-08 12:39:04 +02:00
Mark Pollack
d96d0b53f6 Add docs for FactCheckingEvaluator 2024-10-08 12:21:52 +02:00
努力的小雨
82a69dc3a3 Update milvus.adoc
error description
2024-10-08 10:56:59 +02:00
John Blum
3738c38b66 Cleanup grammar in documentation
* Fixes grammar in (Ollama) Function Calling.
* Fixes grammar in ETL Pipeline.
* Fixes grammar in Vector Databases.

Closes #1494
2024-10-08 10:56:29 +02:00
Christian Tzolov
38082de0f8 Refactor FunctionCallback API to use ToolContext instead of Map<String, Object>
- Replaced `Map<String, Object>` with `ToolContext` in the `FunctionCallback`, `AbstractFunctionCallback`, and related classes.
 - Updated all BiFunction definitions to use `ToolContext` as the second parameter,
   enhancing the clarity and structure of the tool context management.
 - Modified `FunctionCallbackWrapper` and `FunctionCallbackContext` to adapt to the new `ToolContext` parameter.
 - Adjusted the handling of tool context in the documentation and test classes.
 - Updated relevant test cases to reflect the API changes and modified the function handling logic to ensure consistency.
2024-10-07 16:15:55 +02:00
Mark Pollack
662afdf46e Update asciidoc table in Azure OpenAI properties documentation
- Add description for spring.ai.azure.openai.custom-headers property

Fixes #1434.
2024-10-07 14:32:37 +02:00
Bruno Oliveira
78073c64ea Update bedrock-cohere-embedding.adoc to fix an incorrect description 2024-10-07 11:52:36 +02:00
Thomas Vitale
6e62ff7d83 Add Cloud Bindings for Mistral AI
* Introduce Cloud Bindings support to configure the Mistral AI integration
* Update the Cloud Bindings documentation accordingly
2024-10-07 10:04:51 +02:00
ktm
2babb2a878 Add JSON Pointer support to JsonReader
This enhancement allows users to specify a JSON Pointer to extract
specific parts of a JSON document when reading. Key changes include:

- New get(String pointer) method in JsonReader class
- Updated JsonReaderTests with pointer-based extraction tests
- Added documentation for JSON Pointer usage in etl-pipeline.adoc

This feature enables more flexible parsing of complex JSON structures,
allowing users to easily target nested data for extraction.
2024-10-06 23:10:24 +02:00
John Blum
aa4502896d Correct grammar in the Image Model API doc
Closes #1454
2024-10-06 22:50:58 +02:00
Christian Tzolov
8bea302b11 Add missing observation and merics names to the docs 2024-10-06 22:01:50 +02:00
Thomas Vitale
60e36c3b55 Update Observability documentation
* Update attributes
* Add more information on optional attributes and risks
* Include documentation for events.

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2024-10-06 19:19:58 +02:00
Christian Tzolov
eb2deba9cb Clarify how advisors are ordered in the reference doc 2024-10-06 16:40:54 +02:00
Jang990
bf172e931d Remove duplicate Elasticsearch initialize-schema property
This commit removes the duplicate entry of
'spring.ai.vectorstore.elasticsearch.initialize-schema' property from
the Elasticsearch Vector Store documentation.
2024-10-04 16:55:14 -04:00
Christian Tzolov
9c10a08bef Add tool context support to chat options and enhance function calling
This commit adds support for tool context in various chat options classes across
  different AI model implementations and enhances function calling capabilities.

  The tool context allows passing additional contextual information to function callbacks.

 - Add toolContext field to chat options classes
 - Update builder classes to support setting toolContext
 - Enhance FunctionCallback interface to support context-aware function calls
 - Update AbstractFunctionCallback to implement BiFunction instead of Function
 - Modify FunctionCallbackWrapper to support both Function and BiFunction and
   to use the new SchemaType location
 - Add support for BiFunction in TypeResolverHelper
 - Update ChatClient interface and DefaultChatClient implementation to support
   new function calling methods with Function, BiFunction and FunctionCallback arguments
 - Refactor AbstractToolCallSupport to pass tool context to function execution
 - Update all affected <Model>ChatOptions with tool context support
 - Simplify OpenAiChatClientMultipleFunctionCallsIT test
 - Add tests for function calling with tool context
 - Add new test cases for function callbacks with context in various integration tests
 - Modify existing tests to incorporate new context-aware function calling capabilities
 - Add docs in in openai function calling

 Resolves #864, #1303, #991
2024-10-04 16:47:42 -04:00
Christian Tzolov
d6dc2b26bf Add conditinal support for logging errors in observation Span
- Useful for not Web apps.
 - Introduce ErrorLoggingObservationHandler for tracing errors across various AI contexts
 - Add error logging configuration option to ChatObservationProperties
 - Include ErrorLoggingObservationHandler bean in ChatObservationAutoConfiguration
 - Update docs

Resolves #1440
2024-10-04 11:08:26 -04:00
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