langchain
Version:
Typescript bindings for langchain
1 lines • 3.5 kB
Source Map (JSON)
{"version":3,"file":"file_system.d.ts","names":["BaseStore","LocalFileStore","Uint8Array","ArrayBufferLike","Promise","AsyncGenerator"],"sources":["../../src/storage/file_system.d.ts"],"sourcesContent":["import { BaseStore } from \"@langchain/core/stores\";\n/**\n * File system implementation of the BaseStore using a dictionary. Used for\n * storing key-value pairs in the file system.\n * @example\n * ```typescript\n * const store = await LocalFileStore.fromPath(\"./messages\");\n * await store.mset(\n * Array.from({ length: 5 }).map((_, index) => [\n * `message:id:${index}`,\n * new TextEncoder().encode(\n * JSON.stringify(\n * index % 2 === 0\n * ? new AIMessage(\"ai stuff...\")\n * : new HumanMessage(\"human stuff...\"),\n * ),\n * ),\n * ]),\n * );\n * const retrievedMessages = await store.mget([\"message:id:0\", \"message:id:1\"]);\n * console.log(retrievedMessages.map((v) => new TextDecoder().decode(v)));\n * for await (const key of store.yieldKeys(\"message:id:\")) {\n * await store.mdelete([key]);\n * }\n * ```\n *\n * @security **Security Notice** This file store\n * can alter any text file in the provided directory and any subfolders.\n * Make sure that the path you specify when initializing the store is free\n * of other files.\n */\nexport declare class LocalFileStore extends BaseStore<string, Uint8Array> {\n lc_namespace: string[];\n rootPath: string;\n constructor(fields: {\n rootPath: string;\n });\n private getParsedFile;\n private setFileContent;\n /**\n * Returns the full path of the file where the value of the given key is stored.\n * @param key the key to get the full path for\n */\n private getFullPath;\n /**\n * Retrieves the values associated with the given keys from the store.\n * @param keys Keys to retrieve values for.\n * @returns Array of values associated with the given keys.\n */\n mget(keys: string[]): Promise<(Uint8Array<ArrayBufferLike> | undefined)[]>;\n /**\n * Sets the values for the given keys in the store.\n * @param keyValuePairs Array of key-value pairs to set in the store.\n * @returns Promise that resolves when all key-value pairs have been set.\n */\n mset(keyValuePairs: [string, Uint8Array][]): Promise<void>;\n /**\n * Deletes the given keys and their associated values from the store.\n * @param keys Keys to delete from the store.\n * @returns Promise that resolves when all keys have been deleted.\n */\n mdelete(keys: string[]): Promise<void>;\n /**\n * Asynchronous generator that yields keys from the store. If a prefix is\n * provided, it only yields keys that start with the prefix.\n * @param prefix Optional prefix to filter keys.\n * @returns AsyncGenerator that yields keys from the store.\n */\n yieldKeys(prefix?: string): AsyncGenerator<string>;\n /**\n * Static method for initializing the class.\n * Preforms a check to see if the directory exists, and if not, creates it.\n * @param path Path to the directory.\n * @returns Promise that resolves to an instance of the class.\n */\n static fromPath(rootPath: string): Promise<LocalFileStore>;\n}\n//# sourceMappingURL=file_system.d.ts.map"],"mappings":";;;;;;AA+BA;;;;;;;;;;;;AAAqD;;;;;;;;;;;;;;;;cAAhCC,cAAAA,SAAuBD,kBAAkBE;;;;;;;;;;;;;;;;;;wBAkBpCE,SAASF,WAAWC;;;;;;+BAMbD,gBAAgBE;;;;;;2BAMpBA;;;;;;;8BAOGC;;;;;;;qCAOOD,QAAQH"}