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

client = MiruvorClient(
    base_url="https://api.aws.eu-west-2.cerebrium.ai/v4/p-1059a0f6/zyra-snn-db",
    api_key="your-api-key",
    token="your-jwt-token"
)

# 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(
        base_url="https://api.aws.eu-west-2.cerebrium.ai/v4/p-1059a0f6/zyra-snn-db",
        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(base_url="...", 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(base_url, api_key, token=None, timeout=30.0, max_retries=3)

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.0.tar.gz (13.2 kB 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.0-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for miruvor-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1a1f7df80b278729e21c1f9e2b1967b228e52774ca33ce40bfb94a50f913a245
MD5 c70f40f97c5a91edff50a28afe97b3a8
BLAKE2b-256 694de87b1c8becad6c10e2ed9e5f1fc5a7a34fc1d8889e208139be00f7d98668

See more details on using hashes here.

File details

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

File metadata

  • Download URL: miruvor-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.4 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 efc1c162bdeab40a25df43357e380d980f073c273ba2252c1cdfaaf95c1d7a55
MD5 7a3352295c57ebb7dc498e8f9377c8ea
BLAKE2b-256 f6d81be03569298b6b4572d7ab2de0c2e7ac9a6f20eb5fc89cee471934b4bf35

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