Class that represents a conversation chat memory with a token buffer. It extends the BaseChatMemory class and implements the ConversationTokenBufferMemoryInput interface.

Example

const memory = new ConversationTokenBufferMemory({
llm: new ChatOpenAI({}),
maxTokenLimit: 10,
});

// Save conversation context
await memory.saveContext({ input: "hi" }, { output: "whats up" });
await memory.saveContext({ input: "not much you" }, { output: "not much" });

// Load memory variables
const result = await memory.loadMemoryVariables({});
console.log(result);

Hierarchy

Implements

Constructors

Properties

aiPrefix: string = "AI"
humanPrefix: string = "Human"
maxTokenLimit: number = 2000
memoryKey: string = "history"
returnMessages: boolean
inputKey?: string
outputKey?: string

Accessors

Methods

  • Method to clear the chat history.

    Returns Promise<void>

    Promise that resolves when the chat history has been cleared.

Generated using TypeDoc