Cache LLM results using Redis.
const model = new ChatOpenAI({
model: "gpt-4o-mini",
cache: new RedisCache(new Redis(), { ttl: 60 }),
});
// Invoke the model with a prompt
const response = await model.invoke("Do something random!");
console.log(response);
// Remember to disconnect the Redis client when done
await redisClient.disconnect();