class Mem0MemoryBaseChatMemoryClass 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.
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 });