Skip to content

Commit 2c590e2

Browse files
authored
Updated docs (#17)
1 parent 08400aa commit 2c590e2

12 files changed

Lines changed: 292 additions & 266 deletions

File tree

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,11 @@ pip install cortexadb[docs,pdf] # Optional: For PDF/Docx support
7272
<details>
7373
<summary><b>Technical Architecture & Benchmarks</b></summary>
7474

75-
### Performance Benchmarks (v0.1.7)
76-
Measured on M2 Mac with 1,000 chunks of text.
75+
### Performance Benchmarks (v0.1.8)
7776

78-
| Operation | v0.1.6 (Sync) | v0.1.7 (Batch) | Improvement |
77+
CortexaDB `v0.1.8` introduced a new batching architecture. Measured on an M2 Mac with 1,000 chunks of text:
78+
79+
| Operation | v0.1.6 (Sync) | v0.1.8 (Batch) | Improvement |
7980
|-----------|---------------|----------------|-------------|
8081
| Ingestion | 12.4s | **0.12s** | **103x Faster** |
8182
| Memory Add| 15ms | 1ms | 15x Faster |
@@ -86,7 +87,7 @@ Measured on M2 Mac with 1,000 chunks of text.
8687
---
8788

8889
## License & Status
89-
CortexaDB is currently in **Beta (v0.1.7)**. It is released under the **MIT** and **Apache-2.0** licenses.
90+
CortexaDB is currently in **Beta (v0.1.8)**. It is released under the **MIT** and **Apache-2.0** licenses.
9091
We are actively refining the API and welcome feedback!
9192

9293
---

docs/content/docs/api/python.mdx

Lines changed: 37 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -72,57 +72,55 @@ report = db.last_replay_report
7272

7373
## Memory Operations
7474

75-
### `.remember(text, embedding=None, metadata=None)`
75+
### `.add(text=None, vector=None, metadata=None, collection=None)`
7676

7777
Stores a new memory entry. If an embedder is configured and no embedding is provided, the text is auto-embedded.
7878

7979
**Parameters:**
8080

8181
| Parameter | Type | Default | Description |
8282
|-----------|------|---------|-------------|
83-
| `text` | `str` | Required | Text content to store |
84-
| `embedding` | `list[float]?` | `None` | Pre-computed embedding vector |
83+
| `text` | `str?` | `None` | Text content to store |
84+
| `vector` | `list[float]?` | `None` | Pre-computed embedding vector |
8585
| `metadata` | `dict[str, str]?` | `None` | Key-value metadata pairs |
86+
| `collection` | `str?` | `"default"` | Target collection |
8687

8788
**Returns:** `int` - The assigned memory ID
8889

8990
**Example:**
9091
```python
91-
mid = db.remember("User prefers dark mode")
92-
mid = db.remember("text", metadata={"source": "onboarding"})
93-
mid = db.remember("text", embedding=[0.1, 0.2, ...])
92+
mid = db.add("User prefers dark mode")
93+
mid = db.add("text", metadata={"source": "onboarding"})
94+
mid = db.add("text", vector=[0.1, 0.2, ...], collection="agent_a")
9495
```
9596

9697
---
9798

98-
### `.ask(query, embedding=None, top_k=5, use_graph=False, recency_bias=False)`
99+
### `.query(text=None, vector=None)`
99100

100-
Performs a hybrid search across the database.
101+
Starts a fluent query builder to search across the database.
101102

102-
**Parameters:**
103-
104-
| Parameter | Type | Default | Description |
105-
|-----------|------|---------|-------------|
106-
| `query` | `str` | Required | Search query text |
107-
| `embedding` | `list[float]?` | `None` | Pre-computed query embedding |
108-
| `top_k` | `int` | `5` | Number of results to return |
109-
| `use_graph` | `bool` | `False` | Enable graph expansion via BFS |
110-
| `recency_bias` | `bool` | `False` | Boost recent memories in scoring |
103+
**Methods:**
111104

112-
**Returns:** `list[Hit]`
105+
| Method | Description |
106+
|--------|-------------|
107+
| `.limit(n)` | Set maximum number of results (default 5) |
108+
| `.collection(name)` | Filter to a specific collection |
109+
| `.use_graph()` | Enable hybrid graph traversal |
110+
| `.recency_bias()` | Boost recent memories in scoring |
111+
| `.execute()` | Run the query and return `list[Hit]` |
113112

114113
**Example:**
115114
```python
116-
hits = db.ask("What does the user prefer?")
117-
hits = db.ask("query", top_k=10, use_graph=True, recency_bias=True)
115+
hits = db.query("What does the user prefer?").limit(5).use_graph().execute()
118116

119117
for hit in hits:
120118
print(f"ID: {hit.id}, Score: {hit.score:.3f}")
121119
```
122120

123121
---
124122

125-
### `.get_memory(mid)`
123+
### `.get(mid)`
126124

127125
Retrieves a full memory entry by ID.
128126

@@ -138,7 +136,7 @@ Retrieves a full memory entry by ID.
138136

139137
**Example:**
140138
```python
141-
mem = db.get_memory(42)
139+
mem = db.get(42)
142140
print(mem.id) # 42
143141
print(mem.content) # b"User prefers dark mode"
144142
print(mem.namespace) # "default"
@@ -150,7 +148,7 @@ print(mem.embedding) # [0.1, 0.2, ...] or None
150148

151149
---
152150

153-
### `.delete_memory(mid)`
151+
### `.delete(mid)`
154152

155153
Permanently deletes a memory and updates all indexes.
156154

@@ -164,7 +162,7 @@ Permanently deletes a memory and updates all indexes.
164162

165163
**Example:**
166164
```python
167-
db.delete_memory(42)
165+
db.delete(42)
168166
```
169167

170168
---
@@ -189,7 +187,7 @@ db.connect(1, 2, "relates_to")
189187
db.connect(1, 3, "caused_by")
190188
```
191189

192-
> Both memories must be in the same namespace. Cross-namespace edges are forbidden.
190+
> Both memories must be in the same collection. Cross-collection edges are forbidden.
193191
194192
---
195193

@@ -229,7 +227,7 @@ Chunks text and stores each chunk as a memory.
229227
| `chunk_size` | `int` | `512` | Target chunk size in characters |
230228
| `overlap` | `int` | `50` | Overlap between chunks |
231229
| `metadata` | `dict?` | `None` | Metadata to attach to all chunks |
232-
| `namespace` | `str?` | `None` | Target namespace |
230+
| `collection` | `str?` | `None` | Target collection |
233231

234232
**Returns:** `list[int]` - Memory IDs of stored chunks
235233

@@ -248,7 +246,7 @@ Loads a file, chunks it, and stores each chunk.
248246
| `chunk_size` | `int` | `512` | Target chunk size |
249247
| `overlap` | `int` | `50` | Overlap between chunks |
250248
| `metadata` | `dict?` | `None` | Metadata for all chunks |
251-
| `namespace` | `str?` | `None` | Target namespace |
249+
| `collection` | `str?` | `None` | Target collection |
252250

253251
**Supported formats:** `.txt`, `.md`, `.json`, `.docx` (requires `cortexadb[docs]`), `.pdf` (requires `cortexadb[pdf]`)
254252

@@ -260,34 +258,28 @@ db.load("paper.pdf", strategy="recursive", chunk_size=1024)
260258

261259
---
262260

263-
### `.ingest_document(text, chunk_size=512, overlap=50, metadata=None, namespace=None)`
264-
265-
Legacy method for chunking and storing text. Uses fixed chunking.
266-
267-
---
268-
269-
## Namespace
261+
## Collections
270262

271-
### `.namespace(name, readonly=False)`
263+
### `.collection(name, readonly=False)`
272264

273-
Returns a scoped view of the database for a specific namespace.
265+
Returns a scoped view of the database for a specific collection.
274266

275267
**Parameters:**
276268

277269
| Parameter | Type | Default | Description |
278270
|-----------|------|---------|-------------|
279-
| `name` | `str` | Required | Namespace name |
271+
| `name` | `str` | Required | Collection name |
280272
| `readonly` | `bool` | `False` | If `True`, write operations raise errors |
281273

282-
**Returns:** `Namespace`
274+
**Returns:** `Collection`
283275

284276
**Example:**
285277
```python
286-
ns = db.namespace("agent_a")
287-
mid = ns.remember("text")
288-
hits = ns.ask("query")
289-
ns.delete_memory(mid)
290-
ns.ingest_document("long text")
278+
col = db.collection("agent_a")
279+
mid = col.add("text")
280+
hits = col.query("query").execute()
281+
col.delete(mid)
282+
col.ingest("long text")
291283
```
292284

293285
---
@@ -382,12 +374,12 @@ Query result from `.ask()`.
382374

383375
### `Memory`
384376

385-
Full memory entry from `.get_memory()`.
377+
Full memory entry from `.get()`.
386378

387379
| Field | Type | Description |
388380
|-------|------|-------------|
389381
| `id` | `int` | Memory ID |
390-
| `namespace` | `str` | Namespace name |
382+
| `namespace` | `str` | Collection name (internal key) |
391383
| `content` | `bytes` | Raw content |
392384
| `embedding` | `list[float]?` | Vector embedding |
393385
| `metadata` | `dict[str, str]` | Key-value metadata |

docs/content/docs/api/rust.mdx

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ The high-level API for interacting with the database.
1212
### Opening a Database
1313

1414
```rust
15-
use cortexadb_core::CortexaDB;
15+
use cortexadb_core::{CortexaDB, CortexaDBBuilder};
1616

1717
// Simple open with default config
18-
let db = CortexaDB::open("/path/to/db", 128)?;
18+
let db = CortexaDBBuilder::new("/path/to/db", 128).build()?;
1919

2020
// Builder pattern for advanced config
21-
let db = CortexaDB::builder("/path/to/db", config).build()?;
21+
let db = CortexaDBBuilder::new("/path/to/db", 128)
22+
.with_sync_policy(cortexadb_core::engine::SyncPolicy::Async { interval_ms: 1000 })
23+
.build()?;
2224
```
2325

2426
---
@@ -142,6 +144,25 @@ println!("Indexed: {}", stats.indexed_embeddings);
142144

143145
---
144146

147+
## Observability / Telemetry
148+
149+
CortexaDB uses the standard Rust [`log`](https://crates.io/crates/log) crate for all internal diagnostics and telemetry. It issues structured `debug!` and `trace!` logs instead of printing to stdout/stderr.
150+
151+
To see CortexaDB metrics and internal operations in your application, initialize a logger (like `env_logger` or `tracing-subscriber`):
152+
153+
```rust
154+
use env_logger;
155+
156+
fn main() {
157+
// Initialize the logger before opening the database
158+
env_logger::init();
159+
160+
// In your terminal, run with: RUST_LOG=cortexadb_core=debug cargo run
161+
}
162+
```
163+
164+
---
165+
145166
## Types
146167

147168
### `Hit`

docs/content/docs/getting-started/quickstart.mdx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,23 @@ db = CortexaDB.open("agent.mem", dimension=128)
3030

3131
```python
3232
# Auto-embedding (requires embedder)
33-
mid1 = db.remember("The user prefers dark mode.")
34-
mid2 = db.remember("User works at Stripe.")
33+
mid1 = db.add("The user prefers dark mode.")
34+
mid2 = db.add("User works at Stripe.")
3535

3636
# With metadata
37-
mid3 = db.remember("User's name is Alice.", metadata={"source": "onboarding"})
37+
mid3 = db.add("User's name is Alice.", metadata={"source": "onboarding"})
3838
```
3939

4040
### 4. Query Memories
4141

4242
```python
4343
# Semantic search
44-
hits = db.ask("What does the user like?")
44+
hits = db.query("What does the user like?").execute()
4545
for hit in hits:
4646
print(f"ID: {hit.id}, Score: {hit.score:.3f}")
4747

4848
# Retrieve full memory
49-
mem = db.get_memory(hits[0].id)
49+
mem = db.get(hits[0].id)
5050
print(mem.content) # b"The user prefers dark mode."
5151
```
5252

@@ -68,12 +68,12 @@ db.load("document.pdf", strategy="recursive")
6868
db.ingest("Long article text here...", strategy="markdown")
6969
```
7070

71-
### 7. Use Namespaces
71+
### 7. Use Collections
7272

7373
```python
74-
agent_a = db.namespace("agent_a")
75-
agent_a.remember("Agent A's private memory")
76-
hits = agent_a.ask("query only agent A's memories")
74+
agent_a = db.collection("agent_a")
75+
agent_a.add("Agent A's private memory")
76+
hits = agent_a.query("query only agent A's memories").execute()
7777
```
7878

7979
---
@@ -90,10 +90,10 @@ cortexadb-core = { git = "https://github.com/anaslimem/CortexaDB.git" }
9090
### 2. Basic Usage
9191

9292
```rust
93-
use cortexadb_core::CortexaDB;
93+
use cortexadb_core::{CortexaDB, CortexaDBBuilder};
9494

9595
fn main() -> Result<(), Box<dyn std::error::Error>> {
96-
let db = CortexaDB::open("/tmp/agent.mem", 128)?;
96+
let db = CortexaDBBuilder::new("/tmp/agent.mem", 128).build()?;
9797

9898
// Store a memory with an embedding
9999
let embedding = vec![0.1; 128];

0 commit comments

Comments
 (0)