Commit Graph

1453 Commits

Author SHA1 Message Date
GR
a3c0927c9b Add MiniMax chat option to mask sensitive information
This commit introduces a new boolean option 'maskSensitiveInfo' for
the MiniMax API model support in Spring AI. This feature allows users
to control whether sensitive information in the output is masked.

Relevant unit tests have been added to ensure proper functionality.

Resolves: #1216
2024-08-22 11:23:59 -04:00
Mark Pollack
9ecd9c0940 Add docs for Vector Store observability 2024-08-22 11:07:35 -04:00
Christian Tzolov
9587cb0dfb Add ChatClient input data section to Observability docs 2024-08-22 09:49:32 +02:00
Thomas Vitale
036093a42b Enhance vector store observability support
* Consolidate usage of “db.collection.name” attribute to track table name, collection name, index name, document name, or whatever concept a vector database uses to store data. Removed “db.index” that was use sometimes instead of “db.collection.name”. This usage is in line with the OpenTelemetry Semantic Conventions.
* Configure query response content to be included as a “span event” instead of a “span attribute” if the backend system supports that, similar to how we do for the model observations.
* Structure vector store observation attributes in dedicated enums, including one for the Spring AI Kinds to avoid hard-coding the same value in a lot of places. This follows the OpenTelemetry Semantic Conventions as much as possible. Also, adopt Spring usual non-null-by-default strategy as much as possible.
* Align vector store conventions to the chat model ones, and follow alphabetical order for values. This is particularly useful for the convention classes, for which the Micrometer performance of exporting telemetry data improves when key values are added already sorted to the context.
* Fix flaky test in Mistral AI.
* Improve Qdrant integration tests.

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2024-08-22 09:38:59 +02:00
Mark Pollack
99d679f232 Add documentation for Observability 2024-08-21 17:26:03 -04:00
Christian Tzolov
3b014db165 Add ChatClient Advisor Observability support
- Add advisor context, convetions and documentation
- Add ObservableRequestResponseAdvisor wrapper.
- Add Tests

Resolves #1258
2024-08-21 14:28:24 -04:00
Soby Chacko
f0771f0770 Fixing MongoDB vector store support test failures
Remove the requirement of MongoDB vector store auto-configuration only after `MongoDataAutoConfiguration`.
This enables the `MongoDBAtlasVectorStoreAutoConfiguration` to properly provide custom Mongo conversions.

In `MongoDBAtlasVectorStoreIT` and `MongoDbVectorStoreObservationIT` tests, properly provision the `MongoTemplate`
with custom conversions as these tests are not relying on auto-configuration.
2024-08-21 07:10:54 +02:00
Mark Pollack
dad30f06d9 Add ChatOptions to PromptTemplate create methods
Enable ChatOptions configuration when creating Prompts from Templates,

Co-authored-by: zhangqian9158 <zhangqian9158@users.noreply.github.com>
2024-08-20 18:19:14 -04:00
Vivek Alpeshbhai Sonani
528dc0438a Unit tests for Generation class 2024-08-20 15:37:43 -04:00
rivkode
1d6cce2419 Add JSON array handling to JsonReader
Enhance JsonReader to detect and process both JSON objects and arrays at
the root level. This update introduces type checking for the JSON root node
using JsonNode and leverages the Stream API to handle JSON arrays.

- Refactor parsing logic to support both JSON arrays and objects
- Rename variable: resourceArray to arrayResource for clarity
- Convert for-loop to Stream API for processing JSON keys
- Add additional tests to ensure proper array handling
2024-08-20 15:06:19 -04:00
wmz7year
32a4652aba Fix out of bounds exception in BedrockAnthropic3ChatModel
Handle the case where AnthropicChatResponse content is empty to prevent
an out of bounds exception. This ensures that the model behaves correctly
even when no content is returned in the response.
2024-08-20 14:55:47 -04:00
Mark Pollack
0f52ca510f Simply implementation of RelevancyEvaluator
Co-authored-by: Lee KyuHwun Lee-Kyuhwun@users.noreply.github.com
2024-08-20 14:46:27 -04:00
Soby Chacko
949f1ed4e8 Add Batching strategy for embedding documents
- When embedding documents, allow batching the documents using some criteria.
 - `BatchingStrategy` interface with a `TokenCountBatchingStrategy` implementation that uses
   the openai max input token size of 8191 as the default.
 - Add a default method in EmbeddingModel to embed document using this new batching strategy.
 - Change `MilvusVectorStore` to make use of this new batching API.
 - Adding unit tests for `TokenCountBatchingStrategy`.
 - Adding openai integration test to call the embed API that uses batching.

Resolves https://github.com/spring-projects/spring-ai/issues/1214

