Skip to content

Latest commit

 

History

History
87 lines (58 loc) · 3.6 KB

File metadata and controls

87 lines (58 loc) · 3.6 KB

MemMachine Memory Example

Complexity: 🟨 Intermediate

This example demonstrates how to use MemMachine as a long-term memory backend for NeMo Agent Toolkit agents. MemMachine provides unified episodic and semantic memory management backed by PostgreSQL and Neo4j.

Table of Contents

Key Features

  • Episodic and Semantic Memory: Stores memories from conversations and direct facts into both episodic and semantic memory layers, enabling rich retrieval by context.
  • ReAct Agent with Memory Tools: Demonstrates a ReAct agent equipped with get_memory and add_memory tools that can recall and persist user preferences across interactions.
  • Docker-Based MemMachine Service: MemMachine runs as a Docker service (PostgreSQL + Neo4j + MemMachine app), so no local server process is needed in the notebook.

Prerequisites

  • Docker installed and running — see the Docker Installation Guide
  • An NVIDIA API key from NVIDIA Build
  • An OpenAI API key (or AWS Bedrock credentials) for MemMachine's embedding and language models

Installation and Setup

If you have not already done so, follow the Install Guide to create the development environment and install NeMo Agent Toolkit.

Install the required packages from the repository root:

uv pip install -e ".[langchain,memmachine]"

Configure MemMachine

Edit examples/memory/memmachine/configuration.yml and replace the API key placeholders with your actual credentials:

  • <OPENAI_API_KEY> — your OpenAI API key
  • <AWS_ACCESS_KEY_ID> / <AWS_SECRET_ACCESS_KEY> — only needed if using AWS Bedrock models

The file is pre-configured to connect to the PostgreSQL and Neo4j containers using the default credentials in docker-compose.memmachine.yml. No changes to the database section are needed unless you override the defaults.

Start Services

Start MemMachine (PostgreSQL, Neo4j, and the MemMachine app) from the repository root:

docker compose -f examples/deploy/docker-compose.memmachine.yml up -d

By default, the MemMachine API is available at http://localhost:8095. See examples/deploy/README.md for full start/stop instructions.

Run the Example

Open and run the notebook from the repository root:

jupyter lab examples/memory/memmachine/memmachine_memory_example.ipynb

The notebook walks through:

  1. Connecting to the running MemMachine Docker service
  2. Adding memories from conversations and directly
  3. Searching memories
  4. Running a ReAct agent that uses memory tools to recall and store user preferences