Metadata-Version: 2.4
Name: mnemosyne-sdk
Version: 0.1.1
Summary: 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.
Author-email: Mashle Burneded <mashle@geasslabs.xyz>
Maintainer-email: Geass Labs <team@geasslabs.xyz>
License: MIT License
        
        Copyright (c) 2026 Geass Labs
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://mnemosyne.geasslabs.xyz
Project-URL: Documentation, https://docs.geasslabs.xyz/mnemosyne-sdk
Project-URL: Repository, https://github.com/synet-systems/mnemosyne/tree/main/packages/mnemosyne-sdk-python
Project-URL: Issues, https://github.com/synet-systems/mnemosyne/issues
Project-URL: Changelog, https://github.com/synet-systems/mnemosyne/blob/main/packages/mnemosyne-sdk-python/CHANGELOG.md
Keywords: mnemosyne,ai,llm,memory,agent,agent-memory,rag,retrieval-augmented-generation,long-term-memory,vector-search,sdk
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Typing :: Typed
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: LICENSE-MIT
License-File: NOTICE
Requires-Dist: httpx>=0.27.0
Requires-Dist: pydantic>=2.7.0
Provides-Extra: dev
Requires-Dist: pytest>=8.0.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.23.0; extra == "dev"
Requires-Dist: pytest-cov>=5.0.0; extra == "dev"
Requires-Dist: ruff>=0.5.0; extra == "dev"
Requires-Dist: mypy>=1.10.0; extra == "dev"
Requires-Dist: respx>=0.21.0; extra == "dev"
Requires-Dist: anyio>=4.0.0; extra == "dev"
Provides-Extra: all
Requires-Dist: mnemosyne-langchain>=0.1.0; extra == "all"
Requires-Dist: mnemosyne-crewai>=0.1.0; extra == "all"
Requires-Dist: mnemosyne-autogen>=0.1.0; extra == "all"
Requires-Dist: mnemosyne-openai-agents>=0.1.0; extra == "all"
Dynamic: license-file

# mnemosyne-sdk

[![PyPI version](https://img.shields.io/pypi/v/mnemosyne-sdk.svg)](https://pypi.org/project/mnemosyne-sdk/)
[![Python versions](https://img.shields.io/pypi/pyversions/mnemosyne-sdk.svg)](https://pypi.org/project/mnemosyne-sdk/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](./LICENSE)
[![CI](https://github.com/synet-systems/mnemosyne/actions/workflows/ci.yml/badge.svg)](https://github.com/synet-systems/mnemosyne/actions)

> 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

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

## Quick start

```python
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

```python
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

```python
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

```python
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

```bash
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](https://geasslabs.xyz). The Mnemosyne *engine* this SDK talks to is licensed under the [Mnemosyne Source-Available License v1.0](https://github.com/synet-systems/mnemosyne/blob/main/LICENSE). See [`NOTICE`](https://github.com/synet-systems/mnemosyne/blob/main/NOTICE) for the dual-license arrangement.

## Links

- **Homepage**: https://mnemosyne.geasslabs.xyz
- **Documentation**: https://docs.geasslabs.xyz/mnemosyne-sdk
- **Repository**: https://github.com/synet-systems/mnemosyne
- **Issues**: https://github.com/synet-systems/mnemosyne/issues
- **Changelog**: [CHANGELOG.md](./CHANGELOG.md)
