|
| 1 | +# REST API Endpoints |
| 2 | + |
| 3 | +The following endpoints are available: |
| 4 | + |
| 5 | +- **GET /health** |
| 6 | + A simple health check endpoint returning the current server time. |
| 7 | + Example Response: |
| 8 | + |
| 9 | + ```json |
| 10 | + { "now": 1616173200 } |
| 11 | + ``` |
| 12 | + |
| 13 | +- **GET /sessions/** |
| 14 | + Retrieves a paginated list of session IDs. |
| 15 | + _Query Parameters:_ |
| 16 | + |
| 17 | + - `limit` (int): Number of sessions per page (default: 10) |
| 18 | + - `offset` (int): Number of sessions to skip (default: 0) |
| 19 | + - `namespace` (string, optional): Filter sessions by namespace. |
| 20 | + |
| 21 | +- **GET /sessions/{session_id}/memory** |
| 22 | + Retrieves working memory for a session, including messages, structured memories, |
| 23 | + context, and metadata. |
| 24 | + _Query Parameters:_ |
| 25 | + |
| 26 | + - `namespace` (string, optional): The namespace to use for the session |
| 27 | + - `window_size` (int, optional): Number of messages to include in the response (default from config) |
| 28 | + - `model_name` (string, optional): The client's LLM model name to determine appropriate context window size |
| 29 | + - `context_window_max` (int, optional): Direct specification of max context window tokens (overrides model_name) |
| 30 | + |
| 31 | +- **PUT /sessions/{session_id}/memory** |
| 32 | + Sets working memory for a session, replacing any existing memory. |
| 33 | + Automatically summarizes conversations that exceed the window size. |
| 34 | + _Request Body Example:_ |
| 35 | + |
| 36 | + ```json |
| 37 | + { |
| 38 | + "messages": [ |
| 39 | + { "role": "user", "content": "Hello" }, |
| 40 | + { "role": "assistant", "content": "Hi there" } |
| 41 | + ], |
| 42 | + "memories": [ |
| 43 | + { |
| 44 | + "id": "mem-123", |
| 45 | + "text": "User prefers direct communication", |
| 46 | + "memory_type": "semantic" |
| 47 | + } |
| 48 | + ], |
| 49 | + "context": "Previous conversation summary...", |
| 50 | + "session_id": "session-123", |
| 51 | + "namespace": "default" |
| 52 | + } |
| 53 | + ``` |
| 54 | + |
| 55 | +- **DELETE /sessions/{session_id}/memory** |
| 56 | + Deletes all working memory (messages, context, structured memories, metadata) for a session. |
| 57 | + |
| 58 | +- **POST /long-term-memory** |
| 59 | + Creates long-term memories directly, bypassing working memory. |
| 60 | + _Request Body Example:_ |
| 61 | + |
| 62 | + ```json |
| 63 | + { |
| 64 | + "memories": [ |
| 65 | + { |
| 66 | + "id": "mem-456", |
| 67 | + "text": "User is interested in AI and machine learning", |
| 68 | + "memory_type": "semantic", |
| 69 | + "session_id": "session-123", |
| 70 | + "namespace": "default" |
| 71 | + } |
| 72 | + ] |
| 73 | + } |
| 74 | + ``` |
| 75 | + |
| 76 | +- **POST /long-term-memory/search** |
| 77 | + Performs vector search on long-term memories with advanced filtering options. |
| 78 | + _Request Body Example:_ |
| 79 | + |
| 80 | + ```json |
| 81 | + { |
| 82 | + "text": "Search query text", |
| 83 | + "limit": 10, |
| 84 | + "offset": 0, |
| 85 | + "session_id": { "eq": "session-123" }, |
| 86 | + "namespace": { "eq": "default" }, |
| 87 | + "topics": { "any": ["AI", "Machine Learning"] }, |
| 88 | + "entities": { "all": ["OpenAI", "Claude"] }, |
| 89 | + "created_at": { "gte": 1672527600, "lte": 1704063599 }, |
| 90 | + "last_accessed": { "gt": 1704063600 }, |
| 91 | + "user_id": { "eq": "user-456" } |
| 92 | + } |
| 93 | + ``` |
| 94 | + |
| 95 | +- **POST /memory-prompt** |
| 96 | + Generates prompts enriched with relevant memory context from both working |
| 97 | + memory and long-term memory. Useful for retrieving context before answering questions. |
| 98 | + _Request Body Example:_ |
| 99 | + |
| 100 | + ```json |
| 101 | + { |
| 102 | + "query": "What did we discuss about AI?", |
| 103 | + "session": { |
| 104 | + "session_id": "session-123", |
| 105 | + "namespace": "default", |
| 106 | + "window_size": 10 |
| 107 | + }, |
| 108 | + "long_term_search": { |
| 109 | + "text": "AI discussion", |
| 110 | + "limit": 5, |
| 111 | + "namespace": { "eq": "default" } |
| 112 | + } |
| 113 | + } |
| 114 | + ``` |
| 115 | + |
| 116 | +## Filter Options |
| 117 | + |
| 118 | +_Filter options for search endpoints:_ |
| 119 | + |
| 120 | +- Tag filters (session_id, namespace, topics, entities, user_id): |
| 121 | + |
| 122 | + - `eq`: Equals this value |
| 123 | + - `ne`: Not equals this value |
| 124 | + - `any`: Contains any of these values |
| 125 | + - `all`: Contains all of these values |
| 126 | + |
| 127 | +- Numeric filters (created_at, last_accessed): |
| 128 | + - `gt`: Greater than |
| 129 | + - `lt`: Less than |
| 130 | + - `gte`: Greater than or equal |
| 131 | + - `lte`: Less than or equal |
| 132 | + - `eq`: Equals |
| 133 | + - `ne`: Not equals |
| 134 | + - `between`: Between two values |
0 commit comments