class Mem0MemoryClass used to manage the memory of a chat session using the Mem0 service. It handles loading and saving chat history, and provides methods to format the memory content for use in chat models.
Method to clear the chat history.
Abstract method that should take an object of input values and return a Promise that resolves with an object of memory variables. The implementation of this method should load the memory variables from the provided input values.
Method to add user and AI messages to the chat history in sequence.
const memory = new Mem0Memory({
sessionId: "user123" // or use user_id inside of memoryOptions (recommended),
apiKey: "your-api-key",
memoryOptions: {
user_id: "user123",
run_id: "run123"
},
});
// Use with a chat model
const model = new ChatOpenAI({
model: "gpt-3.5-turbo",
temperature: 0,
});
const chain = new ConversationChain({ llm: model, memory });