Repository navigation
feat(cache): add SemanticCache for caching LLM responses - #61
Merged
Merged
Conversation
- add SearchIndex.key(id), which builds the full Redis key from the index prefix and key separator - build fetch() and fetchMany() keys with key(), so they read the key that load() writes - strip trailing separators without a regular expression, so separators such as . | and * work - mention key() in the user guide
Member
Author
|
@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 718cebcb54
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
- add SemanticCache, which stores prompt and response pairs in Redis and finds them again by the meaning of the prompt - match prompts within a cosine distance threshold that can be set on the cache or on each call - identify entries by a hash of the prompt and filters, so storing the same prompt again replaces the entry - support entry TTLs that a cache hit can reset, filterable fields, metadata, update, drop, clear and delete - default to the redis/langcache-embed-v2 model through HuggingFaceVectorizer when no vectorizer is given - export SemanticCache and its types
- add a user guide page for SemanticCache and list it in the sidebar - add a semantic cache section and example to the README - describe the range, text and hybrid queries in the README features list - update the introduction page
booleanhunter
force-pushed
the
feat/semantic-cache
branch
from
December 3, 2026 09:32
718cebc to
3fc81a9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SemanticCache.create()makes a cache that stores prompt and response pairs in Redis and finds them again by the meaning of the prompt.check()returns the nearest entries within a cosine distance threshold, and an empty array on a miss.An entry's id is a SHA-256 hash of the prompt and its filters, so storing the same prompt again replaces the entry.
Entries can have a TTL, set on the cache or on one
store(), which a cache hit resets by default. Filterable fields, metadata,update(),drop(),clear()anddelete()are included.Uses
HuggingFaceVectorizerwithredis/langcache-embed-v2if no vectorizer given, with CLS pooling and no normalization.Adds a semantic cache guide to the docs, and updates README.
Differences from RedisVL Python: hits are camelCase typed objects, there is no
returnFieldsoption, an existing index is only checked for vector size,drop()returns a count,clear()removes only the documents the index can see, and a TTL must be a positive integer. Not included: telemetry, the LangCache REST classes, andcreate_index=False.The tests use a fake vectorizer, so CI does not download a model.