Commit Graph

77 Commits

Author SHA1 Message Date
Christian Tzolov
c001650551 Minor code improvements 2024-02-28 16:30:39 +01:00
Christian Tzolov
65d42c9d4f Add full support or Vertex AI Gemini and Azure OpenAI function calling
- Extend the Spring AI Message with getMediaData() : List<MediaData>
   MediaData is a pair of MimeType and data of type Object.
   Message#getContent() return text only.

 - VertexAI Gemini Support
   - implement VertexAiGeiminChatClient for ChatClient and StreamingChat client and support for MediaData content.
     add IT tests for Chat, Streaming and Multimodality
   - add Auto-configuration + ITs
   - add Gemini Spring Boot starter.
   - add clients and boot starters to the Spring AI BOM.
   - add Anotra documentation for the Gemini chat client.
   - update gemini to latest 26.33.0 BOM.
   - add vertex ai gemini dependencies to the BOM.
   - add Vertex AI Gemini API Function Calling support
   - add Gemini API Function Calling Streaming support
   - add vertex ai gemini function calling documentation
   - factor out the Function Calling functionality into common abstraction used by OpenAI, Azure and Gemini.
   - group the VertexAI documentation under a common parent
   - add PortableFunctionCallingOption that implements FunctionCallingOptions and ChatOptions and provide builder for it.
   - remove some deprecated code.
   - allow authorization with GoogleCredentials form json file.
   - add AOT support for VertexAI Gemini.
   - move legacy Vertex AI into VertexAI PaLM2.
   - better handling for empty chat responses.
   - update the Gemini version to latest 26.33.0. This required lifting the protobuf-java to 3.25.2 as well.
   - fix a bug for handling System messages with Gemini.

- Implement Azure OpenAI Function Calling
  Uses the same the common abstractions used by OpenAI and Gemini: FunctionCallingOptions and AbstractFunctionCallSupport
2024-02-28 15:41:37 +01:00
Christian Tzolov
35808498f9 Mistral AI: test package restructuring. Fix failing tests. Add AOT tests 2024-02-28 15:13:45 +01:00
Christian Tzolov
a81a99ff9d Mistral AI improvements
- add AOT support.
 - move the org.springframework.ai.mistral package into org.springframework.ai.mistralai.
2024-02-28 14:46:13 +01:00
ricken07
30c3530561 Add integration for Mistral AI Chat and Embedding models
- Implement MistrealAiApi as a REST client for the Mistral REST API.
 - Add MistralAiChatClient implementing ChatClient and StreamingChatClient.
   Add MistralAiChatOptions implementing ChatOptions.
 - Add MistralAiEmbeddingClient impelementing EmbeddingClient.
   Add MistralAiEmbeddingOptions implementing EmbeddingOptions.
 - Add Unit and IT tests for api and clients.
 - Add mistral  auto-configuration and boot strarter
 - update auto-config property for Mistral AI embedding client
 - update auto-config property for Mistral AI embedding client

 Additional, review changes:
 - Add missing license headers.
 - Fix the intialization of defaul options.
 - Code re-formatting to improve the readabitliy.
 - Many improvements
 - Add missing sine annotations
 - Remove stream field from MistralAiChatOptions. This handled internally.
 - Add MistralAiApi ChatModel and EmbeddingModel enums.
 - Add MistralChatClientIT for testeing chat, stream , parsers...
 - Add MistralAiApiIT tests
 - Refactor and streamline the MistralAiAutoConfiguration.
 - Add MistralAiAutoConfigurationIT
2024-02-28 13:29:35 +01:00
Christian Tzolov
21fc676fba Improve SpringAI models AOT support
- Fix various issues for bedrok/llama2/titan/choere,palm2,openai,azure-openai and vertex
 - Addd demo tests: https://github.com/tzolov/spring-ai-aot-tests
 - Fix broken Ollama AOT configuration
 - Code style & doc improvements for onnx transformer client

 Part of #360
2024-02-26 21:50:04 +01:00
Mark Pollack
8532cb7bcc Bump to 0.8.1-SNAPSHOT 2024-02-23 11:11:14 -05:00
Christian Tzolov
272ed099ed Fix Azure option merging bug 2024-02-22 18:33:21 +01:00
Mark Pollack
596f2b06c0 Move native hints into individual modules
* Use aot.factories approach for registration
* Add tests
* final tweaks- Thanks Josh!
2024-02-20 14:23:40 -05:00
Mark Pollack
ea7dce3833 Refine Bedrock README. Fixes #180 2024-02-19 12:36:03 -05:00
Mark Pollack
a107e313fc Fixes #219 - Remove dependency cycles 2024-02-19 12:24:16 -05:00
Christian Tzolov
fdd3fbb2f9 Revert default OpenAI embedding to text-embedding-ada-002 as some vector stores have problems with 3-small 2024-02-16 11:19:34 +01:00
Christian Tzolov
697e945950 Fix EmbeddingIT after default openai embedding model switch 2024-02-16 10:40:13 +01:00
Christian Tzolov
7ef49b8cef Set the default OpenAI Embedding model to text-embedding-3-small
The text-embedding-3-small has the same dimensions as previous text-embedding-ada-002.
  The text-embedding-3-large has higher dimensionality not supported by some Vector Stores.
