Commit Graph

1020 Commits

Author SHA1 Message Date
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
Christian Tzolov
66e4b8868f Add ObservationRegistry support to ChatClient
- Implement observable chat responses in DefaultChatClient
 - Add ChatClientObservationContext and related classes for metrics
 - Update ChatClient and builder methods to support ObservationRegistry
 - Enhance RequestResponseAdvisor with getName() method
 - Add ChatClient streaming observability support
 - Introduce ChatClientObservationDocumentation for metric key names
 - Create DefaultChatClientObservationConvention for implementing conventions
 - Add ChatClientInputContentObservationFilter for optional input content logging
 - Update ChatClientAutoConfiguration to include new observation components
 - Extend ChatClientBuilderProperties with observation configuration options
 - Add unit tests for new observation classes and configurations
 - Update AiOperationType and AiProvider enums with new values
 - Implement safeguards and warnings for sensitive data in observations

 Resolves #1206
2024-08-11 18:26:53 +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
TarasVovk669
866b262cdd Add refusal field to ChatCompletionMessage and related classes
- Updated OpenAiChatModel, OpenAiApi, and OpenAiStreamFunctionCallingHelper to include the `refusal` field in metadata.
- Adjusted constructors and methods to handle the new `refusal` attribute.
- Modified related tests to account for the new `refusal` field.
- Add the refusal field value to the Spring AI AssistantMessage metadata

Resolves #1178
2024-08-08 19:19:09 +02:00
Dave Syer
e2c5208e3e Correct some grammar typos with 'latter' 2024-08-08 13:08:24 +02:00
Dariusz Jędrzejczyk
478f180297 Add OpenAiChatModel stream observability
Integrated Micrometer's Observation into the OpenAiChatModel#stream reactive chain.

Included changes:
 - Added ability to aggregate streaming responses for use in Observation metadata.
 - Improved error handling and logging for chat response processing.
 - Updated unit tests to include new observation logic and subscribe to Flux responses.
 - Refined validation of observations in both normal and streaming chat operations.
 - Disabled retry for streaming which used RetryTemplate - should use .retryWhen operator as the next step.
 - Added an integration test.

Resolves #1190

Co-authored-by Christian Tzolov <ctzolov@vmware.com>
2024-08-08 13:05:28 +02:00
Christian Tzolov
86348e4bb4 Revert part of the WeaviateContainer version updates
Due to ITs failures revert some of the WeaviateContainer changes made in #1172
2024-08-08 12:58:43 +02:00
Thomas Vitale
08ccc10a16 Streamline EmbeddingOptions
* Add model and dimensions to option abstraction
* Use abstraction in Observations directly instead of dedicated implementation
* Clean-up the merge of runtime and default embedding options in OpenAI

Relates to #gh-1148

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2024-08-08 11:35:08 +02:00
Thomas Vitale
17ba1fc3ba Streamline ImageOptions
* Add style to option abstraction
* Use abstraction in Observations directly instead of dedicated implementation
* Clean-up the merge of runtime and default image options in OpenAI and Stability AI

Related to #1148

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2024-08-07 10:19:08 +02:00
Eddú Meléndez
80007d4d6c Update testcontainers version to 1.20.1
Weaviate module contains the wait strategy.
2024-08-07 09:25:58 +02:00
Thomas Vitale
8784dee16f Update convention for chat finish reason in LLM observations
Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2024-08-07 09:25:06 +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
Christian Tzolov
d00cbe7c03 Update Ollama docker image version 2024-08-04 12:53:30 +02:00
Thomas Vitale
9a8a133d93 Fix NPE in OpenAiUsage
Fix gh-1152

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2024-08-04 11:29:06 +02:00
Christian Tzolov
4cacbe8468 Refactor Ollama embedding model implementation
- Update OllamaEmbeddingModel to support batch embedding requests
- Rename EmbeddingRequest/Response to EmbeddingsRequest/Response
- Add truncate option to control input truncation
- Update documentation and tests for new embedding API
- Remove deprecated withModel and withDefaultOptions methods
- Adjust default values for various Ollama model options
- Include response medata with response model name

