Skip to main content

Class: ChatSummaryMemoryBuffer

A ChatMemory is used to keep the state of back and forth chat messages

Extends

Constructors

new ChatSummaryMemoryBuffer()

new ChatSummaryMemoryBuffer(options?): ChatSummaryMemoryBuffer

Parameters

options?: Partial<ChatSummaryMemoryBuffer>

Returns

ChatSummaryMemoryBuffer

Overrides

BaseMemory.constructor

Defined in

packages/core/memory/dist/index.d.ts:67

Properties

llm

llm: LLM<object, object>

Defined in

packages/core/memory/dist/index.d.ts:66


messages

messages: ChatMessage[]

Defined in

packages/core/memory/dist/index.d.ts:64


summaryPrompt

summaryPrompt: SummaryPrompt

Defined in

packages/core/memory/dist/index.d.ts:65


tokenizer

tokenizer: Tokenizer

Tokenizer function that converts text to tokens, this is used to calculate the number of tokens in a message.

Defined in

packages/core/memory/dist/index.d.ts:62


tokensToSummarize

tokensToSummarize: number

Defined in

packages/core/memory/dist/index.d.ts:63

Methods

_tokenCountForMessages()

protected _tokenCountForMessages(messages): number

Parameters

messages: ChatMessage[]

Returns

number

Inherited from

BaseMemory._tokenCountForMessages

Defined in

packages/core/memory/dist/index.d.ts:32


getAllMessages()

getAllMessages(): Promise<ChatMessage[]>

Retrieves all messages stored in the memory.

Returns

Promise<ChatMessage[]>

An array of all chat messages, either synchronously or as a Promise.

Overrides

BaseMemory.getAllMessages

Defined in

packages/core/memory/dist/index.d.ts:82


getLastSummary()

getLastSummary(): null | ChatMessage

Returns

null | ChatMessage

Defined in

packages/core/memory/dist/index.d.ts:70


getMessages()

getMessages(transientMessages?): Promise<ChatMessage[]>

Retrieves messages from the memory, optionally including transient messages. Compared to getAllMessages, this method a) allows for transient messages to be included in the retrieval and b) may return a subset of the total messages by applying a token limit.

Parameters

transientMessages?: ChatMessage[]

Optional array of temporary messages to be included in the retrieval. These messages are not stored in the memory but are considered for the current interaction.

Returns

Promise<ChatMessage[]>

An array of chat messages, either synchronously or as a Promise.

Overrides

BaseMemory.getMessages

Defined in

packages/core/memory/dist/index.d.ts:81


put()

put(message): void

Adds a new message to the memory.

Parameters

message: ChatMessage

Returns

void

Overrides

BaseMemory.put

Defined in

packages/core/memory/dist/index.d.ts:83


reset()

reset(): void

Clears all messages from the memory.

Returns

void

Overrides

BaseMemory.reset

Defined in

packages/core/memory/dist/index.d.ts:80