pip install cortex-memoryfrom cortex_memory import Cortex
cx = Cortex("localhost:9090")Connect to a Cortex server.
addr— gRPC address, e.g."localhost:9090"
Store a new node. Returns the node ID.
node_id = cx.store("fact", "JWT is used for auth",
body="We chose JWT for stateless...",
importance=0.8,
tags=["auth", "security"])Get a node by ID.
Search nodes semantically.
results = cx.search("authentication", limit=5)
for r in results:
print(r.score, r.title, r.id)Get a context briefing for an agent.
briefing = cx.briefing("my-agent")
# Use as system prompt contextCreate an edge between two nodes.
cx.edge(node_a, node_b, "supports", weight=0.9)Delete a node.
Traverse the graph from a node.
| Field | Type | Description |
|---|---|---|
id |
str | Node ID |
title |
str | Node title |
body |
str | Node body |
kind |
str | Node kind |
score |
float | Similarity score |
importance |
float | Importance score |
| Field | Type | Description |
|---|---|---|
id |
str | Node ID |
kind |
str | Node kind |
title |
str | Title |
body |
str | Body |
importance |
float | Importance score |
tags |
List[str] | Tags |
source_agent |
str | Source agent ID |
created_at |
datetime | Creation timestamp |
metadata |
Dict[str, str] | Metadata |