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.
Clears all memories for the current session
Retrieves memories from the Mem0 service and formats them for use
Saves the current conversation context to the Mem0 service
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 });