Commit Graph

240 Commits

Author SHA1 Message Date
Mark Pollack
67a8896422 Next development version 2024-11-20 18:03:30 -05:00
Mark Pollack
33c05c399c Release version 1.0.0-M4 2024-11-20 18:02:47 -05:00
Christian Tzolov
52999b44b5 Align with the latest Chroma API
- Added Jackson annotations for JSON property handling in Chroma API request/response records.
  Use @JsonInclude(JsonInclude.Include.NON_NULL) to ignore empty fields such as null where.
  Use @JsonProperty(XYZ) to provide a strong contract with the Cohere API.
- Updated the Docker image for running Chroma locally and in tests to version 0.5.20.
- Enhanced  methods with non-null assertions for improved code safety.
- Added a simple search test to verify document similarity search functionality.

Fixes #1749
2024-11-20 10:11:41 -05:00
Mark Pollack
a4462420d8 Add support for optional keyless authentication.
Implemented a new configuration property 'useKeylessAuth' to toggle
between API key and Azure default credential authentication.

Added necessary dependencies and updated tests to reflect the new changes.

co-authored-by: mattgotteiner <mattgotteiner@users.noreply.github.com>
2024-11-19 16:15:07 -05:00
Ilayaperumal Gopinathan
de53e64bfd Fix OpenSearch vector store configuration and update mapping defaults
- Fix the embedding dimension configuration for opensearch client indices mapping
  The dimension config is obtained by the underlying embedding model's dimension
- Updated OpenSearch mapping JSON to include dynamic embedding dimension.
- Changed default mapping for OpenSearch vector store to use generic dimension placeholder.
- Fixed OpenSearchVectorStoreAutoConfiguration to fallback to new default mapping if no custom mapping is provided.
- Added test for verifying mapping configuration with OpenSearch vector store.
- Added test dependencies for Ollama integration.
- Refactored OpenSearch integration tests to use new mapping and dimension logic.

Add tests

- Verify the mappingJson field is correctly set - verify the override works fine
- Add integration tests with Ollama embedding model

Resolves #1589
2024-11-19 20:55:36 +01:00
Christian Tzolov
018257a605 fix: Resolve javadoc and maven confiuration issues 2024-11-16 12:43:27 +01:00
Christian Tzolov
0ca91b2ed9 fix: Resolve various javadoc and checkstyle issues 2024-11-16 11:06:14 +01:00
Ilayaperumal Gopinathan
72c84fe8b8 Remove deprecated code from 1.0 M2 and before
- Remove deprecated types,methods and references
 - Remove usage of "Generation(String text)" and replace with
  "Generation(AssistantMessage)"
 - Remove MiniMaxApi,MootShotApi,OpenAiApi,ZhiPuAiApi
   ChatCompletionFinishReason's FUNCTION_CALL
 - Remove OllamaApi's deprecated types
 - Remove deprecated constructors from PostgresMlEmbeddingModel
 - Remove deprecated constructor from Media
 - Remove tokenNames usage from antlr4 FiltersLexer and FiltersParser
 - Remove deprecated methods from CassandraVectorStoreProperties
 - Remove deprecated constructor and static config class from QdrantVectorStore
 - Minor cleanups on removing deprecated models and versions
 - Remove old name for mixtral models

Resolves #1599
2024-11-15 14:28:21 -05:00
zhaojy01
382fbaca48 Set embedding field as retrievable in Azure Vector Store
Resolves #1628

In Azure Vector Store, the embedding field needs to be retrievable
for proper functionality. While SearchField class doesn't have a
'retrievable' property, the 'hidden' field serves the same purpose.

The fix sets hidden=false on the embedding field to make it retrievable.