Other vector stores will be updated seperately
2024-08-20 14:08:06 -04:00
Christian Tzolov
7afc2b56a1 Disable MonogDB ITs due to #698 2024-08-20 16:19:25 +02:00
Christian Tzolov
e881fefc39 Add spring-ai-test to MongoDB pom 2024-08-20 13:41:21 +02:00
Christian Tzolov
4cc9a9ce4a Harden the WeaviateContainer initialization to prevent IT instability 2024-08-20 10:54:43 +02:00
Christian Tzolov
1465310cf0 Another OracleVectorStoreObservationIT test assertion fix 2024-08-20 10:09:17 +02:00
Christian Tzolov
a3f44872ee Fix OracleVectorStoreObservationIT bug 2024-08-20 09:27:08 +02:00
Christian Tzolov
93fa2bf45a Add observability support to existing vector stores
Add observability support to:
 - Cassandra
 - Chroma
 - Elasticsearch
 - Milvus
 - Neo4j
 - OpenSearch
 - Qdrant
 - Redis
 - Typesense
 - Weaviate
 - Pinecone
 - Oracle
 - Gemifire
 - MongoDB
 - HanaDB

 Add autoconfiguration obsrvability for the above vector stores.
 Add integration tests for all vector stores.
2024-08-20 01:37:45 -04:00
Thomas Vitale
3b7522b6c0 Model observability for Anthropic
Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2024-08-20 01:13:43 -04:00
Thomas Vitale
3fa102e78f Prompt content and completion as span events
Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2024-08-20 00:59:43 -04:00
Thomas Vitale
80fe5e4897 Model observability for Mistral
Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2024-08-20 00:36:31 -04:00
Christian Tzolov
46893b0a99 Add documentation for NVIDIA LLM API integration
Add NVIDIA LLM API - OpenAI Integration Test.
2024-08-19 21:53:20 +02:00
Seongmin Kim
58c292ab87 Remove unnecessary if statement in test code
* Remove unnecessary if statement in 'toolFunctionCall' test code from OpenAiApiToolFunctionCallIT
* Reformat using java-format plugin
2024-08-19 15:40:41 -04:00
uzhuraul
c2b6e85608 Fix OpenAiAudioSpeechOptions speed description
formatting
2024-08-19 15:26:41 -04:00
Thomas Vitale
10e1e13fa2 Add observability support for Ollama
- Improve ITs to reuse a single container across tests
2024-08-16 14:29:23 -04:00
KAMOsama
3bef5c12bf Remove redundant withRateLimit call from OpenAiChatModel.
The withRateLimit call is redundant as rateLimit is already handled conditionally elsewhere. Its removal helps simplify the code and improves maintainability.
2024-08-16 11:52:27 -04:00
Muthukumaran Navaneethakrishnan
6bd059a8b7 Fix IN/NOT IN filters for PgVector JSON queries
PgVectorFilterExpressionConverter was generating incorrect SQL for
IN and NOT IN filters with PostgreSQL JSON data types. This caused
BadSqlGrammarException errors when executing queries.

This change modifies the converter to generate correct SQL syntax
for these operations, ensuring compatibility with PostgreSQL's JSON
handling capabilities.

Why:
- Improves query reliability for PgVector stores
- Enables more complex filtering operations on JSON data
- Eliminates unexpected errors in query execution

Fixes #1179
2024-08-16 11:21:37 -04:00
Christian Tzolov
bc3f9acb86 Add observability support to VectorStore
Implementation:
- Introduce AbstractObservationVectorStore with instrumentation for add, delete, and similaritySearch methods
- Create VectorStoreObservationContext to capture operation details
- Implement DefaultVectorStoreObservationConvention for naming and tagging
- Add VectorStoreObservationDocumentation for defining observation keys
- Create VectorStoreObservationAutoConfiguration for auto-configuring observations
- Add VectorStoreObservationProperties to control optional observation content filters
- Update VectorStore interface with getName() method
- Modify PgVectorStore and SimpleVectorStore to extend AbstractObservationVectorStore
- Add vector_store Spring AI kind

Filters:
- Implement VectorStoreQueryResponseObservationFilter
- Add VectorStoreDeleteRequestContentObservationFilter and VectorStoreAddRequestContentObservationFilter

Enhancements:
- Update PgVectorStoreAutoConfiguration to support observations
- Add observation support to PgVectorStore's Builder
- Add VectorStoreObservationContext.Operation enum with ADD, DELETE, and QUERY options

Tests:
- Add tests for VectorStore context, convention, and filters
- Add VectorStoreObservationAutoConfiguration tests
- Add PgVectorObservationIT

Resolves #1205
2024-08-16 10:33:50 -04:00
Jerry
72369d515f Fix typos in openai-transcriptions.adoc (#1217) 2024-08-15 10:28:52 -04:00
Johnny Lim
2d6117b796 Fix typos (#1223) 2024-08-15 10:27:12 -04:00
Soby Chacko
a051978600 Fixing float[] type embedding on MongoDBAtlas vector store 2024-08-14 18:58:07 -04:00
Christian Tzolov
d538e00643 Replace the Embedding format from List<Double> to float[]
- Adjust all affected classes including the Document.
 - Update docs.

Related to #405
2024-08-13 11:53:08 -04:00
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