UNPKG

@langchain/community

Version:
1 lines • 3.62 kB
{"version":3,"file":"upstash_redis.d.cts","names":["Redis","UpstashRedis","RedisConfigNodejs","BaseStore","UpstashRedisStoreInput","UpstashRedisStore","Uint8Array","ArrayBuffer","Promise","AsyncGenerator"],"sources":["../../src/storage/upstash_redis.d.ts"],"sourcesContent":["import { Redis as UpstashRedis, type RedisConfigNodejs } from \"@upstash/redis\";\nimport { BaseStore } from \"@langchain/core/stores\";\n/**\n * Type definition for the input parameters required to initialize an\n * instance of the UpstashStoreInput class.\n */\nexport interface UpstashRedisStoreInput {\n sessionTTL?: number;\n config?: RedisConfigNodejs;\n client?: UpstashRedis;\n /**\n * The amount of keys to retrieve per batch when yielding keys.\n * @default 1000\n */\n yieldKeysScanBatchSize?: number;\n /**\n * The namespace to use for the keys in the database.\n */\n namespace?: string;\n}\n/**\n * Class that extends the BaseStore class to interact with an Upstash Redis\n * database. It provides methods for getting, setting, and deleting data,\n * as well as yielding keys from the database.\n * @example\n * ```typescript\n * const store = new UpstashRedisStore({\n * client: new Redis({\n * url: \"your-upstash-redis-url\",\n * token: \"your-upstash-redis-token\",\n * }),\n * });\n * await store.mset([\n * [\"message:id:0\", \"encoded-ai-message\"],\n * [\"message:id:1\", \"encoded-human-message\"],\n * ]);\n * const retrievedMessages = await store.mget([\"message:id:0\", \"message:id:1\"]);\n * const yieldedKeys = [];\n * for await (const key of store.yieldKeys(\"message:id\")) {\n * yieldedKeys.push(key);\n * }\n * await store.mdelete(yieldedKeys);\n * ```\n */\nexport declare class UpstashRedisStore extends BaseStore<string, Uint8Array> {\n lc_namespace: string[];\n protected client: UpstashRedis;\n protected namespace?: string;\n protected yieldKeysScanBatchSize: number;\n private sessionTTL?;\n constructor(fields: UpstashRedisStoreInput);\n _getPrefixedKey(key: string): string;\n _getDeprefixedKey(key: string): string;\n /**\n * Gets multiple keys from the Upstash Redis database.\n * @param keys Array of keys to be retrieved.\n * @returns An array of retrieved values.\n */\n mget(keys: string[]): Promise<(Uint8Array<ArrayBuffer> | undefined)[]>;\n /**\n * Sets multiple keys in the Upstash Redis database.\n * @param keyValuePairs Array of key-value pairs to be set.\n * @returns Promise that resolves when all keys have been set.\n */\n mset(keyValuePairs: [string, Uint8Array][]): Promise<void>;\n /**\n * Deletes multiple keys from the Upstash Redis database.\n * @param keys Array of keys to be deleted.\n * @returns Promise that resolves when all keys have been deleted.\n */\n mdelete(keys: string[]): Promise<void>;\n /**\n * Yields keys from the Upstash Redis database.\n * @param prefix Optional prefix to filter the keys. A wildcard (*) is always appended to the end.\n * @returns An AsyncGenerator that yields keys from the Upstash Redis database.\n */\n yieldKeys(prefix?: string): AsyncGenerator<string>;\n}\n//# sourceMappingURL=upstash_redis.d.ts.map"],"mappings":";;;;;;;AAMA;AAsCA;AAAiEM,UAtChDF,sBAAAA,CAsCgDE;EAE3CL,UAAAA,CAAAA,EAAAA,MAAAA;EAIEG,MAAAA,CAAAA,EA1CXF,iBA0CWE;EAQsBG,MAAAA,CAAAA,EAjDjCN,KAiDiCM;EAAXD;;;;EAYNE,sBAAAA,CAAAA,EAAAA,MAAAA;EAMGC;;AAhCwB;;;;;;;;;;;;;;;;;;;;;;;;;;;cAAnCJ,iBAAAA,SAA0BF,kBAAkBG;;oBAE3CL;;;;sBAIEG;;;;;;;;wBAQEI,SAASF,WAAWC;;;;;;+BAMbD,gBAAgBE;;;;;;2BAMpBA;;;;;;8BAMGC"}