Agent with Memory

This guide will walk you through setting up and deploying an AI agent with memory capabilities using the Canso AI Agentic System. We'll create a memory-agent that can store and retrieve information from a vector database, enhancing its ability to maintain context across interactions.

Prerequisites

Before proceeding, ensure you have:

  1. Canso Helm charts installed on your cluster

  2. Gru CLI installed (follow the instructions here)

Setting Up Components

Our memory-agent requires several components:

  • A Vector Database for memory storage

  • A Broker for task orchestration

  • A Checkpoint DB for saving agent state

  • A Task Server for executing long-running tasks

First, create a file named config.yaml with the following configuration:

vector_db:
  type: milvus
  name: my-vector-db
  size: 4Gi
  image_pull_secret: docker-secret-cred-agents

broker:
  type: redis
  name: my-redis

checkpoint_db:
  type: postgres
  name: my-postgres
  size: 4Gi

task_server:
  type: celery
  name: my-task-server
  replicas: 1
  concurrency_per_replica: 1
  broker_resource_name: my-redis

Next, run the command to set up all components:

Creating the Project Bootstrap

Generate the scaffold for our project:

When prompted, provide the following inputs:

This creates a folder named memory-agent with the following structure:

Updating Dependencies

Update requirements.txt with all necessary dependencies:

Developing the Memory-Enabled Agent

Replace the content of src/main.py with the following code:

Setting Up Environment Variables

Create or update the .env file with the following content:

Building and Pushing the Docker Image

Build the Docker image and push it to your container registry:

Registering and Deploying the Agent

Register and deploy your agent with:

Storing Initial Memory Data

Before interacting with your agent, let's store some initial data in its memory.

Create a JSON file named customer_data.json:

Insert this data into agent's memory

This command will return the name of the memory where the data was inserted, which you can use for update and delete operations.

Updating existing Data in Memory

With this operation, you can also update certain attributes of the data you previously added.

Create a JSON file named customer_update_data.json:

Update this data in the agent's memory.

Delete the existing Data from Memory

You can also delete the previously stored elements from memory by.

Interacting with the Memory-Enabled Agent

Start a conversation with your agent:

Example interaction:

Additional Resources

Last updated

Was this helpful?