Skip to main content

A Python SDK for storing structured memory objects in Supabase using OpenAI's API

Project description

Memory SDK

A Python SDK for storing structured memory objects in Supabase using OpenAI's API.

Documentation

Documentation

For complete documentation, visit our documentation website.

Installation

# Clone the repository
git clone https://github.com/deadcow-labs/human-memory.git
cd human-memory

# Install dependencies
pip install -r requirements.txt

Requirements

Create a requirements.txt file with the following dependencies:

openai>=1.0.0
supabase>=2.0.0
python-dotenv>=1.0.0

Configuration

The SDK requires the following environment variables:

  • OPENAI_API_KEY: Your OpenAI API key
  • SUPABASE_URL: Your Supabase project URL
  • SUPABASE_KEY: Your Supabase API key

You can set these in your environment or use a .env file with python-dotenv.

Supabase Setup

Create a memories table in your Supabase project with the following schema:

create table
  public.memories (
    id uuid primary key,
    user_id text not null,
    created_at timestamp with time zone not null,
    content text not null,
    reflection text not null,
    embedding vector(1536) not null,
    emotional_tone text not null,
    location jsonb not null,
    tags text[] not null
  );

Enable RLS (Row Level Security) on your table and create appropriate policies.

Usage

from memory_sdk import MemorySDK

# Initialize the SDK with a user ID
user_id = "user_123"
sdk = MemorySDK(user_id)

# Save a memory from a raw message
raw_message = "Today I made significant progress on my project and feel optimistic about finishing it soon."
memory = sdk.save(raw_message)

# The memory object contains all structured data:
print(f"Content: {memory.content}")
print(f"Reflection: {memory.reflection}")
print(f"Emotional tone: {memory.emotional_tone}")

See example.py for a complete usage example.

Memory Structure

Each memory includes:

  • id: UUID
  • user_id: provided by the SDK user
  • created_at: UTC timestamp
  • content: short summary of the message
  • reflection: insight about the user from the message
  • embedding: vector from OpenAI embedding API
  • emotional_tone: e.g. "hopeful", "anxious"
  • location: dict with type and name
  • tags: list of string topics or themes

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

human_memory-0.1.1.tar.gz (2.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

human_memory-0.1.1-py3-none-any.whl (2.3 kB view details)

Uploaded Python 3

File details

Details for the file human_memory-0.1.1.tar.gz.

File metadata

  • Download URL: human_memory-0.1.1.tar.gz
  • Upload date:
  • Size: 2.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for human_memory-0.1.1.tar.gz
Algorithm Hash digest
SHA256 932cfb4f9d63baefea400e29094bd0ecc86790ab25706ab74bf901d91ef7e544
MD5 ed354765b55c8240d5f0f46a2c7b8954
BLAKE2b-256 fc86f476850626b88339fd02c23f37ac5e5387ef5c172d163b543f2411d33438

See more details on using hashes here.

File details

Details for the file human_memory-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: human_memory-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 2.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for human_memory-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b0f7182d72fa1e811074967e2f6dac1460f8a06557f45d457b37e50e9ef4e0c8
MD5 4ee6398a32ae8a69bb8c6dbc101f247e
BLAKE2b-256 dc33ff13e55fca684067fef964874696c30d19e82ccecb139faf1f8d208a9ffe

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page