@ai16z/eliza v0.1.3 / MemoryManager
Class: MemoryManager
Manage memories in the database.
Implements
Constructors
new MemoryManager()
new MemoryManager(
opts
):MemoryManager
Constructs a new MemoryManager instance.
Parameters
• opts
Options for the manager.
• opts.tableName: string
The name of the table this manager will operate on.
• opts.runtime: IAgentRuntime
The AgentRuntime instance associated with this manager.
Returns
Defined in
packages/core/src/memory.ts:36
Properties
runtime
runtime:
IAgentRuntime
The AgentRuntime instance associated with this manager.
Implementation of
Defined in
packages/core/src/memory.ts:23
tableName
tableName:
string
The name of the database table this manager operates on.
Implementation of
Defined in
packages/core/src/memory.ts:28
Methods
addEmbeddingToMemory()
addEmbeddingToMemory(
memory
):Promise
<Memory
>
Adds an embedding vector to a memory object. If the memory already has an embedding, it is returned as is.
Parameters
• memory: Memory
The memory object to add an embedding to.
Returns
Promise
<Memory
>
A Promise resolving to the memory object, potentially updated with an embedding vector.
Implementation of
IMemoryManager
.addEmbeddingToMemory
Defined in
packages/core/src/memory.ts:46
getMemories()
getMemories(
opts
):Promise
<Memory
[]>
Retrieves a list of memories by user IDs, with optional deduplication.
Parameters
• opts
Options including user IDs, count, and uniqueness.
• opts.roomId: `${string}-${string}-${string}-${string}-${string}`
The room ID to retrieve memories for.
• opts.count?: number
= 10
The number of memories to retrieve.
• opts.unique?: boolean
= true
Whether to retrieve unique memories only.
• opts.agentId?: `${string}-${string}-${string}-${string}-${string}`
• opts.start?: number
• opts.end?: number
Returns
Promise
<Memory
[]>
A Promise resolving to an array of Memory objects.
Implementation of
Defined in
packages/core/src/memory.ts:67
getCachedEmbeddings()
getCachedEmbeddings(
content
):Promise
<object
[]>
Parameters
• content: string
Returns
Promise
<object
[]>
Implementation of
IMemoryManager
.getCachedEmbeddings
Defined in
packages/core/src/memory.ts:94
searchMemoriesByEmbedding()
searchMemoriesByEmbedding(
embedding
,opts
):Promise
<Memory
[]>
Searches for memories similar to a given embedding vector.
Parameters
• embedding: number
[]
The embedding vector to search with.
• opts
Options including match threshold, count, user IDs, and uniqueness.
• opts.match_threshold?: number
The similarity threshold for matching memories.
• opts.agentId?: `${string}-${string}-${string}-${string}-${string}`
• opts.count?: number
The maximum number of memories to retrieve.
• opts.roomId: `${string}-${string}-${string}-${string}-${string}`
The room ID to retrieve memories for.
• opts.unique?: boolean
Whether to retrieve unique memories only.
Returns
Promise
<Memory
[]>
A Promise resolving to an array of Memory objects that match the embedding.
Implementation of
IMemoryManager
.searchMemoriesByEmbedding
Defined in
packages/core/src/memory.ts:121
createMemory()
createMemory(
memory
,unique
):Promise
<void
>
Creates a new memory in the database, with an option to check for similarity before insertion.
Parameters
• memory: Memory
The memory object to create.
• unique: boolean
= false
Whether to check for similarity before insertion.
Returns
Promise
<void
>
A Promise that resolves when the operation completes.
Implementation of
Defined in
packages/core/src/memory.ts:161
getMemoriesByRoomIds()
getMemoriesByRoomIds(
params
):Promise
<Memory
[]>
Parameters
• params
• params.agentId?: `${string}-${string}-${string}-${string}-${string}`
• params.roomIds: `${string}-${string}-${string}-${string}-${string}`[]
Returns
Promise
<Memory
[]>
Implementation of
IMemoryManager
.getMemoriesByRoomIds
Defined in
packages/core/src/memory.ts:178
getMemoryById()
getMemoryById(
id
):Promise
<Memory
>
Parameters
• id: `${string}-${string}-${string}-${string}-${string}`
Returns
Promise
<Memory
>
Implementation of
Defined in
packages/core/src/memory.ts:189
removeMemory()
removeMemory(
memoryId
):Promise
<void
>
Removes a memory from the database by its ID.
Parameters
• memoryId: `${string}-${string}-${string}-${string}-${string}`
The ID of the memory to remove.
Returns
Promise
<void
>
A Promise that resolves when the operation completes.
Implementation of
Defined in
packages/core/src/memory.ts:199
removeAllMemories()
removeAllMemories(
roomId
):Promise
<void
>
Removes all memories associated with a set of user IDs.
Parameters
• roomId: `${string}-${string}-${string}-${string}-${string}`
The room ID to remove memories for.
Returns
Promise
<void
>
A Promise that resolves when the operation completes.
Implementation of
IMemoryManager
.removeAllMemories
Defined in
packages/core/src/memory.ts:211
countMemories()
countMemories(
roomId
,unique
):Promise
<number
>
Counts the number of memories associated with a set of user IDs, with an option for uniqueness.
Parameters
• roomId: `${string}-${string}-${string}-${string}-${string}`
The room ID to count memories for.
• unique: boolean
= true
Whether to count unique memories only.
Returns
Promise
<number
>
A Promise resolving to the count of memories.