@elizaos/core v0.1.7-alpha.1 / MemoryManager
Manage memories in the database.
new MemoryManager(
opts
):MemoryManager
Constructs a new MemoryManager instance.
• 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.
packages/core/src/memory.ts:33
runtime:
IAgentRuntime
The AgentRuntime instance associated with this manager.
packages/core/src/memory.ts:20
tableName:
string
The name of the database table this manager operates on.
packages/core/src/memory.ts:25
addEmbeddingToMemory(
memory
):Promise
<Memory
>
Adds an embedding vector to a memory object if one doesn't already exist. The embedding is generated from the memory's text content using the runtime's embedding model. If the memory has no text content, an error is thrown.
• memory: Memory
The memory object to add an embedding to
Promise
<Memory
>
The memory object with an embedding vector added
Error if the memory content is empty
IMemoryManager
.addEmbeddingToMemory
packages/core/src/memory.ts:52
getMemories(
opts
):Promise
<Memory
[]>
Retrieves a list of memories by user IDs, with optional deduplication.
• 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.start?: number
• opts.end?: number
Promise
<Memory
[]>
A Promise resolving to an array of Memory objects.
packages/core/src/memory.ts:87
getCachedEmbeddings(
content
):Promise
<object
[]>
• content: string
Promise
<object
[]>
IMemoryManager
.getCachedEmbeddings
packages/core/src/memory.ts:111
searchMemoriesByEmbedding(
embedding
,opts
):Promise
<Memory
[]>
Searches for memories similar to a given embedding vector.
• 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.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.
Promise
<Memory
[]>
A Promise resolving to an array of Memory objects that match the embedding.
IMemoryManager
.searchMemoriesByEmbedding
packages/core/src/memory.ts:137
createMemory(
memory
,unique
):Promise
<void
>
Creates a new memory in the database, with an option to check for similarity before insertion.
• memory: Memory
The memory object to create.
• unique: boolean
= false
Whether to check for similarity before insertion.
Promise
<void
>
A Promise that resolves when the operation completes.
packages/core/src/memory.ts:172
getMemoriesByRoomIds(
params
):Promise
<Memory
[]>
• params
• params.roomIds: `${string}-${string}-${string}-${string}-${string}`[]
Promise
<Memory
[]>
IMemoryManager
.getMemoriesByRoomIds
packages/core/src/memory.ts:192
getMemoryById(
id
):Promise
<Memory
>
• id: `${string}-${string}-${string}-${string}-${string}`
Promise
<Memory
>
packages/core/src/memory.ts:200
removeMemory(
memoryId
):Promise
<void
>
Removes a memory from the database by its ID.
• memoryId: `${string}-${string}-${string}-${string}-${string}`
The ID of the memory to remove.
Promise
<void
>
A Promise that resolves when the operation completes.
packages/core/src/memory.ts:211
removeAllMemories(
roomId
):Promise
<void
>
Removes all memories associated with a set of user IDs.
• roomId: `${string}-${string}-${string}-${string}-${string}`
The room ID to remove memories for.
Promise
<void
>
A Promise that resolves when the operation completes.
IMemoryManager
.removeAllMemories
packages/core/src/memory.ts:223
countMemories(
roomId
,unique
):Promise
<number
>
Counts the number of memories associated with a set of user IDs, with an option for uniqueness.
• roomId: `${string}-${string}-${string}-${string}-${string}`
The room ID to count memories for.
• unique: boolean
= true
Whether to count unique memories only.
Promise
<number
>
A Promise resolving to the count of memories.