Resolves #1158
2024-08-04 11:21:45 +02:00
Christian Tzolov
3978e8ecc2 Enhance OpenAI Authentication and Configuration
- Add org-id and project-id properties with unified merging logic
- Update autoconfig and docs for all OpenAI models
- Introduce OpenAiChatOptions#httpHeaders option
- Add integration test for httpHeaders and update docs

Resolves #1141
2024-08-03 22:30:37 +02:00
Thomas Vitale
4c1347db17 Fix autoconfig dependency when metrics enabled
Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2024-08-02 22:25:56 +02:00
Thomas Vitale
12cf38a669 Make MeterObservationHandler conditional on MeterRegistry bean
Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2024-08-02 22:11:47 +02:00
Soby Chacko
8348e92944 Minor code cleanup in EmbeddingOptions 2024-08-02 14:44:58 -04:00
Thomas Vitale
6bdb395686 Initial observability for Spring AI
* Observation APIs for chat, embedding and image models
* Conventions based on OpenTelemetry Semantic Conventions for GenAI
* Instrumentation for OpenAI chat, embedding, and image models
* Autoconfiguration for observability for OpenAI

Fixes gh-953

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2024-08-01 22:25:43 +02:00
Christian Tzolov
a077e1b952 patch for 3f19c4a6e5 2024-08-01 17:40:28 +02:00
Christian Tzolov
3f19c4a6e5 Add OpenAI paralel funciton call option
Resolves #1143
2024-08-01 17:11:11 +02:00
Christian Tzolov
4bb6f6ed44 docs: Updater ollama chat completion diagram 2024-08-01 09:33:46 +02:00
Christian Tzolov
ec3929301e Docs:Add ollama openai API diagram 2024-07-31 19:47:52 +02:00
Soby Chacko
c83630313d Docs cleanup in chat memory section 2024-07-31 13:28:06 -04:00
Christian Tzolov
52ce565472 Add Groq tool calling docs 2024-07-31 16:27:43 +02:00
Christian Tzolov
0aaab0267d Additional Groq documentation improvements 2024-07-31 14:13:01 +02:00
Christian Tzolov
86ab5926ce Improve Groq documentation 2024-07-31 12:54:32 +02:00
kamosama
7c800f35b8 Fix a FunctionCallback inside a container that pollutes the global model's ChatOptions
The autoconfiguration adds the FunctionCallbacks directly to the model's ChatOptions,
 which results in the FunctionCallback being included in the request each time it is called.

 The modification registers the container's FunctionCallback directly to the model's functionCallbackRegister
 using the parent AbstractToolCallSupport constsructor.

 Replace the handleFunctionCallbackConfigurations by simplified runtimeFunctionCallbackConfigurations.

Co-authored-by Christian Tzolov <ctzolov@vmware.com>
2024-07-30 20:11:14 +02:00
Soby Chacko
ce5961348b GH-868: Fix inconsistency in autoconfigured beans
* Fixing auto configured beans where they are missing `@ConditionalOnMissingBean`
* Add `matchIfMissing` on `@ConditionalOnProperty` where it is missing with value `true`

Resolves https://github.com/spring-projects/spring-ai/issues/868
2024-07-30 14:15:50 +02:00
David
3e920faede Bump org.springframework.cloud:spring-cloud-function-context from 4.1.1 to 4.1.3
Updated version resolves CVE-2024-22271
2024-07-30 13:05:37 +02:00
Christian Tzolov
d875d48bd3 Streamline Azure OpenAI Function Calling 2024-07-30 11:52:44 +02:00
Christian Tzolov
6978e8f111 Streamline the VertexAI Gemini Function Calling
- Align with AbstractToolCallSupport
2024-07-30 10:46:38 +02:00
Christian Tzolov
14b5397ca0 Streamline the MistralAI Function Calling
Align with the parent AbstractToolCallSupport and remove the redundant code.
2024-07-30 10:43:39 +02:00
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
zlzzlzz2l
55347056b0 Docs: Edit typo
- modify streeming to streaming
2024-07-26 17:07:48 +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
554fbcd305 minor docs improvment 2024-07-25 11:53:58 +02:00