Class 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({
modelName: "gpt-3.5-turbo",
temperature: 0,
});

const chain = new ConversationChain({ llm: model, memory });

Hierarchy (view full)

Implements

Constructors

Properties

aiPrefix: string = "AI"
apiKey: string
chatHistory: BaseChatMessageHistory
humanPrefix: string = "Human"
inputKey?: string
mem0Client: MemoryClient
mem0Options: ClientOptions
memoryKey: string = "history"
memoryOptions: MemoryOptions | SearchOptions
outputKey?: string
returnMessages: boolean
separateMessages?: boolean
sessionId: string

Accessors

Methods