Self-organizing graph memory for AI agents — Python SDK
Project description
cortex-memory-client
Python client SDK for the Cortex graph memory engine. The distribution is named cortex-memory-client; the import package remains cortex_memory.
Installation
pip install cortex-memory-client
Quick start
from cortex_memory import Cortex
# Connect to a running server
with Cortex("localhost:9090") as cx:
# Store knowledge
node_id = cx.store(
"decision",
"Use FastAPI for the backend",
body="Chose FastAPI over Flask for async support and type hints",
tags=["backend", "python"],
importance=0.8,
)
# Semantic search
results = cx.search("backend technology choices", limit=5)
for r in results:
print(f"{r.score:.2f} — {r.title}")
# Get a briefing
briefing = cx.briefing("my-agent")
print(briefing) # Ready-to-inject markdown
Library mode (embedded server)
cx = Cortex.open("./memory.redb")
# Works identically — starts a local server subprocess
Testing
from cortex_memory.testing import mock_cortex
def test_my_agent():
with mock_cortex() as cx:
cx.store("fact", "test data")
results = cx.search("test")
assert len(results) == 1
cx.assert_stored("fact", "test data")
pytest fixture
import pytest
from cortex_memory.testing import mock_cortex
@pytest.fixture
def cortex():
with mock_cortex() as cx:
yield cx
def test_store_and_search(cortex):
cortex.store("decision", "Use FastAPI", body="Async support", importance=0.8)
results = cortex.search("FastAPI")
assert results[0].title == "Use FastAPI"
Proto generation
The cortex_pb2.py and cortex_pb2_grpc.py stubs are pre-generated from
crates/cortex-proto/proto/cortex.proto. To regenerate after a proto change:
pip install grpcio-tools
./scripts/generate_protos.sh
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cortex_memory_client-0.3.2.tar.gz.
File metadata
- Download URL: cortex_memory_client-0.3.2.tar.gz
- Upload date:
- Size: 16.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc842836f3d8d0329a4164cb7360c914f92b9d88a20111e3427228dece2c16b8
|
|
| MD5 |
c437b7e22524c23f3c816843d605e406
|
|
| BLAKE2b-256 |
fc49a40776a5b4ba30d300543a4d0c8c9d9f9af55a705b00548965da042761a4
|
File details
Details for the file cortex_memory_client-0.3.2-py3-none-any.whl.
File metadata
- Download URL: cortex_memory_client-0.3.2-py3-none-any.whl
- Upload date:
- Size: 16.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4e79aba8a954b78ed7198c0f4d1b2fa140cadd28f2cd298c5ba15739d59b45fb
|
|
| MD5 |
25a2549951df00450e54c5d2356d3d9b
|
|
| BLAKE2b-256 |
720a075002a28dca6a7ca59a29afd144235d61fe827a38e5ff03011124b55e8c
|