Skip to main content

Python SDK for Zyra SNN Memory Database - Brain-inspired memory for AI agents

Project description

Miruvor

Python SDK for Zyra SNN Memory Database - Brain-inspired memory for AI agents.

Features

  • Simple API: Three core methods - store(), ingest(), retrieve()
  • Pattern Completion: O(L) retrieval via pointer layer - no training required
  • Sync & Async: Both MiruvorClient and AsyncMiruvorClient
  • Type Safe: Full Pydantic v2 models with validation
  • Production Ready: Automatic retries, timeouts, logging, error handling
  • Batch Operations: Efficient batch store with concurrency control
  • Health Checks: Built-in health monitoring

Installation

pip install miruvor

Quick Start

Sync Usage

from miruvor import MiruvorClient

# Defaults to production. Set MIRUVOR_BASE_URL for dev (e.g. http://localhost:8000).
# Set MIRUVOR_API_KEY in env to skip passing api_key.
client = MiruvorClient(api_key="your-api-key", token="your-jwt-token")  # token optional

# Store a memory
response = client.store(
    text="The user prefers dark mode and likes Python",
    tags=["preferences", "user"],
    metadata={"source": "settings"}
)
print(f"Stored: {response.memory_id} in {response.storage_time_ms:.2f}ms")

# Retrieve memories
results = client.retrieve(query="What does the user prefer?", top_k=5)
for memory in results.results:
    print(f"[{memory.score:.3f}] {memory.data['text']}")

# Ingest with LLM enhancement
ingest_response = client.ingest(content="Long document...", priority="high")
print(f"Queued: {ingest_response.message_id}")

client.close()

Async Usage

import asyncio
from miruvor import AsyncMiruvorClient

async def main():
    async with AsyncMiruvorClient(api_key="your-api-key", token="your-jwt-token") as client:
        response = await client.store(text="User loves async/await", tags=["preferences"])
        results = await client.retrieve(query="What does user love?")
        print(f"Found {results.num_results} memories")

asyncio.run(main())

Batch Operations

import asyncio
from miruvor import AsyncMiruvorClient

async def batch_example():
    async with AsyncMiruvorClient(api_key="...", token="...") as client:
        memories = [
            {"text": "Memory 1", "tags": ["tag1"]},
            {"text": "Memory 2", "tags": ["tag2"]},
            {"text": "Memory 3", "tags": ["tag3"]},
        ]
        responses = await client.store_batch(memories, max_concurrent=10)
        print(f"Stored {len(responses)} memories")

asyncio.run(batch_example())

API Reference

MiruvorClient / AsyncMiruvorClient

Constructor: MiruvorClient(api_key, base_url=None, token=None, timeout=30.0, max_retries=3)base_url defaults to production; override with MIRUVOR_BASE_URL env.

Methods:

  • health() - Check API health status
  • store(text, tags=None, metadata=None) - Store a memory
  • store_batch(memories, max_concurrent=10) - Store multiple memories (async has concurrency)
  • ingest(content, priority="normal", ...) - Ingest with LLM enhancement
  • retrieve(query, top_k=5, use_sparse=None) - Retrieve via pattern completion

Error Handling

from miruvor import MiruvorClient, AuthenticationError, RateLimitError, ValidationError

try:
    response = client.store(text="Hello world")
except AuthenticationError as e:
    print(f"Auth failed: {e.message}")
except RateLimitError as e:
    print(f"Retry after {e.retry_after} seconds")
except ValidationError as e:
    print(f"Validation error: {e.message}")

Examples

See the examples/ directory:

  • quickstart.py - Basic sync usage
  • async_example.py - Async operations
  • batch_ingestion.py - Batch operations with concurrency

Development

pip install -e ".[dev]"
pytest
black src/ tests/
ruff check src/ tests/
mypy src/

Requirements

  • Python 3.9+
  • requests >= 2.31.0
  • httpx >= 0.27.0
  • pydantic >= 2.0.0
  • urllib3 >= 2.0.0

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

miruvor-0.1.1.tar.gz (8.1 MB view details)

Uploaded Source

Built Distribution

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

miruvor-0.1.1-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: miruvor-0.1.1.tar.gz
  • Upload date:
  • Size: 8.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for miruvor-0.1.1.tar.gz
Algorithm Hash digest
SHA256 f02c8d14403b0c2cfd24424717b405c6e905a7ff2024f6f4f88bfe26b094102a
MD5 c141861ac68a2eea45c761782ff17990
BLAKE2b-256 202c7f68e08f5f0e34c85d425f26989d173e07410e561821921a8cd4d1062f92

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for miruvor-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 39fe731b54be012c7478ad8ca420c112d42539efa0277f6bad129eb4f870d7a9
MD5 b8de1672c3b203bdd2ee8055b26f08b1
BLAKE2b-256 9b6d5040dfe9da70265e5e8880461f07a5b5ae9c59fc5dd2b8674baf80867190

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