2024-02-16 10:27:13 +01:00
Christian Tzolov
bd479e1388 Address review comments 2024-02-15 22:38:50 +01:00
Christian Tzolov
d580fe2757 Simplify Function Calling API 2024-02-15 20:26:31 +01:00
Christian Tzolov
1fa2036120 Refactor the Function Calling Support
- Remove the SpringAiFunction annotation in favour of palin Functino Beans, @Description annotation and JacksonClassAnnotation.
 - Update the function calling documentation to reflect latest changes.
 - Add a new openai option (and related property): spring.ai.openai.chat.options.beanFunctions.<function-name>.<description>
   Map of bean names and their descriptions to register as function callbacks.
 - Refactor the OpenAiAutoConfiguration to resolve and register the beans in beanFunctions.
 - Add dependency on Spring Cloud Function to use the FunctionContextUtils and FunctionTypeUtils
   Those utilites help to resolve the function input type signature.
 - Add DefaultToolFunctionCallback class for manually wrapping Functions.
 - Update the ITs.
2024-02-15 12:39:35 +01:00
Mark Pollack
43dbaf4edd Add documentation for Image Generation
- Refine StabilityAI classes
- Add documentation
2024-02-14 17:18:04 -05:00
Christian Tzolov
22bd645d1e fix azure model README broken link 2024-02-14 06:55:42 +01:00
Christian Tzolov
9d41e4380a Make model READMEs ponint to their corresponding Antora documentations 2024-02-14 06:50:23 +01:00
Christian Tzolov
ffd8222c20 OpenAI ChatClient tools support
* Add function call OpenAiApi IT tests
* Add function call docs. Unit and IT func tests
* Add function call diagram
* Allow to opt-in/enable the fuctions to be used in request.
2024-02-11 23:34:04 -05:00
Christian Tzolov
21d7cdd5c0 Add VertexAi Embeddings Docs + clear READMEs 2024-02-11 18:32:55 +01:00
Christian Tzolov
7ea867d3cb Add VertexAi Chat Optios Support + Docs 2024-02-11 18:00:15 +01:00
Christian Tzolov
d38afc50a3 Document Bedrock Titan Embedding API and clients
- Remove outdated Bedrock README fiels and add references to the main docs.
2024-02-11 16:16:22 +01:00
Christian Tzolov
ed52a3e0a1 Add Bedrock Titan Chat Options + Docs 2024-02-11 15:32:33 +01:00
Christian Tzolov
35ce0d1a4b Add Bedrock Cohere Embedding Options support
- Realign the Embeddings API docs strcture
2024-02-11 12:25:26 +01:00
Christian Tzolov
056b95a00e Improve Chat Completon API documentation
- minor code style improvements.
2024-02-10 18:17:06 +01:00
Christian Tzolov
7fca784b05 Add Bedrock Anthropic Chat Options support
- Improve Anthropic tests
 - Add anthrpic docs
 - Restructure the docs for Azure OpenAI, OpenAI, Ollama, Bedrock Cohere and Bedrock Lllam2
2024-02-10 12:22:34 +01:00
Christian Tzolov
c5f80f4930 Minor documentation updates 2024-02-09 19:06:38 +01:00
Christian Tzolov
ced9e6a82d Fix and optimize azure openai chat/embedding clients
- Also restructore and clarify the chat/embedding docs.
2024-02-09 16:45:42 +01:00
Christian Tzolov
ca0f6d79e3 OpenAi Chat/Embedding options handling optimizations
- Also restructure and clean the openai chat/embedding docs.

Address review comments
2024-02-09 15:53:27 +01:00
Christian Tzolov
ed6a464ba8 Add options support to PostgresMlEmbeddingClient
- Add postgremaddmbedding adoc page.
- Auto-configuration:
  - add missing  boot-starter.
  - refactor autoconf class and properties to accomodate the PostgresMlEmbeddingOptions.
- PostgesMlEmbeddingClient
  - Add the (default) options field and remove old fields.
  - Implement default and request options merging.
  - Add tests for options and merging.
- Remove redundant code.
- Code style fixes.
2024-02-09 14:40:53 +01:00
Christian Tzolov
577a605cdc Add Bedrock Llama2 Options Support 2024-02-08 19:41:21 +01:00
Christian Tzolov
779b5a8d5e Bedrock Anthropic Options Support 2024-02-08 18:07:54 +01:00
Christian Tzolov
dfbea8cee1 Add Azure OpenAI Chat and Embedding Options
- Add AzureOpenAiChatOptions
   - Add default options field to AzureOpenAiChatClient.
   - Impl runtime (e.g. prompt) and default options on call.
   - Add options field to the AzureOpenAiChatProperties.
 - Add AzureOpenAiEmbeddingOptions
   - Add default options field to AzureOpenAiEmbeddingClient.
   - Impmlement runtime and default option merging on embedding request.
   - Add options field to AzureOpenAiEmbeddingProperties.
 - Add Unit and ITs.
 - Split the azure-openai.adoc into ./clients/azure-openai-chat.adoc and ./embeddings/azure-openai-embeddings.adoc.
   - Provide detailed explanation how to use the chat and embedding clients manually or via the auto-configuration.
   - Add protable ChatOptions support
