Commit Graph

1453 Commits

Author SHA1 Message Date
VictorZalevski
cd886437eb Improve usage field to include new properties
OpenAI's API returns additional token usage metrics that provide deeper
insight into API consumption. This adds support for:

- acceptedPredictionTokens: Tokens from accepted model predictions
- audioTokens: Tokens used for audio processing
- rejectedPredictionTokens: Tokens from rejected model predictions

These fields help track resource utilization and costs more accurately
by breaking down token usage by type. Added @JsonIgnoreProperties to
maintain compatibility with future OpenAI API additions.

Fixes warning logging in RetryUtils.SHORT_RETRY_TEMPLATE to reduce noise
in test output.
2024-11-06 14:53:17 -05:00
Mark Pollack
2a6f55a8c5 Use shorter retry intervals in tests
The DEFAULT_RETRY_TEMPLATE uses exponential backoff starting at 2s with max 3min
delay between retries, making tests run unnecessarily long. This change
introduces SHORT_RETRY_TEMPLATE with fixed 100ms backoff to speed up test
execution while preserving the same retry behavior and error handling.
2024-11-06 13:29:37 -05:00
Mark Pollack
0b4f90e8c0 wip 2024-11-06 13:15:16 -05:00
1993heqiang
4ad76506bf Fix etl-pipeline.adoc and prompt.adoc issues. 2024-11-06 13:03:39 -05:00
Mark Pollack
f111aaea04 Revert "Add support for Kotlin functions"
This reverts commit 9cf66333b5.
2024-11-06 12:58:52 -05:00
Christian Tzolov
3fbc310ff4 Allow null or empty userText if request contains Tool Response message
- Add a new test case for testing function call with advisor in BedrockConverseChatClientIT
- Add a new test case for testing tool proxy function call in OpenAiChatClientProxyFunctionCallsIT
- Remove unused model property from BedrockConverseProxyChatProperties
2024-11-06 18:20:29 +01:00
Ilayaperumal Gopinathan
cbdb578388 Fix javadoc for HTML elements 2024-11-06 11:09:24 +00:00
John Blum
c93c6fd5b9 Fix grammar and minor typos in documentation as well as Javadoc.
Closes #1652
2024-11-06 07:16:43 +00:00
Sébastien Deleuze
9cf66333b5 Add support for Kotlin functions
Add support for proper Kotlin functions handling
by adapting kotlin.jvm.functions.Function1 to
java.util.function.Function and kotlin.jvm.functions.Function2 to
java.util.function.BiFunction.

It also removes the dependency on Spring Cloud Function and
net.jodah:typetools which are replaced by leveraging
Spring Framework ResolvableType capabilities.

Added withInputType Kotlin extension

- Add a Kotlin extension function for
FunctionCallbackWrapper.Builder.withInputType allowing
to specify withInputType<T>() instead of
withInputType(T::class.java).

- Add Kotlin documentation
2024-11-05 17:26:04 -05:00
Ilayaperumal Gopinathan
298b71c35d Fix Document Upload workflow
- Generate Javadoc before aggregate
2024-11-05 17:41:07 +00:00
Ilayaperumal Gopinathan
f36af38fe8 Fix documentation upload workflow
- The JavaDoc API directory path shouldn't need an explicit 'api' in its path
2024-11-05 15:56:58 +00:00
Soby Chacko
66f58d2d70 Change default build setting to disable Checkstyle enforcement
- Disable project-wide Checkstyle checks to unblock development
- Add documentation for enabling Checkstyle locally
- Fix remaining checkstyle violations in current codebase

