@@ -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
7777Stores 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
119117for 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
127125Retrieves 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 )
142140print (mem.id) # 42
143141print (mem.content) # b"User prefers dark mode"
144142print (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
155153Permanently 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")
189187db.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 |
0 commit comments