添加内存管理工具和用户密钥支持,更新文档和测试用例

This commit is contained in:
2026-06-02 10:09:21 +08:00
parent 68b2513043
commit 1b5fee9866
9 changed files with 653 additions and 25 deletions

View File

@ -20,6 +20,34 @@ If an API key is configured, add:
curl -s <MEMORY_SYSTEM_BASE_URL>/memory-system/health
```
## Create User
Create the business user before calling any business endpoint:
```bash
curl -s -X POST <MEMORY_SYSTEM_BASE_URL>/memory-system/users \
-H "Content-Type: application/json" \
-d '{"user_id": "<USER_ID>"}'
```
Save the returned `account.result.user_key` and pass it as `user_key` on later calls:
```json
{
"status": "success",
"account": {
"status": "ok",
"result": {
"account_id": "<USER_ID>_account",
"admin_user_id": "<USER_ID>",
"user_key": "<USER_KEY>"
}
}
}
```
Do not send `account_id` to business endpoints.
## Write Messages
```bash
@ -134,6 +162,68 @@ Response shape:
}
```
## Manage Memories
Memory management operates on OpenViking memory URIs, usually under `viking://user/memories`. There is no separate PATCH endpoint. Update existing memory by writing directly to its URI.
### List Memory URIs
```bash
curl -sS --get "<MEMORY_SYSTEM_BASE_URL>/memory-system/memories" \
--data-urlencode "user_id=<USER_ID>" \
--data-urlencode "user_key=<USER_KEY>" \
--data-urlencode "uri=viking://user/memories" \
--data-urlencode "recursive=true"
```
This maps to OpenViking `GET /api/v1/fs/ls`.
### Read Memory Content
```bash
curl -sS --get "<MEMORY_SYSTEM_BASE_URL>/memory-system/memories/content" \
--data-urlencode "user_id=<USER_ID>" \
--data-urlencode "user_key=<USER_KEY>" \
--data-urlencode "uri=viking://user/memories/preferences/python.md"
```
This maps to OpenViking `GET /api/v1/content/read`.
### Create, Replace, Or Append Memory
```bash
curl -sS -X POST "<MEMORY_SYSTEM_BASE_URL>/memory-system/memories" \
-H "Content-Type: application/json" \
-d '{
"user_id": "<USER_ID>",
"user_key": "<USER_KEY>",
"uri": "viking://user/memories/preferences/python.md",
"content": "# Python 偏好\n\n用户偏好使用 Python 做数据分析,常用 pandas。",
"mode": "replace",
"wait": true
}'
```
`mode` supports:
- `create`: create a new memory URI.
- `replace`: fully replace an existing memory.
- `append`: append content to an existing memory.
This maps to OpenViking `POST /api/v1/content/write`. OpenViking refreshes semantic and vector indexes after writing.
### Delete Memory
```bash
curl -sS -X DELETE --get "<MEMORY_SYSTEM_BASE_URL>/memory-system/memories" \
--data-urlencode "user_id=<USER_ID>" \
--data-urlencode "user_key=<USER_KEY>" \
--data-urlencode "uri=viking://user/memories/preferences/python.md" \
--data-urlencode "recursive=false"
```
Default to `recursive=false`. If OpenViking reports that the URI is a directory or composite resource, retry with `recursive=true`.
## Search
Without LLM planning: