Class: abstract
BaseMemory<AdditionalMessageOptions>
A ChatMemory is used to keep the state of back and forth chat messages
Extended by
Type Parameters
• AdditionalMessageOptions extends object
= object
Constructors
new BaseMemory()
new BaseMemory<
AdditionalMessageOptions
>():BaseMemory
<AdditionalMessageOptions
>
Returns
BaseMemory
<AdditionalMessageOptions
>
Methods
_tokenCountForMessages()
protected
_tokenCountForMessages(messages
):number
Parameters
• messages: ChatMessage
[]
Returns
number
Defined in
packages/core/memory/dist/memory/index.d.ts:32
getAllMessages()
abstract
getAllMessages():ChatMessage
<AdditionalMessageOptions
>[] |Promise
<ChatMessage
<AdditionalMessageOptions
>[]>
Retrieves all messages stored in the memory.
Returns
ChatMessage
<AdditionalMessageOptions
>[] | Promise
<ChatMessage
<AdditionalMessageOptions
>[]>
An array of all chat messages, either synchronously or as a Promise.
Defined in
packages/core/memory/dist/memory/index.d.ts:22
getMessages()
abstract
getMessages(transientMessages
?):ChatMessage
<AdditionalMessageOptions
>[] |Promise
<ChatMessage
<AdditionalMessageOptions
>[]>
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
<AdditionalMessageOptions
>[]
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
ChatMessage
<AdditionalMessageOptions
>[] | Promise
<ChatMessage
<AdditionalMessageOptions
>[]>
An array of chat messages, either synchronously or as a Promise.
Defined in
packages/core/memory/dist/memory/index.d.ts:17
put()
abstract
put(messages
):void
Adds a new message to the memory.
Parameters
• messages: ChatMessage
<AdditionalMessageOptions
>
The chat message to be added to the memory.
Returns
void
Defined in
packages/core/memory/dist/memory/index.d.ts:27
reset()
abstract
reset():void
Clears all messages from the memory.
Returns
void
Defined in
packages/core/memory/dist/memory/index.d.ts:31