Add APIs for Knowledge Base Tag Management and Dataset Binding (#20023)

Co-authored-by: lizb <lizb@sugon.com>
This commit is contained in:
Ganondorf
2025-05-30 14:48:00 +08:00
committed by GitHub
parent 1ea4459d9f
commit 51f64797cd
5 changed files with 1073 additions and 2 deletions

View File

@@ -2391,6 +2391,314 @@ import { Row, Col, Properties, Property, Heading, SubProperty, PropertyInstructi
</Col>
</Row>
<hr className='ml-0 mr-0' />
<Heading
url='/datasets/tags'
method='POST'
title='新增知识库类型标签'
name='#create_new_knowledge_tag'
/>
<Row>
<Col>
### Request Body
<Properties>
<Property name='name' type='string'>
(text) 新标签名称必填最大长度为50
</Property>
</Properties>
</Col>
<Col sticky>
<CodeGroup
title="Request"
tag="POST"
label="/datasets/tags"
targetCode={`curl --location --request POST '${props.apiBaseUrl}/datasets/tags' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{"name": "testtag1"}'`}
>
```bash {{ title: 'cURL' }}
curl --location --request POST '${props.apiBaseUrl}/datasets/tags' \
--header 'Authorization: Bearer {api_key}' \
--header 'Content-Type: application/json' \
--data-raw '{"name": "testtag1"}'
```
</CodeGroup>
<CodeGroup title="Response">
```json {{ title: 'Response' }}
{
"id": "eddb66c2-04a1-4e3a-8cb2-75abd01e12a6",
"name": "testtag1",
"type": "knowledge",
"binding_count": 0
}
```
</CodeGroup>
</Col>
</Row>
<hr className='ml-0 mr-0' />
<Heading
url='/datasets/tags'
method='GET'
title='获取知识库类型标签'
name='#get_knowledge_type_tags'
/>
<Row>
<Col>
### Request Body
</Col>
<Col sticky>
<CodeGroup
title="Request"
tag="GET"
label="/datasets/tags"
targetCode={`curl --location --request GET '${props.apiBaseUrl}/datasets/tags' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json'`}
>
```bash {{ title: 'cURL' }}
curl --location --request GET '${props.apiBaseUrl}/datasets/tags' \
--header 'Authorization: Bearer {api_key}' \
--header 'Content-Type: application/json'
```
</CodeGroup>
<CodeGroup title="Response">
```json {{ title: 'Response' }}
[
{
"id": "39d6934c-ed36-463d-b4a7-377fa1503dc0",
"name": "testtag1",
"type": "knowledge",
"binding_count": "0"
},
...
]
```
</CodeGroup>
</Col>
</Row>
<hr className='ml-0 mr-0' />
<Heading
url='/datasets/tags'
method='PATCH'
title='修改知识库类型标签名称'
name='#modify_knowledge_tag_name'
/>
<Row>
<Col>
### Request Body
<Properties>
<Property name='name' type='string'>
(text) 修改后的标签名称必填最大长度为50
</Property>
<Property name='tag_id' type='string'>
(text) 标签ID必填
</Property>
</Properties>
</Col>
<Col sticky>
<CodeGroup
title="Request"
tag="PATCH"
label="/datasets/tags"
targetCode={`curl --location --request PATCH '${props.apiBaseUrl}/datasets/tags' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{"name": "testtag2", "tag_id": "e1a0a3db-ee34-4e04-842a-81555d5316fd"}`}
>
```bash {{ title: 'cURL' }}
curl --location --request PATCH '${props.apiBaseUrl}/datasets/tags' \
--header 'Authorization: Bearer {api_key}' \
--header 'Content-Type: application/json' \
--data-raw '{"name": "testtag2", "tag_id": "e1a0a3db-ee34-4e04-842a-81555d5316fd"}'
```
</CodeGroup>
<CodeGroup title="Response">
```json {{ title: 'Response' }}
{
"id": "eddb66c2-04a1-4e3a-8cb2-75abd01e12a6",
"name": "tag-renamed",
"type": "knowledge",
"binding_count": 0
}
```
</CodeGroup>
</Col>
</Row>
<hr className='ml-0 mr-0' />
<Heading
url='/datasets/tags'
method='DELETE'
title='删除知识库类型标签'
name='#delete_knowledge_tag'
/>
<Row>
<Col>
### Request Body
<Properties>
<Property name='tag_id' type='string'>
(text) 标签ID必填
</Property>
</Properties>
</Col>
<Col sticky>
<CodeGroup
title="Request"
tag="DELETE"
label="/datasets/tags"
targetCode={`curl --location --request DELETE '${props.apiBaseUrl}/datasets/tags' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{ "tag_id": "e1a0a3db-ee34-4e04-842a-81555d5316fd"}`}
>
```bash {{ title: 'cURL' }}
curl --location --request DELETE '${props.apiBaseUrl}/datasets/tags' \
--header 'Authorization: Bearer {api_key}' \
--header 'Content-Type: application/json' \
--data-raw '{"tag_id": "e1a0a3db-ee34-4e04-842a-81555d5316fd"}'
```
</CodeGroup>
<CodeGroup title="Response">
```json {{ title: 'Response' }}
{"result": "success"}
```
</CodeGroup>
</Col>
</Row>
<hr className='ml-0 mr-0' />
<Heading
url='/datasets/tags/binding'
method='POST'
title='绑定知识库到知识库类型标签'
name='#bind_dataset_to_knowledge_tag'
/>
<Row>
<Col>
### Request Body
<Properties>
<Property name='tag_ids' type='list'>
(list) 标签ID列表必填
</Property>
<Property name='target_id' type='string'>
(text) 知识库ID必填
</Property>
</Properties>
</Col>
<Col sticky>
<CodeGroup
title="Request"
tag="POST"
label="/datasets/tags/binding"
targetCode={`curl --location --request POST '${props.apiBaseUrl}/datasets/tags/binding' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{"tag_ids": ["65cc29be-d072-4e26-adf4-2f727644da29","1e5348f3-d3ff-42b8-a1b7-0a86d518001a"], "target_id": "a932ea9f-fae1-4b2c-9b65-71c56e2cacd6"}'`}
>
```bash {{ title: 'cURL' }}
curl --location --request POST '${props.apiBaseUrl}/datasets/tags/binding' \
--header 'Authorization: Bearer {api_key}' \
--header 'Content-Type: application/json' \
--data-raw '{"tag_ids": ["65cc29be-d072-4e26-adf4-2f727644da29","1e5348f3-d3ff-42b8-a1b7-0a86d518001a"], "target_id": "a932ea9f-fae1-4b2c-9b65-71c56e2cacd6"}'
```
</CodeGroup>
<CodeGroup title="Response">
```json {{ title: 'Response' }}
{"result": "success"}
```
</CodeGroup>
</Col>
</Row>
<hr className='ml-0 mr-0' />
<Heading
url='/datasets/tags/unbinding'
method='POST'
title='解绑知识库和知识库类型标签'
name='#unbind_dataset_and_knowledge_tag'
/>
<Row>
<Col>
### Request Body
<Properties>
<Property name='tag_id' type='string'>
(text) 标签ID必填
</Property>
<Property name='target_id' type='string'>
(text) 知识库ID必填
</Property>
</Properties>
</Col>
<Col sticky>
<CodeGroup
title="Request"
tag="POST"
label="/datasets/tags/unbinding"
targetCode={`curl --location --request POST '${props.apiBaseUrl}/datasets/tags/unbinding' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{"tag_id": "1e5348f3-d3ff-42b8-a1b7-0a86d518001a", "target_id": "a932ea9f-fae1-4b2c-9b65-71c56e2cacd6"}'`}
>
```bash {{ title: 'cURL' }}
curl --location --request POST '${props.apiBaseUrl}/datasets/tags/unbinding' \
--header 'Authorization: Bearer {api_key}' \
--header 'Content-Type: application/json' \
--data-raw '{"tag_id": "1e5348f3-d3ff-42b8-a1b7-0a86d518001a", "target_id": "a932ea9f-fae1-4b2c-9b65-71c56e2cacd6"}'
```
</CodeGroup>
<CodeGroup title="Response">
```json {{ title: 'Response' }}
{"result": "success"}
```
</CodeGroup>
</Col>
</Row>
<hr className='ml-0 mr-0' />
<Heading
url='/datasets/<uuid:dataset_id>/tags'
method='POST'
title='查询知识库已绑定的标签'
name='#query_dataset_tags'
/>
<Row>
<Col>
### Path
<Properties>
<Property name='dataset_id' type='string'>
(text) 知识库ID
</Property>
</Properties>
</Col>
<Col sticky>
<CodeGroup
title="Request"
tag="POST"
label="/datasets/<uuid:dataset_id>/tags"
targetCode={`curl --location --request POST '${props.apiBaseUrl}/datasets/<uuid:dataset_id>/tags' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json' \\\n`}
>
```bash {{ title: 'cURL' }}
curl --location --request POST '${props.apiBaseUrl}/datasets/<uuid:dataset_id>/tags' \
--header 'Authorization: Bearer {api_key}' \
--header 'Content-Type: application/json' \
```
</CodeGroup>
<CodeGroup title="Response">
```json {{ title: 'Response' }}
{
"data":
[
{"id": "4a601f4f-f8a2-4166-ae7c-58c3b252a524",
"name": "123"
},
...
],
"total": 3
}
```
</CodeGroup>
</Col>
</Row>
<hr className='ml-0 mr-0' />
<Row>