feat: 重构客户端结构体,增强块、消息、会话和租户模型,并更新API文档
This commit is contained in:
@@ -0,0 +1,180 @@
|
||||
# 消息管理 API
|
||||
|
||||
[返回目录](./README.md)
|
||||
|
||||
| 方法 | 路径 | 描述 |
|
||||
| ------ | ---------------------------- | ------------------------ |
|
||||
| GET | `/messages/:session_id/load` | 获取最近的会话消息列表 |
|
||||
| DELETE | `/messages/:session_id/:id` | 删除消息 |
|
||||
|
||||
## GET `/messages/:session_id/load` - 获取最近的会话消息列表
|
||||
|
||||
**查询参数**:
|
||||
|
||||
- `before_time`: 上一次拉取的最早一条消息的 created_at 字段,为空拉取最近的消息
|
||||
- `limit`: 每页条数(默认 20)
|
||||
|
||||
**请求**:
|
||||
|
||||
```curl
|
||||
curl --location --request GET 'http://localhost:8080/api/v1/messages/ceb9babb-1e30-41d7-817d-fd584954304b/load?limit=3&before_time=2030-08-12T14%3A35%3A42.123456789Z' \
|
||||
--header 'X-API-Key: sk-vQHV2NZI_LK5W7wHQvH3yGYExX8YnhaHwZipUYbiZKCYJbBQ' \
|
||||
--header 'Content-Type: application/json' \
|
||||
--data '{
|
||||
"query": "彗尾的形状"
|
||||
}'
|
||||
```
|
||||
|
||||
**响应**:
|
||||
|
||||
```json
|
||||
{
|
||||
"data": [
|
||||
{
|
||||
"id": "b8b90eeb-7dd5-4cf9-81c6-5ebcbd759451",
|
||||
"session_id": "ceb9babb-1e30-41d7-817d-fd584954304b",
|
||||
"request_id": "hCA8SDjxcAvv",
|
||||
"content": "<think>\n好的",
|
||||
"role": "assistant",
|
||||
"knowledge_references": [
|
||||
{
|
||||
"id": "c8347bef-127f-4a22-b962-edf5a75386ec",
|
||||
"content": "彗星xxx",
|
||||
"knowledge_id": "a6790b93-4700-4676-bd48-0d4804e1456b",
|
||||
"chunk_index": 0,
|
||||
"knowledge_title": "彗星.txt",
|
||||
"start_at": 0,
|
||||
"end_at": 2760,
|
||||
"seq": 0,
|
||||
"score": 4.038836479187012,
|
||||
"match_type": 4,
|
||||
"sub_chunk_id": [
|
||||
"688821f0-40bf-428e-8cb6-541531ebeb76",
|
||||
"c1e9903e-2b4d-4281-be15-0149288d45c2",
|
||||
"7d955251-3f79-4fd5-a6aa-02f81e044091"
|
||||
],
|
||||
"metadata": {},
|
||||
"chunk_type": "text",
|
||||
"parent_chunk_id": "",
|
||||
"image_info": "",
|
||||
"knowledge_filename": "彗星.txt",
|
||||
"knowledge_source": ""
|
||||
},
|
||||
{
|
||||
"id": "fa3aadee-cadb-4a84-9941-c839edc3e626",
|
||||
"content": "# 文档名称\n彗星.txt\n\n# 摘要\n彗星是由冰和尘埃构成的太阳系小天体,接近太阳时会释放气体形成彗发和彗尾。其轨道周期差异大,来源包括柯伊伯带和奥尔特云。彗星与小行星的区别逐渐模糊,部分彗星已失去挥发物质,类似小行星。目前已知彗星数量众多,且存在系外彗星。彗星在古代被视为凶兆,现代研究揭示其复杂结构与起源。",
|
||||
"knowledge_id": "a6790b93-4700-4676-bd48-0d4804e1456b",
|
||||
"chunk_index": 6,
|
||||
"knowledge_title": "彗星.txt",
|
||||
"start_at": 0,
|
||||
"end_at": 0,
|
||||
"seq": 6,
|
||||
"score": 0.6131043121858466,
|
||||
"match_type": 0,
|
||||
"sub_chunk_id": null,
|
||||
"metadata": {},
|
||||
"chunk_type": "summary",
|
||||
"parent_chunk_id": "c8347bef-127f-4a22-b962-edf5a75386ec",
|
||||
"image_info": "",
|
||||
"knowledge_filename": "彗星.txt",
|
||||
"knowledge_source": ""
|
||||
}
|
||||
],
|
||||
"agent_steps": [],
|
||||
"is_completed": true,
|
||||
"created_at": "2025-08-12T10:24:38.370548+08:00",
|
||||
"updated_at": "2025-08-12T10:25:40.416382+08:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": "7fa136ae-a045-424e-baac-52113d92ae94",
|
||||
"session_id": "ceb9babb-1e30-41d7-817d-fd584954304b",
|
||||
"request_id": "3475c004-0ada-4306-9d30-d7f5efce50d2",
|
||||
"content": "彗尾的形状",
|
||||
"role": "user",
|
||||
"knowledge_references": [],
|
||||
"agent_steps": [],
|
||||
"is_completed": true,
|
||||
"created_at": "2025-08-12T14:30:39.732246+08:00",
|
||||
"updated_at": "2025-08-12T14:30:39.733277+08:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": "9bcafbcf-a758-40af-a9a3-c4d8e0f49439",
|
||||
"session_id": "ceb9babb-1e30-41d7-817d-fd584954304b",
|
||||
"request_id": "3475c004-0ada-4306-9d30-d7f5efce50d2",
|
||||
"content": "<think>\n好的",
|
||||
"role": "assistant",
|
||||
"knowledge_references": [
|
||||
{
|
||||
"id": "c8347bef-127f-4a22-b962-edf5a75386ec",
|
||||
"content": "彗星xxx",
|
||||
"knowledge_id": "a6790b93-4700-4676-bd48-0d4804e1456b",
|
||||
"chunk_index": 0,
|
||||
"knowledge_title": "彗星.txt",
|
||||
"start_at": 0,
|
||||
"end_at": 2760,
|
||||
"seq": 0,
|
||||
"score": 4.038836479187012,
|
||||
"match_type": 3,
|
||||
"sub_chunk_id": [
|
||||
"688821f0-40bf-428e-8cb6-541531ebeb76",
|
||||
"c1e9903e-2b4d-4281-be15-0149288d45c2",
|
||||
"7d955251-3f79-4fd5-a6aa-02f81e044091"
|
||||
],
|
||||
"metadata": {},
|
||||
"chunk_type": "text",
|
||||
"parent_chunk_id": "",
|
||||
"image_info": "",
|
||||
"knowledge_filename": "彗星.txt",
|
||||
"knowledge_source": ""
|
||||
},
|
||||
{
|
||||
"id": "fa3aadee-cadb-4a84-9941-c839edc3e626",
|
||||
"content": "# 文档名称\n彗星.txt\n\n# 摘要\n彗星是由冰和尘埃构成的太阳系小天体,接近太阳时会释放气体形成彗发和彗尾。其轨道周期差异大,来源包括柯伊伯带和奥尔特云。彗星与小行星的区别逐渐模糊,部分彗星已失去挥发物质,类似小行星。目前已知彗星数量众多,且存在系外彗星。彗星在古代被视为凶兆,现代研究揭示其复杂结构与起源。",
|
||||
"knowledge_id": "a6790b93-4700-4676-bd48-0d4804e1456b",
|
||||
"chunk_index": 6,
|
||||
"knowledge_title": "彗星.txt",
|
||||
"start_at": 0,
|
||||
"end_at": 0,
|
||||
"seq": 6,
|
||||
"score": 0.6131043121858466,
|
||||
"match_type": 3,
|
||||
"sub_chunk_id": null,
|
||||
"metadata": {},
|
||||
"chunk_type": "summary",
|
||||
"parent_chunk_id": "c8347bef-127f-4a22-b962-edf5a75386ec",
|
||||
"image_info": "",
|
||||
"knowledge_filename": "彗星.txt",
|
||||
"knowledge_source": ""
|
||||
}
|
||||
],
|
||||
"agent_steps": [],
|
||||
"is_completed": true,
|
||||
"created_at": "2025-08-12T14:30:39.735108+08:00",
|
||||
"updated_at": "2025-08-12T14:31:17.829926+08:00",
|
||||
"deleted_at": null
|
||||
}
|
||||
],
|
||||
"success": true
|
||||
}
|
||||
```
|
||||
|
||||
## DELETE `/messages/:session_id/:id` - 删除消息
|
||||
|
||||
**请求**:
|
||||
|
||||
```curl
|
||||
curl --location --request DELETE 'http://localhost:8080/api/v1/messages/ceb9babb-1e30-41d7-817d-fd584954304b/9bcafbcf-a758-40af-a9a3-c4d8e0f49439' \
|
||||
--header 'X-API-Key: sk-vQHV2NZI_LK5W7wHQvH3yGYExX8YnhaHwZipUYbiZKCYJbBQ' \
|
||||
--header 'Content-Type: application/json'
|
||||
```
|
||||
|
||||
**响应**:
|
||||
|
||||
```json
|
||||
{
|
||||
"message": "Message deleted successfully",
|
||||
"success": true
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user