跳转到主要内容

基本操作

本指南展示当前服务端 API 的最小操作流程。

认证(Authentication)

TOKEN=$(curl -s -X POST http://127.0.0.1:3000/v1/dashboard/auth/login \
  -H "Content-Type: application/json" \
  -d '{"username":"admin","password":"admin"}' | jq -r '.token')

创建 Stream

STREAM_ID=$(uuidgen | tr '[:upper:]' '[:lower:]')

写入文本

curl -s -X POST "http://127.0.0.1:3000/v1/users/user_123/streams/$STREAM_ID/events" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "org_id": "default",
    "content": "User writes Rust code with async patterns",
    "content_type": "text"
  }'

检索(Retrieve)

curl -s -X POST "http://127.0.0.1:3000/v1/users/user_123/streams/$STREAM_ID/retrieve" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "org_id": "default",
    "query": "What language and style does the user prefer?",
    "limit": 5,
    "graph_depth": 1
  }'

手动添加图谱边(Graph Edge)

curl -s -X POST "http://127.0.0.1:3000/v1/users/user_123/graph/edges" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "source_id": "11111111-1111-1111-1111-111111111111",
    "target_id": "22222222-2222-2222-2222-222222222222",
    "relation": "Supports",
    "weight": 0.8
  }'

预览语义记忆变更(Semantic Memory Change)

当用户意图是”更新这条记忆”或”忘掉那个事实”而非硬删除时,使用此接口。
curl -s -X POST "http://127.0.0.1:3000/v1/users/user_123/memories/semantic/preview" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "instruction": "I moved from Shanghai to Beijing and my email changed from [email protected] to [email protected]",
    "org_id": "default",
    "mode": "update",
    "forget_mode": "soft",
    "limit": 10
  }'
响应会返回一个计划以及受影响的记忆候选项。请在审核后再执行。

执行已审核的语义计划

curl -s -X POST "http://127.0.0.1:3000/v1/users/user_123/memories/semantic/execute" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "plan_id": "<plan-id>",
    "org_id": "default",
    "confirm": true
  }'

硬删除记忆单元(Memory Unit)

仅在需要直接且不可逆地删除单个记忆单元时使用硬删除。
curl -s -X DELETE "http://127.0.0.1:3000/v1/users/user_123/memories/<memory-id>" \
  -H "Authorization: Bearer $TOKEN"

查看待处理任务

curl -s http://127.0.0.1:3000/v1/status/pending \
  -H "Authorization: Bearer $TOKEN"

使用仪表盘(Dashboard)

  • UI 地址:http://127.0.0.1:3100/dashboard
  • API 重定向:http://127.0.0.1:3000/dashboard
仪表盘可用于记忆检查、图谱探索、组织知识管理和集群健康监控。