Skip to main content

Official Python SDK for the Mnemosyne memory substrate. Sync and async clients, container-scoped storage, hybrid BM25+vector recall, full Pydantic type stubs. Talks to any Mnemosyne endpoint over HTTPS via httpx.

Project description

mnemosyne-sdk

PyPI version Python versions License: MIT CI

The official Python client for the Mnemosyne memory substrate. Synchronous and async APIs, container-scoped storage, hybrid BM25+vector recall, full type stubs. Talks to any Mnemosyne endpoint over HTTPS via httpx.

Mnemosyne gives any AI system persistent identity, episodic recall, contradiction resolution, metacognition, and a self-model that compounds across sessions. This SDK is the thin HTTP client that talks to a Mnemosyne Cloud or self-hosted Mnemosyne instance.

Install

pip install mnemosyne-sdk
# or
uv add mnemosyne-sdk
# or
poetry add mnemosyne-sdk

Quick start

from mnemosyne_sdk import Mnemosyne

mn = Mnemosyne(
    api_key="mn_...",  # from your Mnemosyne dashboard
    # base_url="https://api.mnemosyne.geasslabs.xyz",  # default
)

# Save a memory
memory = mn.add(
    "The dock-A camera lost calibration at 14:32 UTC",
    container_tag="fleet-ops",
    metadata={"severity": "high"},
)
print(memory.id)

# Search
results = mn.search("when did dock A fail?", container_tag="fleet-ops")
for r in results:
    print(f"{r.score:.3f}  {r.content}")

# Get / delete
one = mn.get(memory.id)
mn.delete(memory.id)

Async client

import asyncio
from mnemosyne_sdk import AsyncMnemosyne

async def main():
    async with AsyncMnemosyne(api_key="mn_...") as mn:
        await mn.add("...", container_tag="fleet-ops")
        results = await mn.search("query", container_tag="fleet-ops")

asyncio.run(main())

The async client shares the same httpx connection pool and is recommended for high-throughput agents.

Function-calling tools

from mnemosyne_sdk import TOOLS, execute_tool

# Pass TOOLS to any OpenAI-compatible function-calling API
response = client.chat.completions.create(
    model="gpt-4",
    messages=[...],
    tools=TOOLS,
)

# Execute a tool call from the model's response
for call in response.choices[0].message.tool_calls:
    result = execute_tool(
        call.function.name,
        call.function.arguments,
        base_url="https://api.mnemosyne.geasslabs.xyz",
        api_key="mn_...",
    )

Framework adapters

This package is the core client. For framework-specific integrations, install one of the dedicated adapter packages:

Framework Package Install
LangChain / LangGraph mnemosyne-langchain pip install mnemosyne-sdk[langchain]
CrewAI mnemosyne-crewai pip install mnemosyne-sdk[crewai]
AutoGen v0.4 mnemosyne-autogen pip install mnemosyne-sdk[autogen]
OpenAI Agents SDK mnemosyne-openai-agents pip install mnemosyne-sdk[openai-agents]

Or install everything: pip install mnemosyne-sdk[all].

Error handling

from mnemosyne_sdk import Mnemosyne, AuthenticationError, RateLimitError

mn = Mnemosyne(api_key="...")

try:
    mn.add("...")
except AuthenticationError:
    ...  # bad API key
except RateLimitError as e:
    time.sleep(e.retry_after or 1)
    ...  # back off

All errors inherit from MnemosyneError.

Configuration

Env var Description Default
MNEMOSYNE_API_KEY API key (overridden by constructor) -
MNEMOSYNE_BASE_URL Server URL https://api.mnemosyne.geasslabs.xyz
MNEMOSYNE_CONTAINER Default container tag default

Development

git clone https://github.com/synet-systems/mnemosyne
cd mnemosyne/packages/mnemosyne-sdk-python
uv sync --all-extras
uv run pytest

License

MIT © Geass Labs. The Mnemosyne engine this SDK talks to is licensed under the Mnemosyne Source-Available License v1.0. See NOTICE for the dual-license arrangement.

Links

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

mnemosyne_sdk-0.1.1.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

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

mnemosyne_sdk-0.1.1-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mnemosyne_sdk-0.1.1.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for mnemosyne_sdk-0.1.1.tar.gz
Algorithm Hash digest
SHA256 805b3e232edf827e8b1bae6e65e4221ade1c482dd2701e629b570a33ef72e183
MD5 3272982c2c27ef244d89322774116660
BLAKE2b-256 6b84abdaa3164a331fe7df9d3bd1e38bc71cfe06774ac1c12aa86647bf8422dc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mnemosyne_sdk-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for mnemosyne_sdk-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5049875ace2b643a607fbfb1eb1b719f23c6af963d19b9ec0ec278d7acf0ced4
MD5 0d41ec05baecf26ce2ad079482ac7b2a
BLAKE2b-256 03407b0028a9e7cf924b3f2f2ae1dc00cfde5943923bba634fed8fcf0966c77e

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