Skip to content

Conversation

@abrookins
Copy link
Collaborator

@abrookins abrookins commented Nov 13, 2025

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.

from langchain_redis import LangCacheSemanticCache


cache = LangCacheSemanticCache(
    embeddings=embedding_client,
    cache_id="your-langcache-cache-id",
    api_key="your-langcache-api-key",
    prefix="tenant-a",  # optional
)

@abrookins abrookins force-pushed the feat/langcache-semantic-cache branch 2 times, most recently from c6d8a7e to 0d2d2f4 Compare November 13, 2025 18:14
@abrookins abrookins requested a review from Copilot November 13, 2025 21:02
Copilot finished reviewing on behalf of abrookins November 13, 2025 21:05
Copy link
Contributor

Copilot AI left a 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 LangCacheSemanticCache class that wraps RedisVL's LangCache client for managed semantic caching
  • Introduces optional langcache dependency with extras support for installation flexibility
  • Updates dependencies to require redisvl>=0.11.0 and python>=3.9.2 to 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.

@abrookins abrookins requested a review from Copilot November 13, 2025 23:16
Copilot finished reviewing on behalf of abrookins November 13, 2025 23:21
Copy link
Contributor

Copilot AI left a 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.

@abrookins abrookins requested a review from Copilot November 14, 2025 00:03
Copilot finished reviewing on behalf of abrookins November 14, 2025 00:07
Copy link
Contributor

Copilot AI left a 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.

@abrookins abrookins requested a review from Copilot November 14, 2025 00:36
Copilot finished reviewing on behalf of abrookins November 14, 2025 00:40
Copy link
Contributor

Copilot AI left a 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.

Copy link
Collaborator

@tylerhutcherson tylerhutcherson left a 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!

@abrookins
Copy link
Collaborator Author

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):

BadRequestErrorResponseContent: {"detail":"attributes: (llm_string: Cannot contain commas ','.).","status":400,"title":"Invalid Request","type":"/errors/invalid-data"}

I will have to follow up with this next week!

@abrookins abrookins force-pushed the feat/langcache-semantic-cache branch 3 times, most recently from 1b575fa to c0ac6a2 Compare November 21, 2025 18:12
@abrookins abrookins force-pushed the feat/langcache-semantic-cache branch from c0ac6a2 to 3d55037 Compare November 21, 2025 18:39
@abrookins abrookins force-pushed the feat/langcache-semantic-cache branch from 47c5f5b to ccad3e0 Compare November 21, 2025 23:07
@bsbodden bsbodden self-assigned this Nov 21, 2025
@bsbodden bsbodden self-requested a review November 21, 2025 23:39
Copy link
Collaborator

@bsbodden bsbodden left a 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!

@abrookins abrookins force-pushed the feat/langcache-semantic-cache branch from a3c2fcd to 7d9d236 Compare November 22, 2025 17:01
@bjh3311
Copy link

bjh3311 commented Nov 23, 2025

I have a question bout this. I thought langchain-redis package already had RedisSemanticCache. Is RedisSemanticCache different from Redis LangCache?

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.

5 participants