Defined in: packages/core/src/memory/memory.ts:49
TAdaptersTAdapters
extends Record
<string
, MessageAdapter
<unknown
, TMessageOptions
>> = Record
<string
, never
>
TMessageOptions
extends object
= object
new Memory<
TAdapters
,TMessageOptions
>(messages
,options
):Memory
<TAdapters
,TMessageOptions
>
Defined in: packages/core/src/memory/memory.ts:90
Parameters messagesMemoryMessage
<TMessageOptions
>[] = []
MemoryOptions
<TMessageOptions
> = {}
Memory
<TAdapters
, TMessageOptions
>
add(
message
):Promise
<void
>
Defined in: packages/core/src/memory/memory.ts:123
Add a message to the memory
Parameters messageunknown
The message to add to the memory
ReturnsPromise
<void
>
get<
K
>(options
):Promise
<K
extends keyofTAdapters
| keyof BuiltinAdapters<TMessageOptions> ?ReturnType
<TAdapters
&BuiltinAdapters
<TMessageOptions
>[K
<K
>]["fromMemory"
]>[] :never
>
Defined in: packages/core/src/memory/memory.ts:151
Get the messages of specific type from the memory
Type Parameters KK
extends string
| number
| symbol
= "llamaindex"
The options for the get method
type?K
ChatMessage
<TMessageOptions
>[]
Promise
<K
extends keyof TAdapters
| keyof BuiltinAdapters<TMessageOptions> ? ReturnType
<TAdapters
& BuiltinAdapters
<TMessageOptions
>[K
<K
>]["fromMemory"
]>[] : never
>
The messages of specific type
getLLM()getLLM(
llm
,transientMessages?
):Promise
<ChatMessage
[]>
Defined in: packages/core/src/memory/memory.ts:200
Get the messages from the memory, optionally including transient messages. only return messages that are within context window of the LLM
Parameters llmTo fit the result messages to the context window of the LLM (fallback to default llm if not provided). If llm is not specified in both the constructor and the method, the default token limit will be used.
undefined
| LLM
<object
, object
>
ChatMessage
<TMessageOptions
>[]
Optional transient messages to include.
ReturnsPromise
<ChatMessage
[]>
The messages from the memory, optionally including transient messages.
manageMemoryBlocks()manageMemoryBlocks():
Promise
<void
>
Defined in: packages/core/src/memory/memory.ts:338
Manage the memory blocks This method processes new messages into memory blocks when short-term memory exceeds its token limit. It uses a cursor system to track which messages have already been processed into long-term memory.
ReturnsPromise
<void
>
clear():
Promise
<void
>
Defined in: packages/core/src/memory/memory.ts:409
Clear all the messages in the memory
ReturnsPromise
<void
>
snapshot():
string
Defined in: packages/core/src/memory/memory.ts:420
Creates a snapshot of the current memory state Note: Memory blocks are not included in snapshots as they may contain non-serializable content. Memory blocks should be recreated when loading from snapshot.
Returnsstring
A JSON-serializable object containing the memory state
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4