|
16 | 16 | ``upload`` (storage), ``close``. They are public API and cannot be renamed. Memory |
17 | 17 | methods added since follow the same bare-verb shape so the memory group stays one |
18 | 18 | style and each name is the last segment of its route — ``update`` / ``delete_by_ids`` |
19 | | -/ ``feedback`` (1.2.0). Every other resource carries its name as a prefix — ``kb_`` / |
| 19 | +/ ``feedback`` (1.2.0), ``context`` (1.3.0). Every other resource carries its name as a prefix — ``kb_`` / |
20 | 20 | ``doc_`` / ``task_`` / ``tag_`` — so completion groups by resource and no facade method |
21 | 21 | collides with the generated method it wraps. |
22 | 22 |
|
|
40 | 40 | AddOperation, |
41 | 41 | Content, |
42 | 42 | ContentItem, |
| 43 | + ContextInput, |
43 | 44 | DeleteByIdsInput, |
44 | 45 | DeleteInput, |
45 | 46 | DeleteOperation, |
|
87 | 88 | "add_memory": "add", "search_memory": "search", "get_memory": "get", |
88 | 89 | "flush_memory": "flush", "edit_profile": "edit", "delete_memory": "delete", |
89 | 90 | "update_memory": "update", "delete_memories_by_ids": "delete_by_ids", |
90 | | - "submit_feedback": "feedback", |
| 91 | + "submit_feedback": "feedback", "retrieve_context": "context", |
91 | 92 | "sign_objects": "presign", |
92 | 93 | "bind_tags": "tag_bind", "unbind_tags": "tag_unbind", "replace_tags": "tag_replace", |
93 | 94 | "create_knowledge_base": "kb_create", "list_knowledge_bases": "kb_list", |
@@ -364,6 +365,38 @@ def search( |
364 | 365 | ) |
365 | 366 | return self._call(self.memory.search_memory, payload).data |
366 | 367 |
|
| 368 | + def context( |
| 369 | + self, |
| 370 | + query: str, |
| 371 | + *, |
| 372 | + user_id: str, |
| 373 | + top_k: int | None = None, |
| 374 | + include_profile: bool | None = None, |
| 375 | + filters: Any = None, |
| 376 | + app_id: str | None = None, |
| 377 | + project_id: str | None = None, |
| 378 | + ) -> Any: |
| 379 | + """Context Retrieval: an LLM searches in rounds until the evidence suffices. |
| 380 | +
|
| 381 | + Returns ``SearchData``, the same shape as :meth:`search` — memories, not an |
| 382 | + answer. ``episodes[].cited`` marks the ones the model's answer rested on, and |
| 383 | + ``score`` is a rank-fusion score, not comparable with search scores. User owners |
| 384 | + only. The server caps the loop at 45 s and returns what it found so far, which |
| 385 | + fits the client's default 60 s timeout; a client built with a shorter timeout |
| 386 | + should raise it for this call's sake. |
| 387 | + """ |
| 388 | + payload = ContextInput( |
| 389 | + **_clean( |
| 390 | + query=query, |
| 391 | + user_id=user_id, |
| 392 | + top_k=top_k, |
| 393 | + include_profile=include_profile, |
| 394 | + filters=filters, |
| 395 | + **self._scope(app_id, project_id), |
| 396 | + ) |
| 397 | + ) |
| 398 | + return self._call(self.memory.retrieve_context, payload).data |
| 399 | + |
367 | 400 | def get( |
368 | 401 | self, |
369 | 402 | memory_type: str, |
|
0 commit comments