langchainjs
langchainjs copied to clipboard
Add Redis Cache, cache clean up
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.