2024-02-05 16:15:53 -05:00
Christian Tzolov
4c4e234279 Fix ollama embedding options merging bug 2024-02-03 15:34:41 +01:00
Christian Tzolov
0a930d2ab5 fix broken docs and compilation issues 2024-02-03 15:25:18 +01:00
Christian Tzolov
97537e0a10 Improve Ollama Options support
- Rename OllamaChatClient#withOptions(...) method to OllamaChatClient#withDefaultOptions(...)
 - Rename OllamaEmbeddingClient#withOptions(...) method to OllamaEmbeddingClient#withDefaultOptions(...)
 - Remove the  Chat/Embedding Client model field by defaultOptions.mode one.
 - Correct default and runtime OllamaOptions merging implemented.
 - Added support for portable ChatOptions.
 - OllamaOptions a synthetic field ‘model’ not supported by Ollama API but used by the OllamaChatClient
   and OllamaEbeddingClients. The model field is removed before calling the OllamaApi.
 - Update the IT ollama docker image to 0.1.23
 - Set Mistral as the default model.
 - Extend and improve the ITs
 - Add tests for testing the chat and embedding request creation and options merging logic.
 - Minor code-style improvements.
 - Split the ollama.adoc into embeddings/ollama-embeddings.addoc and clients/ollama-chat.adoc.
 - Improve the documentation to explain how to configure and use the Ollama Chat and Embedding clients manually or with the help of the auto-configuraitons.
 - Clarify the docs property sections.
2024-02-03 14:58:03 +01:00
Christian Tzolov
60a60b4610 Fix handling for openai chat portable options
- Now you can use an arbitrary ChatOption instance as Prompt options for the OpenAIChatClinet.
 - Add Unit tests for OpenAiApi and ModelOptionsUtils.
 - Document portable options support.
2024-02-02 15:34:56 +01:00
Christian Tzolov
d71f90fd56 add OpenAiApi tests 2024-02-01 19:13:57 +01:00
Christian Tzolov
b49458b3ee Improve OpenAiImage/Client implementation
- Impove the code style.
 - Merge the OpenAiImageOptions interface impl and builder into one class.
 - Improve the OpenAiImageClient call implementation.

 Resolves #274
2024-02-01 14:54:34 +01:00
Christian Tzolov
9b79359544 Add openai model retry error listener logging 2024-02-01 11:34:33 +01:00
Christian Tzolov
5b4784fc56 Add OpenAi Chat Options
Add OpenAiChatOptions

 - OpenAiChatOptions implements ChatOptions and exposes all OpenAi request options, except messages and stream.
 - Add OpenAiChatOptions field (as defaultOptions) to OpenAiChatClient. Implement star-up/runtime options merging on chat request creation
 - Add OpenAiChatOptions options field to OpenAiChatProperties. Later is set as OpenAiChatClient#defaultOptions. Use the spring.ai.openai.chat.options.* prefix to set the options.
 - Add tests for properties and options merging.
 - Move the OpenAiChatOptions.java out of the api package

Add OpenAiEmbeddingOptions

 - Add OpenAiEmbeddingOptions class implementing the EmbeddingOptions interface.
 - Add OpenAiEmbeddingClient#defaultOptions
 - Add request merging with default and propmt options.
 - Add OopenAiEmbeddingProperties#options field of type OpenAiEmbeddingOptions

Update OpenAI client docs

Part of the larger 'epic' issue #228
2024-01-29 13:48:12 -05:00
Christian Tzolov
7c7392e657 Change EmbeddingOptions from class into interface 2024-01-28 19:10:17 +01:00
Christian Tzolov
8f9a1475c1 Re-align the grpc dependecies and exclusions so that Milvus and Pinecone autoconfigurations ITs work 2024-01-26 18:32:55 +01:00
Christian Tzolov
08fea315a4 Update the production depedencies 2024-01-26 17:31:29 +01:00
Christian Tzolov
944c4ebbaa Fix Ollama client options NPE and lack for SYS message handling
- Fix the Ollama options merging to pervent NPE.
 - Fix the Ollama handling for SYS messages.
 - Fix the BeanOutputParser to support JSON Schema reponses.
 - All Ollama Parsers tests pass now.

 Resolves: #258 ,  #273
2024-01-26 15:29:09 +01:00
Christian Tzolov
eb42912efd Move OpenAiImageOptionsXXX classes outside the 'api' packages as those are client not api related 2024-01-26 10:48:36 +01:00
Christian Tzolov
5e38536b6c Rename streamingCall into stream 2024-01-25 16:36:29 -05:00
Christian Tzolov
4217a54c31 Make the StreamingChatClient a StreamingModelClient 2024-01-25 16:35:58 -05:00