Skip to main content

Cliente Python para mnemonexus — memória pra agentes de IA, open source, em português.

Project description

mnemonexus

PyPI version PyPI downloads License: MIT Python: 3.10+

Cliente Python oficial para o mnemonexus — memória pra agentes de IA, open source, em português.

Paridade com mem0 nas operações CRUD, mais o diferencial: compilação Karpathy, twice-rule pra lessons, grafo de entidades, staleness/supersede automáticos.

Instalação

pip install mnemonexus

Uso

from mnemonexus import Nexus

nexus = Nexus(api_url="http://localhost:8080", token="seu-token-sanctum")

# Paridade mem0
nexus.add("Reunião terça 14h", domain="memory")
result = nexus.search("quando é a reunião?")
print(result.answer)

# Twice rule — lesson aprendida
nexus.lesson(
    title="Sempre validar embedding dim antes de inserir em pgvector",
    body="Dim 1536 ≠ 1024 → INSERT explode silenciosamente",
    severity="critical",
)

# Decision com rationale
nexus.decision(
    title="Adotar pgvector em vez de Weaviate",
    description="Reduz containers; busca híbrida fica dentro de Eloquent",
    category="architecture",
)

# Grafo de entidades
graph = nexus.entity("foxpulse").graph()
for edge in graph.edges:
    print(edge.from_entity_slug, "→", edge.kind, "→", edge.to_entity_slug)

# Async também (recomendado em apps async)
import asyncio
from mnemonexus import AsyncNexus

async def main():
    async with AsyncNexus(token="...") as nexus:
        await nexus.add("…")
        r = await nexus.search("…")
asyncio.run(main())

API resumida

Paridade mem0

Método Endpoint O que faz
add(content, **) POST /ingest Adiciona memória
search(query, **) POST /query Recall híbrido (FTS + vetor)
get(slug) GET /pages/{slug} Lê página
update(slug, content) PUT /pages/{slug} Supersede
delete(slug) DELETE /pages/{slug} Hard delete
history(slug) GET /pages/{slug} Cadeia de versões

Diferencial mnemonexus

Método Endpoint O que faz
compile(slug) POST /pages/{slug}/compile Recompila wiki page
extract_facts(text) POST /facts/extract Facts + entidades + relações
lesson(title, body) POST /lessons Lesson com twice-rule
decision(title, description) POST /decisions Decisão com rationale
compact_session(id) PUT /sessions/{id} Fecha + sumariza sessão
entity(slug).graph() GET /entities/{slug}/graph Grafo BFS da entidade
search_entity(q) GET /entities Busca grafo de entidades

Errors

NexusError é a base. Subclasses:

  • AuthError — 401/403
  • NotFoundError — 404
  • ValidationError — 422

Cookbook

Veja examples/:

  1. 01_hello_world.py — add + search
  2. 02_with_karpathy.py — wiki compilada
  3. 03_with_lessons.py — twice rule
  4. 04_multi_tenant.py — isolamento por agent_id/tenant
  5. 05_rag_over_wiki.py — RAG com histórico

Dev

git clone https://github.com/lrdeoliveira/mnemonexus-python
cd mnemonexus-python
pip install -e ".[dev]"
pytest

Licença

MIT.

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

mnemonexus-0.2.0.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

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

mnemonexus-0.2.0-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file mnemonexus-0.2.0.tar.gz.

File metadata

  • Download URL: mnemonexus-0.2.0.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for mnemonexus-0.2.0.tar.gz
Algorithm Hash digest
SHA256 96fafd017d7e15bc358cf9c8202abc8f8388a37257bb6677d1010f427a7ac2ad
MD5 3edf485cfc71e742bc04bbe2a5f2f554
BLAKE2b-256 31930d77368458d2a0b13b3711276f15a42953b31d47334d9fa528c39a240e8c

See more details on using hashes here.

File details

Details for the file mnemonexus-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: mnemonexus-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for mnemonexus-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 987c9d34bf76e59af6025587b6089d15f6f1db75e50cb3be694f79083bf77fa7
MD5 bbd218dbe88c9127454bd9003d8ec0a4
BLAKE2b-256 ff2299e9cb43caf3229cc40d22cc5af8a0d84969cab6a6f83aea9653cc276d71

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