Memory command examples

This guide provides practical examples of using CansoMemory with Canso AI agents, including storing structured data, having memory-enhanced conversations, and utilizing the SQL Runner tool.

Prerequisites

Before trying these examples, make sure you have:

  • Deployed a Vector Database

  • Deployed a Canso AI Agent

  • Installed the GRU CLI tool

Storing Data in Memory

  1. Storing Database Table Metadata

Create a JSON file with detailed table metadata:

cat > customer_table_metadata.json << EOF
{
  "collection_name": "canso_table_metadata",
  "data": {
    "table_name": "customers",
    "schema": "CREATE TABLE customers (\n  id INT PRIMARY KEY,\n  first_name VARCHAR(50) NOT NULL,\n  last_name VARCHAR(50) NOT NULL,\n  email VARCHAR(100) UNIQUE NOT NULL,\n  phone VARCHAR(20),\n  address_line1 VARCHAR(100),\n  address_line2 VARCHAR(100),\n  city VARCHAR(50),\n  state VARCHAR(50),\n  postal_code VARCHAR(20),\n  country VARCHAR(50),\n  status VARCHAR(20) NOT NULL DEFAULT 'active',\n  customer_segment VARCHAR(20) CHECK (customer_segment IN ('standard', 'premium', 'vip', 'enterprise')),\n  acquisition_source VARCHAR(50),\n  lifetime_value DECIMAL(12,2),\n  loyalty_points INT DEFAULT 0,\n  date_of_birth DATE,\n  created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,\n  updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,\n  last_login_at TIMESTAMP,\n  CONSTRAINT valid_email CHECK (email ~* '^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}$')\n);",
  }
}
EOF

# Insert the table metadata using GRU CLI
gru agent memory insert --agent-name sql-assistant --file customer_table_metadata.json
  1. Adding Detailed Table Documentation

Create a JSON file with comprehensive table documentation:

  1. Store domain specific knowledge

Create a JSON file with domain-specific knowledge:

  1. Store column metadata information

Create a JSON file with the column metadata information:

Conversation with a Memory-Enhanced Agent

On the command line, you can converse with the agent by running the following command:

Last updated

Was this helpful?