IPFS Datastore Chat Memory
For a storage backend you can use the IPFS Datastore Chat Memory to wrap an IPFS Datastore allowing you to use any IPFS compatible datastore.
Setupβ
First, install the integration dependencies:
- npm
- Yarn
- pnpm
npm install cborg interface-datastore it-all @langchain/community
yarn add cborg interface-datastore it-all @langchain/community
pnpm add cborg interface-datastore it-all @langchain/community
Now you can install and use an IPFS Datastore of your choice. Here are some options:
- datastore-core Datastore in-memory implementation.
- datastore-fs Datastore implementation with file system backend.
- datastore-idb Datastore implementation with IndexedDB backend.
- datastore-level Datastore implementation with level(up|down) backend
- datastore-s3 Datastore implementation backed by s3.
Usageβ
// Replace FsDatastore with the IPFS Datastore of your choice.
import { FsDatastore } from "datastore-fs";
import { IPFSDatastoreChatMessageHistory } from "@langchain/community/stores/message/ipfs_datastore";
const datastore = new FsDatastore("path/to/store");
const sessionId = "my-session";
const history = new IPFSDatastoreChatMessageHistory({ datastore, sessionId });