Class that represents a conversation chat memory with a token buffer. It extends the BaseChatMemory class and implements the ConversationTokenBufferMemoryInput interface.
BaseChatMemory
ConversationTokenBufferMemoryInput
const memory = new ConversationTokenBufferMemory({ llm: new ChatOpenAI({}), maxTokenLimit: 10,});// Save conversation contextawait memory.saveContext({ input: "hi" }, { output: "whats up" });await memory.saveContext({ input: "not much you" }, { output: "not much" });// Load memory variablesconst result = await memory.loadMemoryVariables({});console.log(result); Copy
const memory = new ConversationTokenBufferMemory({ llm: new ChatOpenAI({}), maxTokenLimit: 10,});// Save conversation contextawait memory.saveContext({ input: "hi" }, { output: "whats up" });await memory.saveContext({ input: "not much you" }, { output: "not much" });// Load memory variablesconst result = await memory.loadMemoryVariables({});console.log(result);
Loads the memory variables. It takes an InputValues object as a parameter and returns a Promise that resolves with a MemoryVariables object.
InputValues
Promise
MemoryVariables
InputValues object.
A Promise that resolves with a MemoryVariables object.
Saves the context from this conversation to buffer. If the amount of tokens required to save the buffer exceeds MAX_TOKEN_LIMIT, prune it.
Class that represents a conversation chat memory with a token buffer. It extends the
BaseChatMemory
class and implements theConversationTokenBufferMemoryInput
interface.Example