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.

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.0.tar.gz (2.3 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.0-py3-none-any.whl (2.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: human_memory-0.1.0.tar.gz
  • Upload date:
  • Size: 2.3 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.0.tar.gz
Algorithm Hash digest
SHA256 18ef66626e0fdc805b2292ff88774af12e07f8c30ef3510a333223a8998dc494
MD5 71e47d828c667e543a135933f67668a3
BLAKE2b-256 9d591850f83c32e471bca0d268db5b3039b8fd840bb2c1fcf4a01e1ef2c9d918

See more details on using hashes here.

File details

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

File metadata

  • Download URL: human_memory-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 2.2 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8f6e40d703b4cb618c48b733bf3981b207383cf370c0e141e56e29ce34441469
MD5 d0d03f8741582057dc88e105dfe61f8a
BLAKE2b-256 1b8423d3bf0b06bfcef6c30b0ca6b6cbf52a657d6d918626a09ae321bda614a0

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