class ZepCloudMemoryClass used to manage the memory of a chat session, including loading and saving the chat history, and clearing the memory when needed. It uses the ZepClient to interact with the Zep service for managing the chat session's memory.
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 sessionId = randomUUID();
// Initialize ZepCloudMemory with session ID and API key
const memory = new ZepCloudMemory({
sessionId,
apiKey: "<zep api key>",
});
// Create a ChatOpenAI model instance with specific parameters
const model = new ChatOpenAI({
model: "gpt-3.5-turbo",
temperature: 0,
});
// Create a ConversationChain with the model and memory
const chain = new ConversationChain({ llm: model, memory });
// Example of calling the chain with an input
const res1 = await chain.call({ input: "Hi! I'm Jim." });
console.log({ res1 });
// Follow-up call to the chain to demonstrate memory usage
const res2 = await chain.call({ input: "What did I just say my name was?" });
console.log({ res2 });
// Output the session ID and the current state of memory
console.log("Session ID: ", sessionId);
console.log("Memory: ", await memory.loadMemoryVariables({}));