Skip to content
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

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bsbodden
Copy link

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

…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]>
@bsbodden bsbodden force-pushed the redis/semantic-caching-advisor-and-chat-memory branch from 19bcf33 to e31e620 Compare February 23, 2025 04:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant