-
Notifications
You must be signed in to change notification settings - Fork 32
Introduce LangCacheSemanticCache as a caching option #90
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?
Conversation
c6d8a7e to
0d2d2f4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces LangCacheSemanticCache as a new semantic caching backend that leverages Redis's managed LangCache service, providing an alternative to the existing self-hosted RedisSemanticCache implementation.
Key changes:
- Adds
LangCacheSemanticCacheclass that wraps RedisVL's LangCache client for managed semantic caching - Introduces optional
langcachedependency with extras support for installation flexibility - Updates dependencies to require
redisvl>=0.11.0andpython>=3.9.2to support the new LangCache integration
Reviewed Changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| libs/redis/langchain_redis/cache.py | Implements the new LangCacheSemanticCache class with sync/async methods for lookup, update, and clear operations, plus name/prefix mapping logic |
| libs/redis/langchain_redis/init.py | Exports the new LangCacheSemanticCache class for public API access |
| libs/redis/tests/unit_tests/test_langcache_semantic_cache.py | Adds unit tests for basic cache operations and name/prefix parameter combinations using a mock implementation |
| libs/redis/tests/unit_tests/test_imports.py | Updates expected imports list to include LangCacheSemanticCache |
| libs/redis/pyproject.toml | Adds optional langcache>=0.9.0 dependency, updates redisvl to >=0.11.0, bumps minimum Python to 3.9.2, and adds mypy exclusion for virtual environments |
| libs/redis/poetry.lock | Updates lock file with langcache 0.10.1 package and redisvl git dependency, reflects Poetry version change from 2.0.1 to 1.7.1 |
| libs/redis/Makefile | Adds poetry check command to lint targets for validating pyproject.toml correctness |
| CLAUDE.md | Documents virtual environment setup and Poetry usage patterns for development |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 7 out of 8 changed files in this pull request and generated 7 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 7 out of 8 changed files in this pull request and generated 7 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
tylerhutcherson
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great -- left a note about the prefix arg. Should we require the args that langcache doesn't actually need or use here (embeddings and prefix for example).
Also, we need an update to the README and to one of the user guides. Also need to make sure this gets updated within langcache docs so it's listed with a link to sign up for the service on redis cloud!
|
Ah, a hiccup. LangChain uses model parameters as a filter, so it expects caching to be specific to a model+params combo, which makes sense. LangCache's "attributes" is the feature that should allow us to filter. However, attributes don't support commas, which it appears the model+params string from LangChain includes (llm_string): I will have to follow up with this next week! |
1b575fa to
c0ac6a2
Compare
c0ac6a2 to
3d55037
Compare
47c5f5b to
ccad3e0
Compare
bsbodden
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Ship it!
a3c2fcd to
7d9d236
Compare
|
I have a question bout this. I thought langchain-redis package already had RedisSemanticCache. Is RedisSemanticCache different from Redis LangCache? |
Introduces a semantic cache backend for the Redis LangCache service.
Usage example
Instantiate with the required LangCache cache_id and api_key. Optionally set name/prefix.