A Python SDK for storing structured memory objects in Supabase using OpenAI's API.
# Clone the repository
git clone https://github.com/deadcow-labs/human-memory.git
cd human-memory
# Install dependencies
pip install -r requirements.txtCreate a requirements.txt file with the following dependencies:
openai>=1.0.0
supabase>=2.0.0
python-dotenv>=1.0.0
The SDK requires the following environment variables:
OPENAI_API_KEY: Your OpenAI API keySUPABASE_URL: Your Supabase project URLSUPABASE_KEY: Your Supabase API key
You can set these in your environment or use a .env file with python-dotenv.
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.
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.
Each memory includes:
id: UUIDuser_id: provided by the SDK usercreated_at: UTC timestampcontent: short summary of the messagereflection: insight about the user from the messageembedding: vector from OpenAI embedding APIemotional_tone: e.g. "hopeful", "anxious"location: dict with type and nametags: list of string topics or themes
MIT