- 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
* 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>
- 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
- 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
- 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
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>
* 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>
* 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>
- 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
- 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
* 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>
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>
* 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
- 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.