spring-ai icon indicating copy to clipboard operation
spring-ai copied to clipboard

feat(redis): Add Redis-based semantic caching and chat memory implementations

Open bsbodden opened this issue 9 months ago • 7 comments
trafficstars

  • 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.

/cc @jruaux

Signed-off-by: Brian Sam-Bodden [email protected]

bsbodden avatar Feb 23 '25 04:02 bsbodden