update knowledge base api (#20426)

This commit is contained in:
Dongyu Li
2025-05-30 14:45:30 +08:00
committed by GitHub
parent 55371e5abf
commit 1ea4459d9f
6 changed files with 397 additions and 36 deletions

View File

@@ -1351,6 +1351,75 @@ import { Row, Col, Properties, Property, Heading, SubProperty, PropertyInstructi
<Heading
url='/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}'
method='GET'
title='查看文档分段详情'
name='#view_document_segment'
/>
<Row>
<Col>
查看指定知识库中特定文档的分段详情
### Path
<Properties>
<Property name='dataset_id' type='string' key='dataset_id'>
知识库 ID
</Property>
<Property name='document_id' type='string' key='document_id'>
文档 ID
</Property>
<Property name='segment_id' type='string' key='segment_id'>
分段 ID
</Property>
</Properties>
</Col>
<Col sticky>
<CodeGroup
title="Request"
tag="GET"
label="/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}"
targetCode={`curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}' \\\n--header 'Authorization: Bearer {api_key}'`}
>
```bash {{ title: 'cURL' }}
curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}' \
--header 'Authorization: Bearer {api_key}'
```
</CodeGroup>
<CodeGroup title="Response">
```json {{ title: 'Response' }}
{
"data": {
"id": "分段唯一ID",
"position": 2,
"document_id": "所属文档ID",
"content": "分段内容文本",
"sign_content": "签名内容文本",
"answer": "答案内容(如果有)",
"word_count": 470,
"tokens": 382,
"keywords": ["关键词1", "关键词2"],
"index_node_id": "索引节点ID",
"index_node_hash": "索引节点哈希值",
"hit_count": 0,
"enabled": true,
"status": "completed",
"created_by": "创建者ID",
"created_at": 创建时间戳,
"updated_at": 更新时间戳,
"indexing_at": 索引时间戳,
"completed_at": 完成时间戳,
"error": null,
"child_chunks": []
},
"doc_form": "text_model"
}
```
</CodeGroup>
</Col>
</Row>
<hr className='ml-0 mr-0' />
<Heading
method='POST'
title='更新文档分段'
name='#update_segment'
@@ -1827,6 +1896,31 @@ import { Row, Col, Properties, Property, Heading, SubProperty, PropertyInstructi
- <code>top_k</code> (integer) 返回结果数量,非必填
- <code>score_threshold_enabled</code> (bool) 是否开启 score 阈值
- <code>score_threshold</code> (float) Score 阈值
- <code>metadata_filtering_conditions</code> (object) 元数据过滤条件
- <code>logical_operator</code> (string) 逻辑运算符: <code>and</code> | <code>or</code>
- <code>conditions</code> (array[object]) 条件列表
- <code>name</code> (string) 元数据字段名
- <code>comparison_operator</code> (string) 比较运算符,可选值:
- 字符串比较:
- <code>contains</code>: 包含
- <code>not contains</code>: 不包含
- <code>start with</code>: 以...开头
- <code>end with</code>: 以...结尾
- <code>is</code>: 等于
- <code>is not</code>: 不等于
- <code>empty</code>: 为空
- <code>not empty</code>: 不为空
- 数值比较:
- <code>=</code>: 等于
- <code>≠</code>: 不等于
- <code>></code>: 大于
- <code> < </code>: 小于
- <code>≥</code>: 大于等于
- <code>≤</code>: 小于等于
- 时间比较:
- <code>before</code>: 早于
- <code>after</code>: 晚于
- <code>value</code> (string|number|null) 比较值
</Property>
<Property name='external_retrieval_model' type='object' key='external_retrieval_model'>
未启用字段
@@ -1851,7 +1945,17 @@ import { Row, Col, Properties, Property, Heading, SubProperty, PropertyInstructi
"weights": null,
"top_k": 1,
"score_threshold_enabled": false,
"score_threshold": null
"score_threshold": null,
"metadata_filtering_conditions": {
"logical_operator": "and",
"conditions": [
{
"name": "document_name",
"comparison_operator": "contains",
"value": "test"
}
]
}
}
}'`}
>