Commit Graph

507 Commits

Author SHA1 Message Date
Soby Chacko
9aee4aac4c GH-876: stream.content() swallowing blank space
* Fixing an issue where calling stream.content() method swallows leading
  blank spaces.

Resolves https://github.com/spring-projects/spring-ai/issues/1089
Resolves https://github.com/spring-projects/spring-ai/issues/1089
2024-07-29 17:08:16 +02:00
Christian Tzolov
aa18a67321 Document how to use Mistral AI over Spring AI OpenAI API.
- Add a related integration test: MistralWithOpenAiChatModelIT

Resolves #1134
2024-07-29 16:08:08 +02:00
Christian Tzolov
1c0c77b4eb Remove a redundant code line 2024-07-27 23:42:00 +02:00
Christian Tzolov
0c4d6ab753 Improve Ollama docs 2024-07-27 18:47:51 +02:00
Mark Pollack
27354cd616 Fix possible npes in openai response processing 2024-07-26 11:44:44 -04:00
Thomas Vitale
78cd3e9ad4 Update Ollama APIs and fix multimodality test
* Add doneReason to ChatResponse and update OllamaChatModel accordingly
* Add missing descriptions to Ollama options
* Consolidate Ollama Testcontainers image setup
* Fix multimodality Ollama test
* Add new models to enum: llama 3.1, mistral-nemo, moondream.

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2024-07-26 17:41:15 +02:00
Christian Tzolov
6363352b82 Improve Anthropic function calling
- factor out the common funciton calling logic form AnthropicChatModel to the AbstractToolCallSupport.
 - improve the AbstractToolCallSupport isToolCall to handle OpenAi and Anthropic.
 - fix an issue with the function calling streaming aggreagation leading to lost usage statistics.
 - small code improvements for OpenAiChatModel.
