-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat(redis): Add Redis-based semantic caching and chat memory implementations #2295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat(redis): Add Redis-based semantic caching and chat memory implementations #2295
Conversation
…ntations Add comprehensive Redis-backed features to enhance Spring AI: * Add semantic caching for chat responses: - SemanticCache interface and Redis implementation using vector similarity - SemanticCacheAdvisor for intercepting and caching chat responses - Uses vector search to cache and retrieve responses based on query similarity - Support for TTL-based cache expiration - Improves response times and reduces API costs for similar questions * Add Redis-based chat memory implementation: - RedisChatMemory using RedisJSON + RediSearch for conversation storage - Configurable RedisChatMemoryConfig with builder pattern support - Message TTL, ordering, multi-conversation and batch operations - Efficient conversation history retrieval using RediSearch indexes * Add integration tests: - Comprehensive test coverage using TestContainers - Tests for semantic caching features and chat memory operations - Integration test for RedisVectorStore with VectorStoreChatMemoryAdvisor - Verify chat completion augmentation with vector store content The Redis implementations enable efficient storage and retrieval of chat responses and conversation history, with semantic search capabilities and configurable persistence options. Signed-off-by: Brian Sam-Bodden <[email protected]>
19bcf33
to
e31e620
Compare
@bsbodden thank you so much for this! We have just delivered some changes to the Upgrade Notes: https://docs.spring.io/spring-ai/reference/upgrade-notes.html#_chat_memory |
@ThomasVitale I will make the needed changes and re-submit the branch! Thanks for looking into this. Cheers! |
In the meantime I rebased the PR and am a bit stuck - see #2982 As thomas mentioned, we will definitely need to separate this out into multiple modules, but in the meantime, if @bsbodden you could look at the reworked PR to see what is broken, that would be a big help. Thanks for the PR, I've been meaning to get to it for a while. |
…nectivity Refactor Redis-based chat memory implementation to: - Implement ChatMemoryRepository interface as requested in PR spring-projects#2295 - Fix Redis connection issues in integration tests reported in PR spring-projects#2982 - Optimize conversation ID lookup with server-side deduplication - Add configurable result limits to avoid Redis cursor size limitations - Implement robust fallback mechanism for query failures - Enhance support for metadata, toolcalls, and media in messages - Add comprehensive test coverage with reliable Redis connections
…nectivity Refactor Redis-based chat memory implementation to: - Implement ChatMemoryRepository interface as requested in PR spring-projects#2295 - Fix Redis connection issues in integration tests reported in PR spring-projects#2982 - Optimize conversation ID lookup with server-side deduplication - Add configurable result limits to avoid Redis cursor size limitations - Implement robust fallback mechanism for query failures - Enhance support for metadata, toolcalls, and media in messages - Add comprehensive test coverage with reliable Redis connections Signed-off-by: Brian Sam-Bodden <[email protected]>
…nectivity Refactor Redis-based chat memory implementation to: - Implement ChatMemoryRepository interface as requested in PR spring-projects#2295 - Fix Redis connection issues in integration tests reported in PR spring-projects#2982 - Optimize conversation ID lookup with server-side deduplication - Add configurable result limits to avoid Redis cursor size limitations - Implement robust fallback mechanism for query failures - Enhance support for metadata, toolcalls, and media in messages - Add comprehensive test coverage with reliable Redis connections Signed-off-by: Brian Sam-Bodden <[email protected]>
…nectivity Refactor Redis-based chat memory implementation to: - Implement ChatMemoryRepository interface as requested in PR spring-projects#2295 - Fix Redis connection issues in integration tests reported in PR spring-projects#2982 - Optimize conversation ID lookup with server-side deduplication - Add configurable result limits to avoid Redis cursor size limitations - Implement robust fallback mechanism for query failures - Enhance support for metadata, toolcalls, and media in messages - Add comprehensive test coverage with reliable Redis connections Signed-off-by: Brian Sam-Bodden <[email protected]>
…nectivity Refactor Redis-based chat memory implementation to: - Implement ChatMemoryRepository interface as requested in PR spring-projects#2295 - Fix Redis connection issues in integration tests reported in PR spring-projects#2982 - Optimize conversation ID lookup with server-side deduplication - Add configurable result limits to avoid Redis cursor size limitations - Implement robust fallback mechanism for query failures - Enhance support for metadata, toolcalls, and media in messages - Add comprehensive test coverage with reliable Redis connections Signed-off-by: Brian Sam-Bodden <[email protected]>
Add semantic caching for chat responses:
Add Redis-based chat memory implementation:
Add integration tests:
The Redis implementations enable efficient storage and retrieval of chat responses and conversation history, with semantic search capabilities and configurable persistence options.
/cc @jruaux
Signed-off-by: Brian Sam-Bodden [email protected]