Commit Graph

41 Commits

Author SHA1 Message Date
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
Christian Tzolov
5d55b68380 Align the Embedding api with the new meta-model
- Craete new EmbeddingOptions -> ModelOptions, EmbeddigRequest -> ModelRequest, EmbeddingResponseMetadata -> ResponseMetadata and EmbeddignResultMetadata -> ResultMetadata.
 - Make the EmbeddigClient interface extend from ModelClient<EmbeddingRequest, EmbeddingResponse>, EmbeddingResponse implements ModelResponise and Embedding implements ModelResult.
 - Fix affected tests.
 - Steramline the EmbeddingClient interface with default method implementations based on call.
 - Merge EmbeddingUtil into AbstractEmbeddingClient
2024-01-25 16:33:37 -05:00
Toshiaki Maki
0cf0ed9e00 Use ObjectMapper with FAIL_ON_UNKNOWN_PROPERTIES false during error handling (#253) 2024-01-25 09:02:39 -05:00
Mark Pollack
593d7f23df Fix TextToImage integration tests
* Create StyleEnum for StabilityAI prompt options.
* Add copyright header and javadoc to StabilityAI classes
2024-01-24 15:55:46 -05:00
Christian Tzolov
c5bca45007 Fix failing IT test 2024-01-24 21:33:55 +01:00
Mark Pollack
243cef976c Abstract API for AI model clients
* An abstract API for AI model clients
 * Providing portable client request options while still allowing vendor specific options when required.  Implemented only for StabilityAI/OpenAI ImageClient
 * Support for text->image for openai and stabilityai.

  Partial fix for #27 :  Text To Image and Fixes #266 and Fixes #261
2024-01-24 19:53:33 +01:00
Christian Tzolov
08fa0e393c Prevent OpenAi retry on http client errors such as rate-limit or wrong authentication 2024-01-14 23:04:17 +01:00
Christian Tzolov
abbd911f69 fix test 2024-01-14 20:46:50 +01:00
Christian Tzolov
7262afb14d Capitalize the enumeration names
Resolves #208
2024-01-14 20:36:14 +01:00
Christian Tzolov
8fa0af553c Clarify the OpenAi properties
Add dedicated property classes for the Chat and the Embedding models and use a common connection properties for both:
  - OpenAiConnectionProperties (baseUrl, apiKey) with prefix spring.ai.openai.*.
  - OpenAiChatProperties (model, temperature) with prefix spring.ai.openai.chat.
  - OpenAiEmbeddingProperties (model) with prefix spring.ai.openai.embedding.*
 Additionally the OpenAiChatProperties and OpenAiEmbeddingProperties can optionally override the OpenAiConnectionProperties
 so that we can use the Chat model from one Provider and the Embedding model from another.

 Resolves #229
2024-01-13 22:41:24 +01:00
Mark Pollack
408d75e0d4 Ollama and Titan Embedding Client makes individual calls to embed Document collection
Fixes #218
2024-01-11 12:15:52 -05:00
Mark Pollack
85e3e0015e Remove client and embedding from package name for ChatClient and EmbeddingClient implementations
Moved up one package level the following classes
* org.springframework.ai.huggingface.client.HuggingfaceChatClient
* org.springframework.ai.openai.client.OpenAiChatClient and org.springframework.ai.openai.embedding.OpenAiEmbeddingClient
* org.springframework.ai.vertex.generation.VertexAiChatClient and org.springframework.ai.vertex.embedding.VertexAiEmbeddingClient

Fixes #211
2024-01-11 12:00:36 -05:00
Mark Pollack
b35c71061e Remove VectorStoreRetriever interface and retriever package 2024-01-11 10:52:28 -05:00
Mark Pollack
a48a6d9611 Change package name for PostgresML and Transformers
Fixes #133
2024-01-11 10:11:53 -05:00
Omkar Shetkar
0b87df07e5 Fix Bedrock chat model enum names consistency
- doc update
 - fix code formatting

 Resolves #231
2024-01-09 12:36:17 +01:00
Christian Tzolov
2f89124350 minor README fix 2024-01-09 10:10:39 +01:00
Mark Pollack
99d391b10e Add more documentation for ChatClient implementations
* OpenAI
* Azure OpenAI
* Bedrock
* Bedrock Anthropic Claude
* Bedrock Meta Llama2
* Ollama
2024-01-07 15:51:29 -05:00
Christian Tzolov
0ccf327806 Refactor Azure OpenAi
- Clean the AzureOpenAiChatClient and add support  for StreamingChatClient.
 - Streamline the AzureOpenAiEmbeddingClient.
 - Move the AzureOpenAiChatClient and AzureOpenAiEmbeddingClient to top org.sf.ai.azure.opoenai package.
 - Add ITs for AzureOpenAiChatClient and AzureOpenAiEmbeddingClient
 - Fix the AzureOpenAiAutoConfiguration
   - Split property file into AzureOpienAiConnectionProperties, AzureOpenAiChatProperties
     and AzureOpenAiEmbeddingProperties.
   - Add ITs for the auto-configuration
 - Add improve package structure
 - Add README docs
 - fix failing test
 - update to use Azure Deployment for CI
2024-01-02 12:18:20 -05:00
Christian Tzolov
c8de949123 update azure-openai do beta6 and resolve the compatibility issues 2023-12-22 11:55:38 +01:00
Christian Tzolov
aebfd719a7 Remove the obsolate okhttp and the related interceptor
The OpenAiApi, returns the HTTP headers that can be intropsect for metadata
 with the help of OpenAiResponseHeaderExtractor.
 No need for http interception nor for joining by ID.
2023-12-22 08:49:20 +01:00
Christian Tzolov
6cec33b4bd update the ollama chat api diagram 2023-12-21 15:41:03 +01:00
Christian Tzolov
98281ad1ef Rename AiClient/AiStreamingClient name prefixes to ChatClient/StreamingClient
- fix all class names with AiClient or AiStreamingClient name prefixes.
  - fix all variables or method name prefixes.
  - fix the javadocs, readmes and refference documentation.
2023-12-21 14:54:14 +01:00
Christian Tzolov
b49e84f5e2 fix javadoc issue 2023-12-21 14:22:48 +01:00
Christian Tzolov
8d112e30d8 Add flexible Ollama Options handling
Add OllamOptions that can be used as a builder (withX) and spring propererites (e.g. getX/setX).
 - prvides strongly typed properties.
 - the 'OllamaOptsion#toMap()' converts the options into Map<String, Object>.
 - Add OllamaEmbeddingAutoConfiguraiton#options property of type OllamaOptions.
 - Add OllamaChatAutoConfiguraiton#options property of type OllamaOptions.
 - Factor out the baseUrl property into a standalone OllamConnectionProperties shared
   between the Chat and Embedding autoconfigurations.
 - Fix affected unit/IT tests.
2023-12-21 13:46:11 +01:00
Omkar Shetkar
dd64a50d2f Merge SimplePersistentVectorStore and InMemoryVector store to be SimpleVectorStore
- Doc updates

Fixes  #146
2023-12-20 15:48:34 -05:00
Christian Tzolov
9ab857a8ab Add full support for Ollama AI models
- Implement a native client (OllamaApi) to leverage chat/streaming and embedding endpoints.
 - Add a OllamaChatClient implementing the ChatClinet and StreamingChatClinet interfaces.
 - Add a OllamaEmbedding clinent that impl. the EmbeddingClinet interface.
 - Add AutoConfiguraitons with properties for the chat and the embedding clients.
 - Add unit and ITs for the OllamaApi, OllamaChatClient, OllamaEmbeddingClient, and related auto-configuraitons.
 - Remove the old ollama impl. classes and tests.
 - minor fixes to the bedrok test methods names.
2023-12-20 14:11:17 -05:00
Mark Pollack
1a8fcac206 fix failing tests due to directory structure changes 2023-12-19 12:46:43 -05:00
Mark Pollack
82fe510b39 Moved Maven modules from top level directory and embedding-clients subdirectory to all be under a single models directory.
Rename artifact ID of

* `transformers-embedding` to `spring-ai-transformers`
2023-12-19 12:22:02 -05:00