langchainjs icon indicating copy to clipboard operation
langchainjs copied to clipboard

Add Redis Cache, cache clean up

Open samheutmaker opened this issue 2 years ago • 0 comments

Here's a PR for a Redis cache. It includes a few small change to the BaseCache and InMemory cache as well.

One thing to note: In Python LangChain, the cache is set on the global langchain object like:

import langchain
from langchain.cache import InMemoryCache
langchain.llm_cache = InMemoryCache()

This doesn't translate well to TypeScript. It's worth discussing how this should be handled. IMHO, it would be best to optionally pass the cache to the LLM class upon instantiation with an in-memory cache as a fallback.

samheutmaker avatar Feb 20 '23 16:02 samheutmaker