Skip to main content

Sgraal memory governance integration for mem0

Project description

mem0-sgraal

Sgraal memory governance integration for mem0. Validates memory entries with the Sgraal preflight protocol before your agent acts on them.

Install

pip install mem0-sgraal

Quick Start — Preflight Hook

The simplest way to add Sgraal validation to mem0 memories:

from mem0_sgraal import preflight_hook

memories = [
    {"id": "m1", "memory": "User prefers fintech", "score": 0.9},
    {"id": "m2", "memory": "Account balance $50K", "score": 0.85},
]

safe = preflight_hook(
    memories,
    domain="fintech",
    api_key="sg_demo_playground"  # or set SGRAAL_API_KEY env var
)

# safe = only memories that passed preflight (USE_MEMORY)
for m in safe:
    print(f"{m['id']}: {m['sgraal_decision']} (omega={m['sgraal_omega']})")

Full Client — mem0 + Sgraal

import os
from mem0_sgraal import Mem0SgraalClient

client = Mem0SgraalClient(
    sgraal_api_key=os.environ["SGRAAL_API_KEY"],
    mem0_api_key=os.environ["MEM0_API_KEY"]
)

# Search with safety validation
result = client.safe_search(
    query="user preferences",
    user_id="alice",
    domain="fintech",
    action_type="irreversible"
)

print(f"Safe: {result['preflight_summary']['safe_count']}/{result['preflight_summary']['total']}")
for m in result["safe_memories"]:
    print(f"  {m['memory']} (omega={m['sgraal_omega']})")

# Add with validation
client.safe_add(
    messages=[{"role": "user", "content": "I prefer email notifications"}],
    user_id="alice"
)

Environment Variables

export SGRAAL_API_KEY=sg_live_...   # Required
export MEM0_API_KEY=m0-...           # Required for Mem0SgraalClient

Demo Key

Use sg_demo_playground for testing Sgraal — no signup needed.

Links

License

Apache 2.0

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

mem0_sgraal-0.1.0.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

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

mem0_sgraal-0.1.0-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mem0_sgraal-0.1.0.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for mem0_sgraal-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f48659557164b8bd350a8f4c96fbef068f8efe138ee4e0287f035757cdeee793
MD5 116abffb5a9373db58be643e6c451c94
BLAKE2b-256 a9700dc6d3df38a243cc51fcb2e310f021b993103367e15f6907c72c42b1b35b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mem0_sgraal-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for mem0_sgraal-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5e768f47601d2f916923185074b13f8890bd2c83c1ed10c939eddd8e4274f92c
MD5 e38a3028d71bbbfc669b462792cb4b30
BLAKE2b-256 e5c6a1726354baaf7ff360f326d11e1048d0af3f898cb0bc0c3ce623772f7d29

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