Commit Graph

1212 Commits

Author SHA1 Message Date
Christian Tzolov
2cd85a0781 Remove unnecessary resource cleanup in TransformersEmbeddingModel 2024-10-08 14:38:47 +02:00
Christian Tzolov
3367ebd897 Prevent double-closing of tensors in TransformersEmbeddingModel 2024-10-08 14:30:08 +02:00
Mark Pollack
e30105e5fb minor test fixes 2024-10-08 14:26:35 +02:00
Christian Tzolov
d50e7e2a8d Adjust Bedrok reponse API models 2024-10-08 13:50:34 +02:00
GR
d4ab868921 Add observability to QianFan embedding model 2024-10-08 13:34:32 +02:00
Christian Tzolov
13709f9542 Add builder pattern and order parameter to advisors
- Introduce builder pattern for MessageChatMemoryAdvisor, PromptChatMemoryAdvisor,
   QuestionAnswerAdvisor, SafeGuardAdvisor, and VectorStoreChatMemoryAdvisor.
 - Add 'order' parameter to control advisor execution priority
 - Modify constructors to include the new 'order' parameter
 - Update AbstractChatMemoryAdvisor to support the new 'order' parameter
 - Update docs
2024-10-08 13:30:58 +02:00
Mark Pollack
300561af53 Update to use Boot 3.3.4 2024-10-08 12:54:40 +02:00
Mark Pollack
e712f6cc77 Udpate Spring AI Built-in Advisors documentation 2024-10-08 12:39:04 +02:00
Christian Tzolov
8e792034d9 Enhance SafeGuardAdvisor with customizable failure response
- Add customizable failure response instead of empty result
 - Add order parameter for advisor prioritization
 - Implement default values for failure response and order
 - Introduce builder pattern for flexible configuration

 Resolves #1393
2024-10-08 12:33:29 +02:00
Christian Tzolov
7ed73e8478 Improve resource management in TransformersEmbeddingModel
- Prevent potential resource leaks
 - Wrap OnnxTensor creation in try-with-resources block
 - Explicitly close inputIds, attentionMask, and tokenTypeIds tensors
 - Close OrtSession.SessionOptions() in afterPropertiesSet
 - Add javadoc

Resolves #1427
2024-10-08 12:30:46 +02:00
Mark Pollack
d96d0b53f6 Add docs for FactCheckingEvaluator 2024-10-08 12:21:52 +02:00
Christian Tzolov
10193431f6 Observability instrumentation for VertexAI Text Embedding 2024-10-08 11:20:08 +02:00
努力的小雨
82a69dc3a3 Update milvus.adoc
error description
2024-10-08 10:56:59 +02:00
John Blum
3738c38b66 Cleanup grammar in documentation
* Fixes grammar in (Ollama) Function Calling.
* Fixes grammar in ETL Pipeline.
* Fixes grammar in Vector Databases.

Closes #1494
2024-10-08 10:56:29 +02:00
Christian Tzolov
d71ca0e68e Add observability support to TransformersEmbeddingModel
- Integrate ObservationRegistry and EmbeddingModelObservationConvention
 - Update TransformersEmbeddingModel to use observations
 - Add TransformersEmbeddingModelObservationTests
 - Update TransformersEmbeddingModelAutoConfiguration for observation support
 - Add ONNX to AiProvider enum