2024-07-25 18:13:26 +02:00
Christian Tzolov
437ff74cad Deprecate the legacy Ollama generate API in favor of chat completion one 2024-07-25 09:49:23 +02:00
Christian Tzolov
b9593fe6f0 Remove redundant numGQA option from Ollama options 2024-07-25 09:29:29 +02:00
GR
5642521e74 fix: AbstractToolCallSupport wrong method name 2024-07-25 09:22:13 +02:00
Seol_JY
698a531dae Refactor ContentFormatTransformer for improved readability
- Extract Method
- Replace explicit instanceof checks and casting with pattern matching
- Change var to explicit type
2024-07-24 17:19:49 -04:00
Christian Tzolov
fc7ee87113 Fix javadoc 2024-07-24 23:16:38 +02:00
Geng
8936aac1e2 fix: QianFan role based chat model & unit tests (#1029) 2024-07-24 17:00:15 -04:00
Soby Chacko
4d41080d45 Integration test for OpenAI streaming completion 2024-07-24 16:32:15 -04:00
Christian Tzolov
d53876a624 Add Ollama Function Call support
- extend the OllamaApi with Tool, ToolCalls and Function and add Tool Role.
- make OllamaChatModel extend the AbstractToolCallSupport.
- extend the OllamaChatModel to convert the Spring AI messages to OllamaApi messages, including Tools.
- OllamaOptions implements FunctionCallingOptions.
- add OllamaApiToolFunctionCallIT for testing function calling.
- patch the AbstractToolCallSupport#isToolCall to take set of stop resons.
- add FunctionCallbackInPromptIT and FunctionCallbackWrapperIT function calling auto-configuration tests.
- extend OllamAutoConfiguration to support function calling registration.
- add function call tests to OllamChatAutoConfigurationIT.
- add OllamaWithOpenAiChatModelIT to OpenAi that uses the OpenAI API to call Ollama.
- move buildToolCallConversation and handleToolCalls to parent AbstractToolCallSupport.
- update Docs. add Ollama function call docs.
- update Ollama diagrams.

Resolves #720
2024-07-24 16:28:06 -04:00
Mark Pollack
ee696f33dd Make chat and embedding paths configurable
* Updated docs
* Minor code cleanup
2024-07-24 15:19:01 -04:00
Thomas Vitale
6c88654404 Consolidate retry config for OpenAI
Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2024-07-23 18:22:39 +02:00
Christian Tzolov
6270d627f1 ChatClient register functions with explicit input type
The Lambda functions do not retain the type information, so we need to provide the input type explicitly.

 Resolves #1052

 Co-authored-by: liuzhifei <2679431923@qq.com>
2024-07-23 15:01:05 +02:00
Christian Tzolov
03d1d50130 Update the Azure OpenAI Chat Model to defult to the gpt-4o 2024-07-22 14:51:11 +02:00
Piotr Olaszewski
0e97f9c579 Introduce AzureOpenAI transcription support
- Breaking changes: Classes from the org.springframework.ai.openai.metadata.audio.transcription package have been moved to the org.springframework.ai.audio.transcription package.
 - The AzureOpenAiAudioTranscriptionModel has been added to the auto-configuration.
 - The spring.ai.azure.openai.audio.transcription prefix was introduced for properties.
 - Introduces options properties which cover all of them (see: AzureOpenAiAudioTranscriptionOptions).
 - fix missing MutableResponseMetadata
 - add docs
 - adjust code to updated ResponseMetadata design
 - add test to AzureOpenAiAutoConfiguration
 - add missing AzureOpenAiAudioTranscriptionModel tests
2024-07-22 14:08:11 +02:00
Christian Tzolov
4392f1b72a Relax AbstractMessage parameter constrains. Remove jackson auto-module registrattion 2024-07-20 11:14:18 +02:00
Mark Pollack
5aafea872d Improve Message object hierarchy
- SystemMessage no longer has Media
- Add MediaContent interface
- Clear redundant code
2024-07-19 23:05:46 +02:00
dongfeng
92b06346fd Update enum to include OpenAI's GPT-4o-mini model 2024-07-19 13:05:04 +02:00
Christian Tzolov
5dc9480eea Anthropic: make the beta features header value configurable
- add new spring.ai.anthropic.beta-version property.
  - add ITs.

  Resolves #1068
2024-07-18 20:54:28 +02:00
Christian Tzolov
edf943ec97 Adjust tests 2024-07-18 19:39:43 +02:00
Christian Tzolov
018bb2c600 Ensure that ChatClient copies the input chatoptions
- introduce copy() method to the ChatOptions.
 - make sure that the DefaultChatClientRequestSpec takes a copy of the input chat options to prevent multation.
 - add a OpenAiChatClientMultipleFunctionCallsIT to reproduce the problem and verify the solution.

 Resolves #1064
2024-07-18 18:56:28 +02:00
Christian Tzolov
588082285a OpenAI ChatModel: handle null finish reasons responses 2024-07-18 15:04:21 +02:00
Thomas Vitale
40d8671f3e Improve new function calling strategy
- Streamline the Generation constructors

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2024-07-18 14:18:45 +02:00
Mark Pollack
97f443d615 Update to ResponseMetadata design
* Remove inheritance from HashMap
* No more subclasses per model provider
* Builder class for ChatResponse
* Fix the AbstractResponseMetadata#AI_METADATA_STRING parameter order
* ChatResponseMetadata ignore Null values.
2024-07-18 12:48:28 +02:00
Sinsy
c9a3e66f90 fix: test name error (#1035)
* fix: test name error

* fix: test name error
2024-07-17 11:07:30 +02:00
Christian Tzolov
feb036d2f6 Add high-level function calling support for Azure OpenAI
- follow the timostark advise to replace skip(1) by filter empty choices

 Resolves #613, #1042
2024-07-16 22:22:24 +02:00
Christian Tzolov
697a04b6d0 Moonshot: No Function Calling support verificaiton
Update the docs and tests to verify that currently Moonshot ChatModel does not
 support Function Calling.

 Related to #1058
2024-07-16 17:55:28 +02:00
Christian Tzolov
18cdeee092 Add high-level function calling support for Mistral AI 2024-07-16 16:18:16 +02:00
Johnny Lim
7c26c7bcdf Polish 2024-07-16 10:05:28 +02:00
Christian Tzolov
87dc3be739 Extend the CreateGeminiRequestTests for tool config tests 2024-07-16 10:00:01 +02:00
Chris Turchin
f07e3911dc Fix system messages handling issue
- re-assign the model on withSystemInstruction return.
 - deprecate the gemini-pro-vision model and replace the default model to gemin-pro-1.5
 - update docs.
 - improve system message handling implementation.

 Resolves #1030

Co-authored-by: Christian Tzolov <ctzolov@vmware.com>
2024-07-15 19:26:12 +02:00
Christian Tzolov
ee19ee1db9 Add high-level function calling support for Anthropic
- simplify and unify the AbstractToolCallSupport::executeFuncitons. Fix filed typos
 - remove old classes
2024-07-15 13:57:38 +02:00
Christian Tzolov
086117effa High-level API function calling support for VertexAI Gemini
- Refactor VertexAiChatModel's function calling handling to use Spring AI abstractions.
2024-07-15 12:24:42 +02:00
Thomas Vitale
fac38c5db8 Update tests for EmbeddingResponseMetadata (#1039)
Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2024-07-12 12:02:14 -04:00
Thomas Vitale
e601f14364 Add model name and token usage to EmbeddingResponseMetadata
- Moves these from free-text key/value pairs to interface
- Enables programmatic use for evaluation and observability

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2024-07-12 11:18:49 -04:00
Christian Tzolov
41eab270cb Refactor High-level API function calling support
- Add ToolCall to AssistantMessage.
 - Rename FunctionMessage to ToolResponseMessage and add id and name fields.
 - Refactor OpenAiChatModel's function calling handling.
 - Prompt copy now copies the AssistantMessage and ToolResponseMessage contents.

Other ChatModel implementations to adopt these changes in subsequent commits
2024-07-12 00:02:05 -04:00
吴博
28c0d24807 Updates to ZhiPuAi model
* Adjust chat api request options and add unit test

Fix options of zhipu ai chat model
2024-07-10 15:53:40 -04:00
Christian Tzolov
c70c20b79d Add VertexAI Embedding Model support
- add new spring-ai-vertex-ai-embedding project.
 - add VertexAiTextEmbeddingModel and VertexAiMultimodalEmbeddingMode with related options configuration classes.
 - add ITs
 - add auto-configuraiton and boot starters.
 - register to BOM.
 - add documentation.
 - add multimodal embedding documentation
 - extend the Embedding metdata so that it can keep references to the source document's data, Id, mediatype

 Resolves #1013
 Related to #1009
2024-07-10 15:36:13 -04:00
Christian Tzolov
61a56db98b Update Azure OpenAI to 1.0.0-beta.10 2024-07-09 13:08:42 +02:00
Christian Tzolov
dd22342c0c Improve ONNX Tansformer Embedding Model
- Fix model output name handling.
 - Improve documentation.
2024-07-09 11:21:53 +02:00
Christian Tzolov
f61ccdd09d Add Groq inference support via OpenAI client
- add dedicated groq chat page in the documentation.
   Explain how to re-configure the OpenAI client for accessing the Groq chat completion endpoint.
 - Doc: order the Chat and Embedding items in alphabetical order
 - Add Groq ITs.

 Resolves #996
2024-07-05 16:42:46 -04:00
Christian Tzolov
f171b0fa5e Handle OpenAiChatModel NPE for partially compatible OpneAI API such as the NVIDIA API 2024-07-03 16:14:42 +02:00
Christian Tzolov
d8be884cb1 Improve Anthropic Claude streaming handling
- add StreamEven API domain model for reliably parsing stream events.
 - add StreamHelper#mergeToolUseEvents to aggregate partial tool use jsons into a list of ContentBlocks.
 - add StreamHelper#eventToChatCompletionResponse to convert Flux<StreamEvents> into Flux<ChatCompletionResponse>.
 - Rename MediaContent -> ContentBlock, RequestMessage -> AnthropicMessage, ChatCompletion -> ChatCompletionResponse.
 - Improve tests and docs.
2024-07-02 23:36:25 +02:00
devholic22
3411e3e74d Add comments in OpenAiAudioSpeechModel
* Add comments in OpenAiAudioSpeechModel like OpenAiChatModel

* Remove duplicated word in OpenAiAudioSpeechOptions AudioResponseFormat comment
2024-07-02 11:43:52 -04:00
Mariusz Bernacki
f5b72242c0 Add Anthropic Claude streaming Function Calling support
Resolves #930
2024-07-02 10:28:31 +02:00