- Override adviseStream method in VectorStoreChatMemoryAdvisor to properly handle streaming responses
- Add tests to verify the fix works with both normal and problematic streaming scenarios
Fixes#3152
Signed-off-by: Mark Pollack <mark.pollack@broadcom.com>
- Override adviseStream method in VectorStoreChatMemoryAdvisor to properly handle streaming responses
- Add tests to verify the fix works with both normal and problematic streaming scenarios
Fixes#3152
Signed-off-by: Mark Pollack <mark.pollack@broadcom.com>
Fixes: 3160
https://github.com/spring-projects/spring-ai/issues/3160
When using a filter expression with IN operator on a collection field in
CassandraVectorStore.similaritySearch, a ClassCastException was thrown because
the code attempted to format individual collection elements using the collection's
codec instead of the element type's codec.
This fix modifies doValue to detect when we are formatting elements inside a
collection type and use the appropriate element type codec. While Cassandra
does not support using the IN operator directly on collection columns, this fix
ensures we generate syntactically correct CQL rather than throwing a Java
exception.
The change specifically addresses ListType collections by using the element type
codec for individual elements within the list.
Signed-off-by: Soby Chacko <soby.chacko@broadcom.com>
Fixes: #3181https://github.com/spring-projects/spring-ai/issues/3181
When using CassandraVectorStore with an invalid index name and
initializeSchema=false, the application would throw a generic
NoSuchElementException from Optional.get() with message "No value present"
when trying to access the index metadata.
Changes:
- Added explicit validation of index existence in checkSchemaValid() method
- Improved error handling in getIndexSimilarity() method to provide a clear
error message when an index doesn't exist
- Added integration test to verify proper error handling with invalid index names
Signed-off-by: Soby Chacko <soby.chacko@broadcom.com>
- Fix the QdrantValueFactory to handle "java.util.List" type
- Update the integration test to use List type values
Resolves#3164
Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
* The defaultConversationId was configurable, but not used. It’s now being used correctly when a custom defaultConversationId is defined.
* The memory advisors were missing the required configuration of a Schedule due to a default value missing. Now as default Scheduler is used, automatically protecting from blocking. It can be customised via “scheduler()”, replacing the old “protectFromBlocking()” method.
* The new defaultTopK options in VectorStoreChatMemoryAdvisor were documented, but not implemented. That is fixed now.
* The memory advisors were not null-safe. Now they are.
* Improved tests to check the null-safe behaviour.
* Updated the documentation accordingly.
Fixes gh-3133
Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
Fixes: #1949
- Rename 'disallowSchemaChanges(boolean)' to 'initializeSchema(boolean)' for consistency
with other vector store implementations
- Maintain semantic meaning by inverting the default value (from disallowSchemaChanges=false
to initializeSchema=true) in the CassandraVectorStore implementation
- Keep default behavior in auto-configuration consistent with other vector stores
- Remove unused 'returnEmbeddings' functionality and related code
- Update test cases to use the new initialization parameter
- Ref docs and javadocs updates
This change improves API consistency across Spring AI vector stores while
preserving the same behavior in the Cassandra implementation.
Signed-off-by: Soby Chacko <soby.chacko@broadcom.com>
- Remove deprecated ChatMemory.get(String conversationId, int lastN) method
- Replace AbstractChatMemoryAdvisor with BaseChatMemoryAdvisor interface in api package
- Make constructors private in all memory advisor implementations to enforce builder usage
- Rename CHAT_MEMORY_CONVERSATION_ID_KEY to CONVERSATION_ID and move to ChatMemory interface
- In VectorStoreChatMemoryAdvisor:
- Rename DEFAULT_CHAT_MEMORY_RESPONSE_SIZE (100) to DEFAULT_TOP_K (20)
- Rename builder method chatMemoryRetrieveSize() to topK()
- Remove systemTextAdvise() builder method
- In PromptChatMemoryAdvisor:
- Remove systemTextAdvise() builder method
- Fix bug where only the last user message was stored from prompts with multiple messages
- Enhance logging in memory advisors to aid in debugging
- Add comprehensive tests for all advisor implementations:
- Unit tests for builder behavior
- Integration tests for the various chat memory advisors
Signed-off-by: Mark Pollack <mark.pollack@broadcom.com>
Fixes: #1831
- Document auto-truncation configuration with high token limits
- Add integration tests for auto-truncation behavior
- Include Spring Boot and manual configuration examples
- Test large documents and batching scenarios
Enables proper use of embedding model auto-truncation while avoiding batching strategy exceptions.
Signed-off-by: Soby Chacko <soby.chacko@broadcom.com>
Since the builders for HTTP clients are mutable and shared, they should
only be configured with globally applicable settings. The current use
leaks specific details into other usages and affects newly instantiated
clients. This PR applies the clone() method right before mutation
happens as it probably is the strategy that avoids multiple unnecessary
copies.
feat: improve RestClient and WebClient instantiation and configuration across AI modules
- Ensure RestClient.Builder and WebClient.Builder are properly cloned before setting base URLs and headers in Mistral, OpenAI, and Ollama API classes to prevent side effects.
- Add WebClientAutoConfiguration to auto-configuration classes for Anthropic and Mistral AI modules.
- Update Mistral AI auto-configuration to inject and use WebClient.Builder.
- Clean up test and annotation usage (remove unnecessary @Nullable, fix test builder usage in AnthropicApiIT).
- Improve consistency and reliability of HTTP client configuration across model integrations.
Signed-off-by: Dariusz Jędrzejczyk <dariusz.jedrzejczyk@broadcom.com>
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
Co-authored-by: Christian Tzolov <christian.tzolov@broadcom.com>
* Update remaining Advisors and related classes to use the new APIs.
* In AbstractChatMemoryAdvisor, the “doNextWithProtectFromBlockingBefore()” protected method has been changed from accepting AdvisedRequest to ChatClientRequest. It’s a breaking change since the alternative was not part of M8.
* MessageAggregator has a new method to aggregate messages from ChatClientRequest. The previous method aggregating messages from AdvisedRequest has been removed. Warning since it wasn’t marked as deprecated in M8.
* In SimpleLoggerAdvisor, the “requestToString” input argument needs to be updated to use ChatClientRequest. It’s a breaking change since the alternative was not part of M8. Same thing about the constructor.
* The “getTemplateRenderer” method has been removed from BaseAdvisorChain. Each Advisor is encouraged to accept a PromptTemplate to achieve self-contained prompt augmentation operations.
* Remove deprecations in ChatClient and Advisors, and update tests accordingly.
* When building a Prompt from the ChatClient input, the SystemMessage passed via systemText() is placed first in the message list. Before, it was put last, resulting in errors with several model providers.
Relates to gh-2655
Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
- Remove deprecated constructors from OllamaApi and AnthropicApi
- Modify AnthropicApi's public constructor to be private so that only the builder method can use it to construct
- Update OllamApiAutoConfiguration and AnthropicChatAutoconfiguration to use the builder methods to construct the respective
Apis
- Fix other constructor usages to builder methods
Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
Update multiple dependency versions including:
- Milvus from 2.5.4 to 2.5.7
- Azure Search from 11.6.1 to 11.7.6
- Weaviate client from 5.0.1 to 5.2.0
- Typesense from 0.5.0 to 1.3.0 (with matching code update)
- OpenSearch client from 2.10.1 to 2.23.0
- MariaDB from 3.5.1 to 3.5.3
- Couchbase from 3.7.8 to 3.8.0
- Neo4j Cypher DSL from 2024.0.2 to 2024.5.1
- Jedis from 5.1.0 to 5.2.0
Updates TypesenseVectorStore to use IndexAction enum instead of string literal.
Signed-off-by: Soby Chacko <soby.chacko@broadcom.com>
- Avoid overlapping package names
Changed in spring-ai-commons package from org.sf.ai.model to org.sf.ai.content
Refactor advisor module name to be spring-ai-advisors-vector-store
Moved advisors into org.springframework.ai.chat.client.advisor.vectorstore
- Created top level memory directory
- Create new module spring-ai-model-chat-memory-neo4j and moved neo4j memory classes out of the vectorstore module
Updated neo4j autoconfiguation
- Remove batch strategy usage as it is taken care by the vector store parent builder
Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
Fixes: #938
Issue link: https://github.com/spring-projects/spring-ai/issues/938
This commit integrates Couchbase as a vector store option in Spring AI, providing:
- CouchbaseSearchVectorStore implementation with vector similarity search capabilities
- Support for metadata filtering with SQL++ expression conversion
- Spring Boot auto-configuration and starter module for easy integration
- Comprehensive documentation covering setup, configuration, and usage examples
- Integration tests using TestContainers with Couchbase 7.6
The implementation supports configuring dimensions, similarity functions (dot_product/l2_norm),
and optimization strategies (recall/latency). Schema initialization is now opt-in via
the initializeSchema property. Documentation includes both auto-configuration and
manual configuration instructions, along with property configuration details.
Signed-off-by: Abhiraj <abhiraj.official15@gmail.com>
co-authored-by: Laurent Doguin <laurent.doguin@gmail.com>