Link: https://github.com/spring-projects/spring-ai/issues/1628
2024-11-14 17:53:27 -05:00
Ilayaperumal Gopinathan
a98c042960 Fix Chroma delete operation status check
Due to changes in Chroma v0.5.13 (chroma-core/chroma#2880), the delete
operation no longer returns values. This impacts our ChromaVectorStore's delete
functionality.

Now we need to check the HTTP status code instead to properly verify if the
delete operation succeeded.

Test suite has been updated.

Resolves #1529
2024-11-13 16:32:19 -05:00
Soby Chacko
c8a9b1640a Add builder pattern to ChromaVectorStore for better initialization control
The change addresses initialization issues when ChromaVectorStore is used outside
Spring context, particularly in scenarios where collections are created manually
before store instantiation. Previously, collection ID wasn't properly populated
when afterPropertiesSet() wasn't called by Spring container.

- Add builder pattern to ChromaVectorStore for better initialization control
- Add initialization flag to prevent multiple collection creation calls
- Add integration tests for builder pattern usage scenarios
- Add spring-ai-transformers dependency for testing
- Remove unused constants (SIMILARITY_THRESHOLD_ALL, DEFAULT_TOP_K)

Collection ID is now properly set regardless of whether the store is managed by
Spring or created manually, solving the 404 Not Found errors during document
insertion.

Fixes: #1240
2024-11-12 17:17:18 -05:00
Mark Pollack
a98af02f62 Minimize time to run main CI build action
- Add maven properties for all vector stores such as
skip.vectorstore.azure-cosmos-db to control IT test execution
- Chroma and PGVector IT tests are enabled by default
- Docker Compose and Testcontainers module ITs are skipped by default
- Add parallel job to run docker-compose and testcontainers ITs
2024-11-11 16:19:08 -05:00
Soby Chacko
865d429451 Checkstyle changes 2024-11-08 15:18:35 +00:00
Mark Pollack
8d9e153899 Disable CoherenceVectorStoreIT as it is resource heavy in CI env 2024-11-07 13:24:20 -05:00
CodingLuizy
7780411d0a remove duplicated config building with ApiKey 2024-11-08 02:49:35 +09:00
Ilayaperumal Gopinathan
fa3eea4933 Disable OpenSearchVectorStoreIT$searchDocumentsInTwoIndicesTest
Refer: https://github.com/spring-projects/spring-ai/issues/1645
2024-11-07 16:10:46 +00:00
Soby Chacko
0b55fa3a04 GH-1678: Re-enable tests in OpenSearchVectorStoreIT
Fixes: #1678
2024-11-06 18:01:41 -05:00
jitokim
1cdec7b6c3 Fix Cypher syntax for vector property in Neo4jVectorStore
- Fix parameter access syntax in setNodeVectorProperty DDL statement
- Define DEFAULT_TRANSACTION_SIZE for the hardcoded batch size in
the delete query

Fixes #1623

Signed-off-by: jitokim <pigberger70@gmail.com>
2024-11-06 16:39:21 -05:00
Aleks Seovic
f6a648e85c Add Oracle Coherence vector store implementation
Integrates Oracle Coherence 24.09+ as a vector store backend for Spring AI. The
implementation provides:

- Support for vector similarity search with configurable distance metrics (Cosine,
  Inner Product, L2)
- Multiple indexing options including HNSW and Binary Quantization indexes
- Filter expression evaluation for metadata-based filtering
- Vector normalization capabilities
- Comprehensive test coverage including integration tests

The implementation includes:
- CoherenceVectorStore main implementation
- CoherenceFilterExpressionConverter for Spring AI to Coherence filter conversion
- Auto-configuration support via spring-boot-starter
- Documentation and usage examples

Requires Oracle Coherence 24.09 or later.
2024-11-06 16:07:20 -05:00
Oleksandr Klymenko
6a3c548883 Refactor to modern switch expressions in vector stores
Replace traditional switch statements with Java 14 switch expressions across
vector store filter converters and related components. This change improves
code quality in our filter expression handling for Azure, Milvus, Redis,
Typesense and Weaviate implementations.

The switch expressions eliminate fall-through behavior, enforce exhaustive
pattern matching at compile time, and provide a more direct way to return
values. This makes the filter conversion logic more robust and maintainable.
2024-11-06 15:24:03 -05:00
leevh0908
5235696160 Change NIN filter to use "not in" operator in Milvus
- Milvus requires "not in" operator syntax instead of "nin" for filtering.
- See https://milvus.io/docs/boolean.md
- Updated test and added additional test coverage
2024-11-06 15:20:02 -05: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
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
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
ff41a1a529 Disable OracleVectorStore and Ollama IT tests 2024-11-03 18:55:09 -05: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
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
Mark Pollack
25f386bb14 Disable opensearch vector store test searchDocumentsInTwoIndicesTest 2024-11-02 16:25:51 -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
e72ab6ba25 Addressing more checkstyle violations
- Enable checkstyle on more modules and adressing violations
review
2024-10-31 01:04:41 -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
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
Sébastien Deleuze
081840eef2 Skip tests requiring OpenAI API key
Adds @EnabledIfEnvironmentVariable annotation to integration tests that
use OpenAI embeddings. Tests will be skipped if OPENAI_API_KEY is not set,
making the build process more reliable for contributors who don't have
access to OpenAI services.
2024-10-29 12:15:44 -04:00
Mark Pollack
3f85f792c2 fix cassandra tests 2024-10-24 20:31:19 -04:00
Soby Chacko
8e758dbd00 Introduce checkstyle plugin
- Based on https://github.com/spring-io/spring-javaformat
- In this iteration, checkstyles are only enabled for spring-ai-core
2024-10-24 16:43:59 -04:00
Sébastien Deleuze
f21b8a42b5 Refine Jackson ObjectMapper handling
ObjectMapper instantiation is costly, so unless its usage
is one-shot, it is better to create a reusable instance
for upcoming usage.

Also, before this commit, serialization of most Kotlin
classes was not supported due to the lack of proper
Jackson KotlinModule detection.

This commit:
 - Avoids per invocation ObjectMapper instantiation when
   relevant
 - Automatically detects and enables well-known Jackson
   modules including the Kotlin one
 - Removes org.springframework.ai.vectorstore.JsonUtils
   which looks not needed anymore

More optimizations are possible like reusing more
ObjectMapper instances, but this could introduce more breaking
changes so this commit intends to be a good first step.

Kotlin tests will be provided in a follow-up commit.

Additional changes:
 - Update ModelOptionsUtils to use JacksonUtils.instantiateAvailableModules()
 - Add missing license headers
 - Add missing author Javadoc comments
2024-10-24 09:20:47 +02:00
Christian Tzolov
c979238993 Adding nav entry for Azure Cosmos DB documentation
- Minor code sytle fixes.
2024-10-23 07:45:49 +02:00
Soby Chacko
c979d1c606 CosmosDB vector store auto configuration changes
- Configurable BatchingStrategy via auto configuraiton
- Minor code cleanup
2024-10-22 17:08:31 -04:00
Theo van Kraay
7b06fcf98b Add Azure CosmosDB vector store support
- Implement core vector store module for CosmosDB integration
- Add Spring Boot auto-configuration capabilities
- Integrate batch processing strategy for optimized operations
- Include comprehensive tests for core and auto-config modules
- Add reference docs for the CosmosDB vector store support
2024-10-22 15:50:16 -04:00
Christian Tzolov
278a61fde4 Fix doc ref links 2024-10-21 10:24:28 +02:00
shushengcoder
f461bd603d Add support for multiple types in Chroma metadata
- Change Chroma collection metadata to Map<String, Object>
- Allows integer and other value types to be passed in

Fixes #1548
2024-10-16 16:25:17 -04:00
Mark Pollack
d0c53392aa Update spring-javaformat to version 0.0.43
- Ran ./mvnw spring-javaformat:apply that made some new formatting changes
2024-10-16 15:50:04 -04:00
Christian Tzolov
2e0a51fac5 Streamline dependencies and improve API consistency
- Remove unnecessary spring-web dependencies
 - Update third-party library versions
 - Refactor API classes to use consistent header handling
 - Remove ApiUtils class and inline its functionality
 - Adjust RestClient and WebClient builder usage in autoconfiguration
 - Replace direct RestClient.Builder injections with ObjectProvider<RestClient.Builder>
   and WebClient.Builder injections with ObjectProvider<WebClient.Builder>
 - Update ChromaVectorStoreAutoConfiguration to use ObjectProvider
 - Rename MongoDbAtlasLocalContainerConnectionDetailsFactoryTest to IT
 - Switch spring-ai-chroma-store dependency from spring-web to spring-webflux
 - Simplify ChromaApi constructor by using method reference for default headers
 - Adjust import order

 Resolves #1066
 Resolves #524
2024-10-16 15:46:03 -04:00
Mark Pollack
4c83fe8302 Guard against NPE in ZhiPu embedding model
- Update retry test to pass - needs investigation
2024-10-08 23:37:00 +02:00
Mark Pollack
4a892b5269 Release version 1.0.0-M3 2024-10-08 23:18:50 +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
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
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