Class BufferWindowMemory

Class for managing and storing previous chat messages. It extends the BaseChatMemory class and implements the BufferWindowMemoryInput interface. This class is stateful and stores messages in a buffer. When called in a chain, it returns all of the messages it has stored.

Hierarchy

Implements

Constructors

Properties

aiPrefix: string = "AI"
humanPrefix: string = "Human"
k: number = 5
memoryKey: string = "history"
returnMessages: boolean = false
inputKey?: string
outputKey?: string

Accessors

Methods

  • Method to load the memory variables. Retrieves the chat messages from the history, slices the last 'k' messages, and stores them in the memory under the memoryKey. If the returnMessages property is set to true, the method returns the messages as they are. Otherwise, it returns a string representation of the messages.

    Parameters

    Returns Promise<MemoryVariables>

    Promise that resolves to a MemoryVariables object.

Generated using TypeDoc