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.0.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.0-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mnemosyne_sdk-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 fb5ed86efe2ce2d9926e87bc0a873f55e6d202993069486103e7e2b13901fdde
MD5 93350b17b790bc6dabb9c46203c74fae
BLAKE2b-256 8c0669e3becbfb1549d4bba878694a91a32f8cac9a1c0564478a8fa6bb4edf23

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mnemosyne_sdk-0.1.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 769b94d34aaaa780da3845964836419b678b95e5273f393e143653a3e38928bd
MD5 744b4d47be81852ea9234e1d990e90e1
BLAKE2b-256 b48f452be9a82b9c759a4ba42ff44a1471477f4d88860641f7a4cc799969f1bf

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