Class ConversationSummaryBufferMemory

Class that extends BaseConversationSummaryMemory and implements ConversationSummaryBufferMemoryInput. It manages the conversation history in a LangChain application by maintaining a buffer of chat messages and providing methods to load, save, prune, and clear the memory.

Hierarchy

Implements

Constructors

Properties

aiPrefix: string = "AI"
humanPrefix: string = "Human"
maxTokenLimit: number = 2000
memoryKey: string = "history"
movingSummaryBuffer: string = ""
prompt: BasePromptTemplate<any, BasePromptValue, any> = SUMMARY_PROMPT
returnMessages: boolean = false
summaryChatMessageClass: (new (content) => BaseMessage) = SystemMessage

Type declaration

inputKey?: string
outputKey?: string

Accessors

Methods

  • Predicts a new summary for the conversation given the existing messages and summary.

    Parameters

    • messages: BaseMessage[]

      Existing messages in the conversation.

    • existingSummary: string

      Current summary of the conversation.

    Returns Promise<string>

    A promise that resolves to a new summary string.

  • Method that prunes the memory if the total number of tokens in the buffer exceeds the maxTokenLimit. It removes messages from the beginning of the buffer until the total number of tokens is within the limit.

    Returns Promise<void>

    Promise that resolves when the memory is pruned.

  • Method that saves the context of the conversation, including the input and output values, and prunes the memory if it exceeds the maximum token limit.

    Parameters

    • inputValues: InputValues

      InputValues object containing the input values of the conversation.

    • outputValues: OutputValues

      OutputValues object containing the output values of the conversation.

    Returns Promise<void>

    Promise that resolves when the context is saved and the memory is pruned.

Generated using TypeDoc