class LocalFileStoreBaseStore<string, Uint8Array>File system implementation of the BaseStore using a dictionary. Used for storing key-value pairs in the file system.
A path to the module that contains the class, eg. ["langchain", "llms"] Usually should be the same as the entrypoint the class is exported from.
Deletes the given keys and their associated values from the store.
Retrieves the values associated with the given keys from the store.
Sets the values for the given keys in the store.
Asynchronous generator that yields keys from the store. If a prefix is provided, it only yields keys that start with the prefix.
Static method for initializing the class. Preforms a check to see if the directory exists, and if not, creates it.
The name of the serializable. Override to provide an alias or to preserve the serialized module name in minified environments.
Implemented as a static method to support loading logic.
const store = await LocalFileStore.fromPath("./messages");
await store.mset(
Array.from({ length: 5 }).map((_, index) => [
`message:id:${index}`,
new TextEncoder().encode(
JSON.stringify(
index % 2 === 0
? new AIMessage("ai stuff...")
: new HumanMessage("human stuff..."),
),
),
]),
);
const retrievedMessages = await store.mget(["message:id:0", "message:id:1"]);
console.log(retrievedMessages.map((v) => new TextDecoder().decode(v)));
for await (const key of store.yieldKeys("message:id:")) {
await store.mdelete([key]);
}