Overview
TheMemMachineMemory class provides the primary interface for interacting with the memory engine. It allows for high-granularity control over adding, searching, listing, and deleting memories.
Key Capabilities
- Flexible Ingestion: Add raw text as memories with specific episode types.
- Semantic Retrieval: Search memories using natural language queries.
- Context Awareness: Retrieve combined project and memory metadata.
Constructor
new MemMachineMemory()
Initializes a new memory management instance. This is typically handled internally by the MemMachineProject.memory() factory method.
| Parameter | Type | Description |
|---|---|---|
client | AxiosInstance | Internal Axios instance for API communication. |
projectContext | ProjectContext | Scoping options including org_id and project_id. |
memoryContext | MemoryContext | (Optional) Specific identifiers for the memory scope (e.g., user_id). |
Properties
| Property | Type | Description |
|---|---|---|
client | AxiosInstance | The underlying HTTP client. |
projectContext | ProjectContext | The organizational and project scope for this instance. |
memoryContext | MemoryContext | The specific user or session context for this instance. |
Methods
add()
Adds a new memory to the system within the current project scope.
| Parameter | Type | Description |
|---|---|---|
content | string | The raw text content of the memory. |
options | AddMemoryOptions | (Optional) Metadata like episode_type. |
search()
Performs a semantic and or episodic search against the stored memories.
| Parameter | Type | Description |
|---|---|---|
query | string | The natural language search term. |
options | SearchMemoriesOptions | (Optional) Search filters such as top_k, filter, types, and agent_mode. |
list()
Retrieves a paginated list of memories.
| Parameter | Type | Description |
|---|---|---|
options | ListMemoriesOptions | (Optional) Pagination settings (page_size, page_num). |
delete()
Permanently removes a memory from the system.
| Parameter | Type | Description |
|---|---|---|
id | string | The unique identifier of the memory. |
type | MemoryType | The classification of memory (e.g., episodic). |
getContext()
Retrieves the active project and memory context used by this instance.
- Returns:
ProjectContext & MemoryContext
Usage Example
All methods in this class throw a
MemMachineAPIError if the server returns a non-200 status code.
