UNPKG

@langchain/community

Version:
1 lines • 2.26 kB
{"version":3,"file":"upstash_redis.d.cts","names":["Redis","RedisConfigNodejs","Generation","BaseCache","UpstashRedisCacheProps","UpstashRedisCache","Promise"],"sources":["../../src/caches/upstash_redis.d.ts"],"sourcesContent":["import { Redis, type RedisConfigNodejs } from \"@upstash/redis\";\nimport { Generation } from \"@langchain/core/outputs\";\nimport { BaseCache } from \"@langchain/core/caches\";\nexport type UpstashRedisCacheProps = {\n /**\n * The config to use to instantiate an Upstash Redis client.\n */\n config?: RedisConfigNodejs;\n /**\n * An existing Upstash Redis client.\n */\n client?: Redis;\n /**\n * Time-to-live (TTL) for cached items in seconds.\n */\n ttl?: number;\n};\n/**\n * A cache that uses Upstash as the backing store.\n * See https://docs.upstash.com/redis.\n * @example\n * ```typescript\n * const cache = new UpstashRedisCache({\n * config: {\n * url: \"UPSTASH_REDIS_REST_URL\",\n * token: \"UPSTASH_REDIS_REST_TOKEN\",\n * },\n * ttl: 3600, // Optional: Cache entries will expire after 1 hour\n * });\n * // Initialize the OpenAI model with Upstash Redis cache for caching responses\n * const model = new ChatOpenAI({\n * model: \"gpt-4o-mini\",\n * cache,\n * });\n * await model.invoke(\"How are you today?\");\n * const cachedValues = await cache.lookup(\"How are you today?\", \"llmKey\");\n * ```\n */\nexport declare class UpstashRedisCache extends BaseCache {\n private redisClient;\n private ttl?;\n constructor(props: UpstashRedisCacheProps);\n /**\n * Lookup LLM generations in cache by prompt and associated LLM key.\n */\n lookup(prompt: string, llmKey: string): Promise<Generation[] | null>;\n /**\n * Update the cache with the given generations.\n *\n * Note this overwrites any existing generations for the given prompt and LLM key.\n */\n update(prompt: string, llmKey: string, value: Generation[]): Promise<void>;\n}\n//# sourceMappingURL=upstash_redis.d.ts.map"],"mappings":";;;;;KAGYI,sBAAAA;;AAAZ;AAmCA;EAGuBA,MAAAA,CAAAA,EAlCVH,iBAkCUG;EAI6BF;;;EAMaI,MAAAA,CAAAA,EAxCpDN,KAwCoDM;EAblBH;AAAS;;;;;;;;;;;;;;;;;;;;;;;;;cAAnCE,iBAAAA,SAA0BF,SAAAA;;;qBAGxBC;;;;0CAIqBE,QAAQJ;;;;;;gDAMFA,eAAeI"}