Skip to main content

Universal Memory Layer for AI Agents - Python SDK

Project description

MemoraDB Python SDK

Universal Memory Layer for AI Agents - The S3 + Redis for AI Memory

Installation

pip install memoradb

Quick Start

from memoradb import MemoraDB
import asyncio

async def main():
    # Initialize client
    client = MemoraDB(
        api_url="https://api.memoradb.com",
        api_key="your-api-key"
    )
    
    # Store a memory
    result = await client.write(
        namespace_id="your-namespace",
        owner_id="user-123", 
        session_id="session-456",
        text="User prefers dark mode and wants weekly reports",
        kind="preference"
    )
    
    # Retrieve relevant memories
    memories = await client.retrieve(
        namespace_id="your-namespace",
        owner_id="user-123",
        query="user preferences",
        k=5
    )
    
    print(f"Found {len(memories.results)} relevant memories")

asyncio.run(main())

Features

  • 🧠 Persistent Memory: Store and retrieve memories across sessions
  • 🔄 Portable Memory: Share context between different AI agents
  • 🔍 Semantic Search: Find relevant memories using vector similarity
  • 📄 Automatic Summarization: Compress memories into summaries
  • 🛡️ GDPR Compliant: Right to forget and data portability
  • 🏷️ Multi-kind Storage: Support for user messages, agent responses, tool outputs, and notes

API Reference

Write Memory

await client.write(
    namespace_id="namespace-uuid",
    owner_id="user-uuid",
    session_id="session-uuid", 
    text="Memory content",
    kind="user_msg",  # user_msg, agent_msg, tool_io, note
    metadata={"key": "value"},
    pii_tags=["email", "phone"]
)

Retrieve Memories

memories = await client.retrieve(
    namespace_id="namespace-uuid",
    owner_id="user-uuid",
    query="search query",
    k=10,
    use_summaries=True
)

Context Packing

context = await client.context_pack(
    namespace_id="namespace-uuid", 
    owner_id="user-uuid",
    query="context query",
    budget_tokens=1000,
    include_summaries=True
)

Forget Memories (GDPR)

await client.forget(
    namespace_id="namespace-uuid",
    owner_id="user-uuid", 
    reason="user_request"
)

License

MIT License - see LICENSE file for details.

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

memoradb_sdk-0.1.0.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

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

memoradb_sdk-0.1.0-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: memoradb_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for memoradb_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5b8e97573aace0264182102332e13b652c30f916cd1318e38eaa0c6c7ef65ba0
MD5 e6922e4206b63ef35d53f37b39423198
BLAKE2b-256 b4451d528a8132fb10b36bbfa9129bd82dd51122f7de9665dd26195d1ccaa74b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: memoradb_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for memoradb_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bc94f4e5258fd79ee5ea2936dc08e5e6b7500ca5151631897d935dd5dad0eda0
MD5 7749d8737f4e4480b8d5ed374f7a8e2c
BLAKE2b-256 f922b0c67f11234b4d433d846442f84a407f3f28cc670b68cd410094d8ee622b

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