2024-10-08 10:48:48 +02:00
GR
7bd8a17d33 Add observability to zhipu chat model 2024-10-08 10:38:18 +02:00
GR
6203325f30 Add observability to qianfan chat model 2024-10-08 10:33:58 +02:00
GR
1606383704 Add observability to moonshot chat model 2024-10-08 00:40:27 +02:00
GR
ee7d2b2556 Add observability to minimax chat model
- add observability to minimax embedding model
- fix chat web search result error
- fix minimax auto configuration
2024-10-08 00:24:22 +02:00
Soby Chacko
bac002bf83 Observation for Vertex gemini chat model streaming operation
- Adding observability for Vertex Gemini chat model streaming call
- Updating auto-configuration for gemini chat model with the observability components
- Integration test for streaming observability
2024-10-08 00:14:47 +02:00
Mark Pollack
06392f90cb Update azure embedding test not to set dimensions 2024-10-08 00:10:46 +02:00
Christian Tzolov
6f39704d46 Extend observation support to Azure OpenAI models (#1491)
- Implement observation instrumentation for AzureOpenAiEmbeddingModel
 - Create AzureOpenAiEmbeddingModelObservationIT for integration testing
 - Update AzureOpenAiAutoConfiguration to support observation
 - Introduce ObservationRegistry and observation conventions
2024-10-07 17:43:13 -04:00
Soby Chacko
0763d78fef Add observability for the regular imperative call in VertexAi Gemini chat model
- Integrate ObservationRegistry for instrumentation in VertexAiGeminiChatModel's non-streaming call
- Add ChatModelObservationContext and related classes for observation
- Refactor createGeminiRequest method to support runtime options for imperative calls
- Implement observation for non-streaming chat operations in VertexAiChatModelObservationIT
- Add VertexAiGeminiConstants class for provider name

This commit enhances the VertexAiGeminiChatModel with observability features
for the non-streaming, imperative call() method. It allows for better
monitoring and instrumentation of synchronous chat operations. The changes
include refactoring to improve runtime option handling for these calls and
adds integration tests for the new observability features.
2024-10-07 23:25:40 +02:00
Christian Tzolov
9678ea53e8 Fix NPE in a test fixture 2024-10-07 20:48:10 +02:00
Mark Pollack
4b95dfc2ef Refine prompt for strict comma-separated list output
Improve clarity of instructions for model responses. The changes:

- Specify no leading or trailing text in the output
- Reword for more direct and unambiguous instructions

Fixes #718
2024-10-07 18:58:32 +02:00
Mark Pollack
64b147e699 Restructure OpenAI and AzureOpenAI ChatClientITs
- Use List<ChatResponse> to better examine the full response
2024-10-07 17:29:11 +02:00
Mark Pollack
22a61548ac Fix Keyword extractor test as chatgpt's response changed 2024-10-07 16:25:19 +02:00
Christian Tzolov
38082de0f8 Refactor FunctionCallback API to use ToolContext instead of Map<String, Object>
- Replaced `Map<String, Object>` with `ToolContext` in the `FunctionCallback`, `AbstractFunctionCallback`, and related classes.
 - Updated all BiFunction definitions to use `ToolContext` as the second parameter,
   enhancing the clarity and structure of the tool context management.
 - Modified `FunctionCallbackWrapper` and `FunctionCallbackContext` to adapt to the new `ToolContext` parameter.
 - Adjusted the handling of tool context in the documentation and test classes.
 - Updated relevant test cases to reflect the API changes and modified the function handling logic to ensure consistency.
2024-10-07 16:15:55 +02:00
Mark Pollack
662afdf46e Update asciidoc table in Azure OpenAI properties documentation
- Add description for spring.ai.azure.openai.custom-headers property

Fixes #1434.
2024-10-07 14:32:37 +02:00
Eddú Meléndez
a987e0305a Add new FactCheckingEvaluator for grounded factuality checking
- Introduce FactCheckingEvaluator class for LLM response validation
- Implement evaluation logic using ChatClient for fact-checking
- Add comprehensive JavaDoc explaining the evaluator's purpose and usage
- Reference Bespoke-Minicheck model for efficient implementation options
- Include links to Ollama blog post and MiniCheck research paper
- Distinguish from 'closed book' scenario testing in documentation

This new evaluator enables detection and reduction of hallucinations
in LLM outputs by checking claims against provided context. It provides
a foundation for implementing advanced fact-checking methodologies in
Spring AI applications.

See https://ollama.com/blog/reduce-hallucinations-with-bespoke-minicheck
2024-10-07 14:07:12 +02:00
Bruno Oliveira
78073c64ea Update bedrock-cohere-embedding.adoc to fix an incorrect description 2024-10-07 11:52:36 +02:00
Christian Tzolov
4e7e4cf2b5 Add tool context support to ChatClient and related classes
- Introduce toolContext to ChatClient, DefaultChatClient, and AdvisedRequest
 - Add methods to set and manage toolContext via the FunctionCallingOptions
 - Update tests to include toolContext in relevant scenarios
 - Implement toolContext handling in function calling options
2024-10-07 11:50:41 +02:00
Mudabir Hussain
2090826656 Fix NullPointerException with Ollama + tool calls
Fixed #1459
2024-10-07 11:48:40 +02:00
Thomas Vitale
6e62ff7d83 Add Cloud Bindings for Mistral AI
* Introduce Cloud Bindings support to configure the Mistral AI integration
* Update the Cloud Bindings documentation accordingly
2024-10-07 10:04:51 +02:00
ktm
2babb2a878 Add JSON Pointer support to JsonReader
This enhancement allows users to specify a JSON Pointer to extract
specific parts of a JSON document when reading. Key changes include:

- New get(String pointer) method in JsonReader class
- Updated JsonReaderTests with pointer-based extraction tests
- Added documentation for JSON Pointer usage in etl-pipeline.adoc

This feature enables more flexible parsing of complex JSON structures,
allowing users to easily target nested data for extraction.
2024-10-06 23:10:24 +02:00
John Blum
89487e3565 Optimze imports in ImageResponseMetadata.
* Make the Long created field final.
* Delegate the default constructor to ImageResponseMetadata(:Long) passing System.currentTimeMillis().
2024-10-06 22:52:57 +02:00
John Blum
aa4502896d Correct grammar in the Image Model API doc
Closes #1454
2024-10-06 22:50:58 +02:00
Fu Cheng
ae743f98a5 Enhance ChromaVectorStore initialization and add test for disabled schema
- Improve ChromaVectorStore to throw exception on missing collection with disabled schema
 - Add test case to verify exception is thrown when collection doesn't exist and schema init is false
 - Correctly set Chroma collection id when initializeSchema set to false

 Co-authored-by: Christian Tzolov <ctzolov@vmware.com>
2024-10-06 22:46:22 +02:00
dafriz
b1377d194d Make ElasticsearchVectorStoreAutoConfig class public
This change allows the ElasticsearchVectorStoreAutoConfiguration
class to be excluded, enabling custom configurations. It brings
consistency with other vector store auto-configuration classes.
2024-10-06 22:44:26 +02:00
Hyune-c
e12372171b Fix anthropicApi visibility in AnthropicChatModel 2024-10-06 22:41:23 +02:00
inpink
5431bdd956 Include index name in OpenSearch similarity search
- Resolved issue where index name was not being sent during
  similaritySearch
- Updated similaritySearch method to include index in the SearchRequest
- Implemented test to verify documents can be added and retrieved from
  two different indices using separate OpenSearchVectorStore instances
- Ensured similarity search results are correctly returned for the
  respective indices

Fixes #885
2024-10-06 22:39:14 +02:00
Christian Tzolov
8bea302b11 Add missing observation and merics names to the docs 2024-10-06 22:01:50 +02:00
Thomas Vitale
60e36c3b55 Update Observability documentation
* Update attributes
* Add more information on optional attributes and risks
* Include documentation for events.

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2024-10-06 19:19:58 +02:00
Thomas Vitale
012f07c97b Optimize Testcontainers config for VectorStores
* Unify image definition for vector stores in vector-store modules

* Unify image definition for vector stores in spring-ai-testcontainers module

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2024-10-06 19:18:05 +02:00
Christian Tzolov
eb2deba9cb Clarify how advisors are ordered in the reference doc 2024-10-06 16:40:54 +02:00
Thomas Vitale
1ee90944de Improve chat client and advisor observations
* Make ChatClient and Advisor observation logic null-safe
* Simplify naming for Advisor observations
* Include high-cardinality attributes only if a value is present
* Fix condition to include system test to chat client observations
* Add Advisor order information to context
* Streamline usage of enums and utils to reduce hard-coded/duplications
* Fix pending Chroma integration test

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2024-10-06 16:38:18 +02:00
Soby Chacko
8ea56329ac Adding observability for AzureOpenAiChatModel streaming 2024-10-06 15:37:15 +02:00
Thomas Vitale
21504a6296 Keep model metric attributes fixed for Prometheus
Unlike other metrics implementations supported by Micrometer, when using the Prometheus integration, all metric attributes are supposed to have a value, or else the related metrics are dropped.

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2024-10-06 15:36:49 +02:00
Thomas Vitale
50e11e3f46 Improve optional values handling in vector store observations
Vector store observations support several key-value pairs, coming from the Spring AI abstractions. Currently, whenever a value is not available (either because not configured by the user or not supported by the vector store provider), span/metrics attributes are generated anyway with value none.

That causes several issues, including an unneeded increase in time series, challenges in alerting/monitoring (especially for integer/double attributes that suddenly are populated with a string), and non-compliance with the OpenTelemetry Semantic Conventions (according to which, attributes should be excluded altogether if there's no value).

This pull request changes the conventions for vector store observations to exclude the generation of span/metrics attributes for optional values which don't have any value.

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2024-10-06 15:36:18 +02:00
Thomas Vitale
3b1c68ac10 Improve optional values handling in chat model observations
Chat model observations support several key-value pairs, coming from the Spring AI abstractions.
Currently, whenever a value is not available (either because not configured by the user or not supported by the model provider), a span/metrics is generated anyway with value none.
That causes several issues, including an unneeded increase in time series, challenges in alerting/monitoring (especially for integer/double attributes that suddenly are populated with a string), and incompliance with the OpenTelemetry Semantic Conventions (according to which, attributes should be excluded altogether if there's no value).
This pull request changes the conventions for chat model observation to exclude the generation of span/metrics attributes for optional values which don't have any value.

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2024-10-05 23:55:16 +02:00