96 lines
2.6 KiB
Markdown
96 lines
2.6 KiB
Markdown
# 分块管理 API
|
|
|
|
[返回目录](./README.md)
|
|
|
|
| 方法 | 路径 | 描述 |
|
|
| ------ | --------------------------- | ------------------------ |
|
|
| GET | `/chunks/:knowledge_id` | 获取知识的分块列表 |
|
|
| DELETE | `/chunks/:knowledge_id/:id` | 删除分块 |
|
|
| DELETE | `/chunks/:knowledge_id` | 删除知识下的所有分块 |
|
|
|
|
## GET `/chunks/:knowledge_id?page=&page_size=` - 获取知识的分块列表
|
|
|
|
**请求**:
|
|
|
|
```curl
|
|
curl --location 'http://localhost:8080/api/v1/chunks/4c4e7c1a-09cf-485b-a7b5-24b8cdc5acf5?page=1&page_size=1' \
|
|
--header 'X-API-Key: sk-vQHV2NZI_LK5W7wHQvH3yGYExX8YnhaHwZipUYbiZKCYJbBQ' \
|
|
--header 'Content-Type: application/json'
|
|
```
|
|
|
|
**响应**:
|
|
|
|
```json
|
|
{
|
|
"data": [
|
|
{
|
|
"id": "df10b37d-cd05-4b14-ba8a-e1bd0eb3bbd7",
|
|
"tenant_id": 1,
|
|
"knowledge_id": "4c4e7c1a-09cf-485b-a7b5-24b8cdc5acf5",
|
|
"knowledge_base_id": "kb-00000001",
|
|
"tag_id": "",
|
|
"content": "彗星xxxx",
|
|
"chunk_index": 0,
|
|
"is_enabled": true,
|
|
"status": 2,
|
|
"start_at": 0,
|
|
"end_at": 964,
|
|
"pre_chunk_id": "",
|
|
"next_chunk_id": "",
|
|
"chunk_type": "text",
|
|
"parent_chunk_id": "",
|
|
"relation_chunks": null,
|
|
"indirect_relation_chunks": null,
|
|
"metadata": null,
|
|
"content_hash": "",
|
|
"image_info": "",
|
|
"created_at": "2025-08-12T11:52:36.168632+08:00",
|
|
"updated_at": "2025-08-12T11:52:53.376871+08:00",
|
|
"deleted_at": null
|
|
}
|
|
],
|
|
"page": 1,
|
|
"page_size": 1,
|
|
"success": true,
|
|
"total": 5
|
|
}
|
|
```
|
|
|
|
## DELETE `/chunks/:knowledge_id/:id` - 删除分块
|
|
|
|
**请求**:
|
|
|
|
```curl
|
|
curl --location --request DELETE 'http://localhost:8080/api/v1/chunks/4c4e7c1a-09cf-485b-a7b5-24b8cdc5acf5/df10b37d-cd05-4b14-ba8a-e1bd0eb3bbd7' \
|
|
--header 'X-API-Key: sk-vQHV2NZI_LK5W7wHQvH3yGYExX8YnhaHwZipUYbiZKCYJbBQ' \
|
|
--header 'Content-Type: application/json'
|
|
```
|
|
|
|
**响应**:
|
|
|
|
```json
|
|
{
|
|
"message": "Chunk deleted",
|
|
"success": true
|
|
}
|
|
```
|
|
|
|
## DELETE `/chunks/:knowledge_id` - 删除知识下的所有分块
|
|
|
|
**请求**:
|
|
|
|
```curl
|
|
curl --location --request DELETE 'http://localhost:8080/api/v1/chunks/4c4e7c1a-09cf-485b-a7b5-24b8cdc5acf5' \
|
|
--header 'X-API-Key: sk-vQHV2NZI_LK5W7wHQvH3yGYExX8YnhaHwZipUYbiZKCYJbBQ' \
|
|
--header 'Content-Type: application/json'
|
|
```
|
|
|
|
**响应**:
|
|
|
|
```json
|
|
{
|
|
"message": "All chunks under knowledge deleted",
|
|
"success": true
|
|
}
|
|
```
|