Fixes #1669
2024-11-05 10:43:38 -05:00
Ilayaperumal Gopinathan
cbef2d1600 Attempt to fix JavaDocs publish path 2024-11-05 14:08:40 +00:00
Christian Tzolov
d0312ba426 Add @JsonIgnore annotation to jsonSchema field in AI provider APIs
Add @JsonIgnore annotation to the jsonSchema field in Function classes across
multiple AI provider APIs (MiniMax, MistralAI, OpenAI, ZhiPuAI) to exclude
it from JSON serialization.
2024-11-05 12:56:23 +01:00
Christian Tzolov
fd8cac57bb Revert "Revert "Convert API records to POJOs and fix failing autconfig tests""
This reverts commit 3e9a3fd3b0.
2024-11-05 11:52:41 +01:00
Christian Tzolov
3e9a3fd3b0 Revert "Convert API records to POJOs and fix failing autconfig tests"
This reverts commit 4184af5341.
2024-11-05 10:00:57 +01:00
Nikolai Kulagin
d1b8fa30f9 Fix JsonReader example 2024-11-05 07:36:17 +00:00
CodingLuizy
d3afa63b38 Update pinecone.adoc
remove duplicate table row
2024-11-05 07:16:56 +00:00
jito
efc392394c Add Cosmos Vector Store configuration to AutoConfiguration imports (#1658)
Signed-off-by: jitokim <pigberger70@gmail.com>
2024-11-04 17:37:54 -05:00
Ilayaperumal Gopinathan
d44a6aff7c GH-924 Remove PaLM API support
https://github.com/spring-projects/spring-ai/pull/1664

  - As a follow up to decommission the PaLM API, the PaLM API support is removed.
  - Remove the model and vector store classes
  - Remove the documentation entries
  - Reference: https://ai.google.dev/palm_docs/deprecation

Resolves #924
2024-11-04 15:22:50 -05:00
周波
5a90beebac fix(milvus): doSimilaritySearch to use the databaseName
- The doSimilaritySearch method did not pass the databaseName parameter in milvus 2.3.4 and before, resulting in the use of the default database; The current milvus upgrade to 2.3.5 supports passing the databaseName parameter
    - Update doSimilaritySearch to set the database name from the Milvus configuration
2024-11-04 13:40:10 +00:00
Ilayaperumal Gopinathan
cdb590338c Fix supported vector store list
- Add Azure Cosmos DB and GemFire
2024-11-04 13:02:39 +00:00
Jemin Huh
37598b198d Fix Vector Database providers list
Signed-off-by: Jemin Huh <hjm1980@gmail.com>
2024-11-04 13:01:00 +00:00
jitokim
166e3d5f37 Fix incorrect logger class initialization
Signed-off-by: jitokim <pigberger70@gmail.com>
2024-11-04 12:53:59 +00:00
Ilayaperumal Gopinathan
8b4df9075f Re-enable javadoc error check on the CI 2024-11-04 12:15:09 +00:00
Ilayaperumal Gopinathan
8becbbba3b Fix javadoc errors at BedrockProxyChatModel
- Removed invalid parameters
2024-11-04 12:08:44 +00:00
Mark Pollack
08a007f234 Disable Gemfire Vector Store integration tests
Test are not reliable, often get the error

Error:  Failed to execute goal on project spring-ai-gemfire-store: Could not resolve dependencies for project org.springframework.ai:spring-ai-gemfire-store:jar:1.0.0-SNAPSHOT: Could not transfer artifact dev.gemfire:gemfire-testcontainers:jar:2.3.0 from/to maven-central (https://repo.maven.apache.org/maven2/): transfer failed for https://repo.maven.apache.org/maven2/dev/gemfire/gemfire-testcontainers/2.3.0/gemfire-testcontainers-2.3.0.jar, status: 429 -> [Help 1]
2024-11-03 21:45:05 -05:00
Mark Pollack
05f4eb0520 Ignore javadoc errors in GitHub CI action 2024-11-03 19:47:44 -05:00
Mark Pollack
ff41a1a529 Disable OracleVectorStore and Ollama IT tests 2024-11-03 18:55:09 -05:00
Christian Tzolov
0d2d4b7385 Add Bedrock Converse API chat model support
Introduces support for Amazon Bedrock Converse API through a new BedrockProxyChatModel
implementation. This enables integration with Bedrock's conversation models with features
including:
- Support for sync/async chat completions
- Stream response handling
- Tool/function calling capabilities
- System message support
- Image input support
- Observation and metrics integration
- Configurable model parameters and AWS credentials

Adds core support classes:
- BedrockUsage: Implements Usage interface for token tracking
- ConverseApiUtils: Utility class for handling Bedrock API responses including:
  - Tool use event aggregation and processing
  - Chat response transformation from stream outputs
  - Model options conversion
  - Support for metadata aggregation
- URLValidator: Utility for URL validation and normalization with support for:
  - Basic and strict URL validation
  - URL normalization
  - Multimodal input handling
- Enhanced FunctionCallingOptionsBuilder with merge capabilities for both ChatOptions
  and FunctionCallingOptions
- Added BEDROCK_CONVERSE to AiProvider enum for metrics tracking
- Extended AWS credentials support with session token capability
- Added configurable session token property to BedrockAwsConnectionProperties

Adds new auto-configuration support:
- BedrockConverseProxyChatAutoConfiguration for automatic setup of the Bedrock Converse chat model
- BedrockConverseProxyChatProperties for configuration including:
  - Model selection (defaults to Claude 3 Sonnet)
  - Timeout settings (defaults to 5 minutes)
  - Temperature and token control
  - Top-K and Top-P sampling parameters
- Integration with existing BedrockAwsConnectionConfiguration for AWS credentials

Updates to testing infrastructure:
- Adds comprehensive test suite for Bedrock Converse properties and auto-configuration
- Integration tests for chat completion and streaming scenarios
- Property validation tests for configuration options
- Temporarily disabled other Bedrock tests due to AWS quota limitations
- Added ObjectMapper configuration for proper JSON handling

Added new spring-ai-bedrock-converse-spring-boot-starter module

Updates module configuration in parent POM and BOM to include new bedrock-converse
modules and starters. Adds necessary auto-configuration imports for seamless integration
with Spring Boot applications.

Unrelated changes:
- Disabled several Bedrock model tests (Jurassic2, Llama, Titan) due to AWS quota limitations
- Disabled PaLM2 tests due to API decommissioning by Google

Resolves #809, #802

Add docs and fix configs

- Move timeout configuration from chat properties to connection properties
- Add comprehensive documentation for Bedrock Converse API usage and configuration
- Update tests to reflect configuration changes

Co-authored-by: maxjiang153 <maxjiang153@users.noreply.github.com>

Standardize AWS credential handling in integration tests

- Improve how we manage AWS credentials across our integration test
suite and ensures consistent test configuration. We're replacing individual
environment variable checks with @RequiresAwsCredentials
annotation and standardizing the use of BedrockTestUtils for context creation
in tests

We also align all AWS regions to US_EAST_1 for consistency and add missing
dependency versioning for Oracle Free.

These changes make our AWS tests more easier to maintain.

Key changes:
- Replace @EnabledIfEnvironmentVariable with @RequiresAwsCredentials
- Standardize context creation via BedrockTestUtils
- Set AWS region to US_EAST_1
- Add Oracle Free dependency version in pom.xml
2024-11-03 17:10:24 -05:00
Timo Salm
932fc873f1 Take userText parameters into account for QuestionAnswerAdvisor's similarity search
Resolves  #1234
2024-11-03 18:42:00 +01:00
Michael J. Simons
560315ccfc refactor: Use Neo4j transactional functions.
This change uses `session.executeWrite` and `session.executeRead` to interact with the database.
Those methods use build-in retries for several Neo4j specific error states.
Doing will improve the overall user experience in this case as the no other external retry mechanism should be used.
Doing so is fine, as the Neo4j vector store is not subject to Springs general transaction management.
2024-11-03 12:57:42 +01:00
jiseunghyeon
cd15b65c7a modify a document 2024-11-03 12:36:05 +01:00
jitokim
cec76318f8 Update documentation for property override precedence in ChatModel and EmbeddingModel configurations.
Signed-off-by: jitokim <pigberger70@gmail.com>
2024-11-03 12:25:34 +01:00
Thomas Vitale
bc50d28f2d Modular RAG: Query Augmentor
* Add new QueryAugmentor API, a component for augmenting a user query with contextual data.
* Implement ContextualQueryAugmentor that combines the content of each document and add it to the original user prompt, with support for the scenario where the context is empty.
* Extend RetrievalAugmentationAdvisor to use the new augmentation building block.
* Introduce utility to assist in validating arguments for prompt-related operations.

Relates to gh-#1603

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2024-11-03 12:07:20 +01:00
Thomas Vitale
cca430428e Support case with missing system text in VectorStoreChatMemoryAdvisor
The system text advise prompt is only joined with the value of the system text if it's non-null and non-empty.

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2024-11-03 11:54:45 +01:00
Thomas Vitale
048d54b82b Make ChatClient APIs null-safe and predictable
* Introduced null-safety for all ChatClient APIs and verified via extensive auto-tests.
* Made the final message list computed by ChatClient consistent and predictable across the different options for providing messages (prompt(), messages(), user(), prompt()) and verified via extensive auto-tests.
* Added even more auto-tests to cover as many scenarios and edge cases as possible.

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2024-11-03 07:30:05 +01:00
Mark Pollack
25f386bb14 Disable opensearch vector store test searchDocumentsInTwoIndicesTest 2024-11-02 16:25:51 -04:00
Mark Pollack
0c07edc2e7 Revert back to previous OpenAiApi implementation and disable config prop tests 2024-11-02 16:16:22 -04:00
Soby Chacko
4184af5341 Convert API records to POJOs and fix failing autconfig tests
Following removal of Spring Boot's ConstructorBinding, convert record types
to regular POJOs to maintain JSON serialization. Update API classes:

- Convert FunctionTool and Function records to standard Java classes with
 getters/setters
- Update test assertions to use getter methods instead of record accessors
- Fix failing tests in MiniMax, OpenAi and ZhiPu API implementations

This keeps core API models independent of Spring Boot while ensuring proper
serialization through standard Java beans.

- MistralAIApi FunctionTool ConstructorBinding removal changes
2024-11-02 15:04:06 -04:00
jitokim
291da720a6 Remove redundant condition in RedisVectorStore
- Fix Javadoc typo: change 'algorithmto use' to 'algorithm to use'

Signed-off-by: jitokim <pigberger70@gmail.com>
2024-11-01 12:33:13 -04:00
Soby Chacko
254239cfe0 More checkstyle fixes 2024-11-01 12:25:19 -04:00
Mark Pollack
12ff83b068 Comment out flaky assertion in OpenAiChatModelObservationIT 2024-10-31 15:15:30 -04:00
Soby Chacko
e72ab6ba25 Addressing more checkstyle violations
- Enable checkstyle on more modules and adressing violations
review
2024-10-31 01:04:41 -04:00
Soby Chacko
cdc1cecb57 Enabling checkstyle on spring-ai-openai 2024-10-31 00:03:25 -04:00
Thomas Vitale
5d8c032bb7 Modular RAG: Retrieval with Vector Stores
* Establish new package for Modular RAG components.
* Add new Query API, representing a query in the context of a RAG flow.
* Define Retrieval package for the RAG building blocks handling the data retrieval operations.
* Relocate DocumentRetriever to Retrieval package and implement VectorStoreDocumentRetriever.
* Introduce RetrievalAugmentationAdvisor as the successor of QuestionAnswerAdvisor. It uses the Retrieval building blocks described in the previous point.
* Make Advisor APIs null-safe and update tests accordingly.

Relates to gh-#1603

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2024-10-30 23:57:38 -04:00
leevh0908
3fc03233c0 Milvus vector store: Pass databaseName in DeleteParam for non-default databases
When using a non-default database, MilvusVectorStore's doDelete method wasn't
passing the specified databaseName in DeleteParam, causing searches to fall back
to the default database where collections couldn't be found. Added explicit
databaseName parameter to fix this issue.

- Add databaseName to DeleteParam builder
- Upgrade milvus-sdk from 2.3.4 to 2.3.5
2024-10-30 20:37:55 -04:00
jito
cf17a6dccb Fix example code in ref docs (#1618)
chatclient.adoc
 - Replaced javaCopySimpleLoggerAdvisor with SimpleLoggerAdvisor
 - Fixed typo in the multiline String for ChatClient example

etl-pipeline.adoc
 - Fixed indent in the ParagraphPdfDocumentReader example

imageclient.adoc
 - Fixed indent of override annotation in the ImageGeneration example

testing.adoc
 - Added a semicolon to the Evaluator interface

Signed-off-by: jitokim <pigberger70@gmail.com>
2024-10-30 17:12:06 -04:00
jito
1e980d13b2 Azure cosmos-db vector store maven cleanup (#1631)
- Define the version for Azure Cosmos DB
- Add dependencies for the azure-cosmos-db-store module and boot starter
- Include the artifacts in spring-ai-bom

Signed-off-by: jitokim <pigberger70@gmail.com>
2024-10-30 17:07:13 -04:00
Ilayaperumal Gopinathan
d8f7ddb72c GH-513 fix: Support custom field names for Milvus VectorStore collection (#1616)
* GH-513 fix: Support custom field names for Milvus VectorStore collection

- Add configuration properties to override the default field names for doc_id, content, metadata and embedding
- Add support to allow auto-id when enabled
- Add tests

Resolves #513

* Fix package modifier
2024-10-30 14:44:50 -04:00