Merge branch 'feat/upgrade-knowledge-metabase' into deploy/dev
This commit is contained in:
commit
3ec64a3630
@ -1546,12 +1546,12 @@ import { Row, Col, Properties, Property, Heading, SubProperty, PropertyInstructi
|
|||||||
<Heading
|
<Heading
|
||||||
url='/datasets/{dataset_id}/metadata'
|
url='/datasets/{dataset_id}/metadata'
|
||||||
method='POST'
|
method='POST'
|
||||||
title='Create a Knowledge metadata'
|
title='Create a Knowledge Metadata'
|
||||||
name='#create_metadata'
|
name='#create_metadata'
|
||||||
/>
|
/>
|
||||||
<Row>
|
<Row>
|
||||||
<Col>
|
<Col>
|
||||||
### POST
|
### Params
|
||||||
<Properties>
|
<Properties>
|
||||||
<Property name='dataset_id' type='string' key='dataset_id'>
|
<Property name='dataset_id' type='string' key='dataset_id'>
|
||||||
Knowledge ID
|
Knowledge ID
|
||||||
@ -1561,8 +1561,8 @@ import { Row, Col, Properties, Property, Heading, SubProperty, PropertyInstructi
|
|||||||
### Request Body
|
### Request Body
|
||||||
<Properties>
|
<Properties>
|
||||||
<Property name='segment' type='object' key='segment'>
|
<Property name='segment' type='object' key='segment'>
|
||||||
- <code>type</code> (string) metadata type, required
|
- <code>type</code> (string) Metadata type, required
|
||||||
- <code>name</code> (string) metadata name, required
|
- <code>name</code> (string) Metadata name, required
|
||||||
</Property>
|
</Property>
|
||||||
</Properties>
|
</Properties>
|
||||||
</Col>
|
</Col>
|
||||||
@ -1571,23 +1571,219 @@ import { Row, Col, Properties, Property, Heading, SubProperty, PropertyInstructi
|
|||||||
title="Request"
|
title="Request"
|
||||||
tag="POST"
|
tag="POST"
|
||||||
label="/datasets/{dataset_id}/metadata"
|
label="/datasets/{dataset_id}/metadata"
|
||||||
targetCode={`curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json'\\\n--data-raw '{\"segment\": {\"content\": \"1\",\"answer\": \"1\", \"keywords\": [\"a\"], \"enabled\": false}}'`}
|
targetCode={`curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/metadata' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json'\\\n--data-raw '{"type": "string", "name": "test"}'`}
|
||||||
>
|
>
|
||||||
```bash {{ title: 'cURL' }}
|
```bash {{ title: 'cURL' }}
|
||||||
curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/documents/{document_id}/segments/{segment_id}' \
|
|
||||||
--header 'Content-Type: application/json' \
|
|
||||||
--data-raw '{
|
|
||||||
"segment": {
|
|
||||||
"content": "1",
|
|
||||||
"answer": "1",
|
|
||||||
}
|
|
||||||
}'
|
|
||||||
```
|
```
|
||||||
</CodeGroup>
|
</CodeGroup>
|
||||||
<CodeGroup title="Response">
|
<CodeGroup title="Response">
|
||||||
```json {{ title: 'Response' }}
|
```json {{ title: 'Response' }}
|
||||||
{
|
{
|
||||||
"doc_form": "text_model"
|
"id": "abc",
|
||||||
|
"type": "string",
|
||||||
|
"name": "test",
|
||||||
|
}
|
||||||
|
```
|
||||||
|
</CodeGroup>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
|
||||||
|
<hr className='ml-0 mr-0' />
|
||||||
|
|
||||||
|
<Heading
|
||||||
|
url='/datasets/{dataset_id}/metadata/{metadata_id}'
|
||||||
|
method='PATCH'
|
||||||
|
title='Update a Knowledge Metadata'
|
||||||
|
name='#update_metadata'
|
||||||
|
/>
|
||||||
|
<Row>
|
||||||
|
<Col>
|
||||||
|
### Params
|
||||||
|
<Properties>
|
||||||
|
<Property name='dataset_id' type='string' key='dataset_id'>
|
||||||
|
Knowledge ID
|
||||||
|
</Property>
|
||||||
|
<Property name='metadata_id' type='string' key='metadata_id'>
|
||||||
|
Metadata ID
|
||||||
|
</Property>
|
||||||
|
</Properties>
|
||||||
|
|
||||||
|
### Request Body
|
||||||
|
<Properties>
|
||||||
|
<Property name='segment' type='object' key='segment'>
|
||||||
|
- <code>name</code> (string) Metadata name, required
|
||||||
|
</Property>
|
||||||
|
</Properties>
|
||||||
|
</Col>
|
||||||
|
<Col sticky>
|
||||||
|
<CodeGroup
|
||||||
|
title="Request"
|
||||||
|
tag="POST"
|
||||||
|
label="/datasets/{dataset_id}/metadata/{metadata_id}"
|
||||||
|
targetCode={`curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/metadata/{metadata_id}' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json'\\\n--data-raw '{"name": "test"}'`}
|
||||||
|
>
|
||||||
|
```bash {{ title: 'cURL' }}
|
||||||
|
```
|
||||||
|
</CodeGroup>
|
||||||
|
<CodeGroup title="Response">
|
||||||
|
```json {{ title: 'Response' }}
|
||||||
|
{
|
||||||
|
"id": "abc",
|
||||||
|
"type": "string",
|
||||||
|
"name": "test",
|
||||||
|
}
|
||||||
|
```
|
||||||
|
</CodeGroup>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
|
||||||
|
<hr className='ml-0 mr-0' />
|
||||||
|
|
||||||
|
<Heading
|
||||||
|
url='/datasets/{dataset_id}/metadata/{metadata_id}'
|
||||||
|
method='DELETE'
|
||||||
|
title='Delete a Knowledge Metadata'
|
||||||
|
name='#delete_metadata'
|
||||||
|
/>
|
||||||
|
<Row>
|
||||||
|
<Col>
|
||||||
|
### Params
|
||||||
|
<Properties>
|
||||||
|
<Property name='dataset_id' type='string' key='dataset_id'>
|
||||||
|
Knowledge ID
|
||||||
|
</Property>
|
||||||
|
<Property name='metadata_id' type='string' key='metadata_id'>
|
||||||
|
Metadata ID
|
||||||
|
</Property>
|
||||||
|
</Properties>
|
||||||
|
</Col>
|
||||||
|
<Col sticky>
|
||||||
|
<CodeGroup
|
||||||
|
title="Request"
|
||||||
|
tag="DELETE"
|
||||||
|
label="/datasets/{dataset_id}/metadata/{metadata_id}"
|
||||||
|
targetCode={`curl --location --request DELETE '${props.apiBaseUrl}/datasets/{dataset_id}/metadata/{metadata_id}' \\\n--header 'Authorization: Bearer {api_key}'`}
|
||||||
|
>
|
||||||
|
```bash {{ title: 'cURL' }}
|
||||||
|
```
|
||||||
|
</CodeGroup>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
|
||||||
|
<hr className='ml-0 mr-0' />
|
||||||
|
|
||||||
|
<Heading
|
||||||
|
url='/datasets/{dataset_id}/metadata/built-in/{action}'
|
||||||
|
method='POST'
|
||||||
|
title='Disable Or Enable Metadata'
|
||||||
|
name='#toggle_metadata'
|
||||||
|
/>
|
||||||
|
<Row>
|
||||||
|
<Col>
|
||||||
|
### Params
|
||||||
|
<Properties>
|
||||||
|
<Property name='dataset_id' type='string' key='dataset_id'>
|
||||||
|
Knowledge ID
|
||||||
|
</Property>
|
||||||
|
<Property name='action' type='string' key='action'>
|
||||||
|
disable/enable
|
||||||
|
</Property>
|
||||||
|
</Properties>
|
||||||
|
</Col>
|
||||||
|
<Col sticky>
|
||||||
|
<CodeGroup
|
||||||
|
title="Request"
|
||||||
|
tag="POST"
|
||||||
|
label="/datasets/{dataset_id}/metadata/built-in/{action}"
|
||||||
|
targetCode={`curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/metadata/built-in/{action}' \\\n--header 'Authorization: Bearer {api_key}'`}
|
||||||
|
>
|
||||||
|
```bash {{ title: 'cURL' }}
|
||||||
|
```
|
||||||
|
</CodeGroup>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
|
||||||
|
<hr className='ml-0 mr-0' />
|
||||||
|
|
||||||
|
<Heading
|
||||||
|
url='/datasets/{dataset_id}/documents/metadata'
|
||||||
|
method='POST'
|
||||||
|
title='Update Documents Metadata'
|
||||||
|
name='#update_documents_metadata'
|
||||||
|
/>
|
||||||
|
<Row>
|
||||||
|
<Col>
|
||||||
|
### Params
|
||||||
|
<Properties>
|
||||||
|
<Property name='dataset_id' type='string' key='dataset_id'>
|
||||||
|
Knowledge ID
|
||||||
|
</Property>
|
||||||
|
</Properties>
|
||||||
|
|
||||||
|
### Request Body
|
||||||
|
<Properties>
|
||||||
|
<Property name='operation_data' type='object list' key='segments'>
|
||||||
|
- <code>document_id</code> (string) Document ID
|
||||||
|
- <code>metadata_list</code> (list) Metadata list
|
||||||
|
- <code>id</code> (string) Metadata ID
|
||||||
|
- <code>value</code> (string) Metadata value
|
||||||
|
- <code>name</code> (string) Metadata name
|
||||||
|
</Property>
|
||||||
|
</Properties>
|
||||||
|
</Col>
|
||||||
|
<Col sticky>
|
||||||
|
<CodeGroup
|
||||||
|
title="Request"
|
||||||
|
tag="POST"
|
||||||
|
label="/datasets/{dataset_id}/documents/metadata"
|
||||||
|
targetCode={`curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/documents/metadata' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json'\\\n--data-raw '{"operation_data": [{"document_id": "document_id", "metadata_list": [{"id": "id", "value": "value", "name": "name"}]}]}'`}
|
||||||
|
>
|
||||||
|
```bash {{ title: 'cURL' }}
|
||||||
|
```
|
||||||
|
</CodeGroup>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
|
||||||
|
<hr className='ml-0 mr-0' />
|
||||||
|
|
||||||
|
<Heading
|
||||||
|
url='/datasets/{dataset_id}/metadata'
|
||||||
|
method='GET'
|
||||||
|
title='Get Knowledge Metadata List'
|
||||||
|
name='#dataset_metadata_list'
|
||||||
|
/>
|
||||||
|
<Row>
|
||||||
|
<Col>
|
||||||
|
### Params
|
||||||
|
<Properties>
|
||||||
|
<Property name='dataset_id' type='string' key='dataset_id'>
|
||||||
|
Knowledge ID
|
||||||
|
</Property>
|
||||||
|
</Properties>
|
||||||
|
</Col>
|
||||||
|
<Col sticky>
|
||||||
|
<CodeGroup
|
||||||
|
title="Request"
|
||||||
|
tag="GET"
|
||||||
|
label="/datasets/{dataset_id}/metadata"
|
||||||
|
targetCode={`curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}/metadata' \\\n--header 'Authorization: Bearer {api_key}'`}
|
||||||
|
>
|
||||||
|
```bash {{ title: 'cURL' }}
|
||||||
|
```
|
||||||
|
</CodeGroup>
|
||||||
|
<CodeGroup title="Response">
|
||||||
|
```json {{ title: 'Response' }}
|
||||||
|
{
|
||||||
|
"doc_metadata": [
|
||||||
|
{
|
||||||
|
"id": "",
|
||||||
|
"name": "name",
|
||||||
|
"type": "string",
|
||||||
|
"use_count": 0,
|
||||||
|
},
|
||||||
|
...
|
||||||
|
],
|
||||||
|
"built_in_field_enabled": true
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
</CodeGroup>
|
</CodeGroup>
|
||||||
|
|||||||
@ -1547,6 +1547,254 @@ import { Row, Col, Properties, Property, Heading, SubProperty, PropertyInstructi
|
|||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
|
|
||||||
|
<hr className='ml-0 mr-0' />
|
||||||
|
|
||||||
|
<Heading
|
||||||
|
url='/datasets/{dataset_id}/metadata'
|
||||||
|
method='POST'
|
||||||
|
title='新增元数据'
|
||||||
|
name='#create_metadata'
|
||||||
|
/>
|
||||||
|
<Row>
|
||||||
|
<Col>
|
||||||
|
### Params
|
||||||
|
<Properties>
|
||||||
|
<Property name='dataset_id' type='string' key='dataset_id'>
|
||||||
|
知识库 ID
|
||||||
|
</Property>
|
||||||
|
</Properties>
|
||||||
|
|
||||||
|
### Request Body
|
||||||
|
<Properties>
|
||||||
|
<Property name='segment' type='object' key='segment'>
|
||||||
|
- <code>type</code> (string) 元数据类型,必填
|
||||||
|
- <code>name</code> (string) 元数据名称,必填
|
||||||
|
</Property>
|
||||||
|
</Properties>
|
||||||
|
</Col>
|
||||||
|
<Col sticky>
|
||||||
|
<CodeGroup
|
||||||
|
title="Request"
|
||||||
|
tag="POST"
|
||||||
|
label="/datasets/{dataset_id}/metadata"
|
||||||
|
targetCode={`curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/metadata' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json'\\\n--data-raw '{"type": "string", "name": "test"}'`}
|
||||||
|
>
|
||||||
|
```bash {{ title: 'cURL' }}
|
||||||
|
```
|
||||||
|
</CodeGroup>
|
||||||
|
<CodeGroup title="Response">
|
||||||
|
```json {{ title: 'Response' }}
|
||||||
|
{
|
||||||
|
"id": "abc",
|
||||||
|
"type": "string",
|
||||||
|
"name": "test",
|
||||||
|
}
|
||||||
|
```
|
||||||
|
</CodeGroup>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
|
||||||
|
<hr className='ml-0 mr-0' />
|
||||||
|
|
||||||
|
<Heading
|
||||||
|
url='/datasets/{dataset_id}/metadata/{metadata_id}'
|
||||||
|
method='PATCH'
|
||||||
|
title='更新元数据'
|
||||||
|
name='#update_metadata'
|
||||||
|
/>
|
||||||
|
<Row>
|
||||||
|
<Col>
|
||||||
|
### Params
|
||||||
|
<Properties>
|
||||||
|
<Property name='dataset_id' type='string' key='dataset_id'>
|
||||||
|
知识库 ID
|
||||||
|
</Property>
|
||||||
|
<Property name='metadata_id' type='string' key='metadata_id'>
|
||||||
|
元数据 ID
|
||||||
|
</Property>
|
||||||
|
</Properties>
|
||||||
|
|
||||||
|
### Request Body
|
||||||
|
<Properties>
|
||||||
|
<Property name='segment' type='object' key='segment'>
|
||||||
|
- <code>name</code> (string) 元数据名称,必填
|
||||||
|
</Property>
|
||||||
|
</Properties>
|
||||||
|
</Col>
|
||||||
|
<Col sticky>
|
||||||
|
<CodeGroup
|
||||||
|
title="Request"
|
||||||
|
tag="POST"
|
||||||
|
label="/datasets/{dataset_id}/metadata/{metadata_id}"
|
||||||
|
targetCode={`curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/metadata/{metadata_id}' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json'\\\n--data-raw '{"name": "test"}'`}
|
||||||
|
>
|
||||||
|
```bash {{ title: 'cURL' }}
|
||||||
|
```
|
||||||
|
</CodeGroup>
|
||||||
|
<CodeGroup title="Response">
|
||||||
|
```json {{ title: 'Response' }}
|
||||||
|
{
|
||||||
|
"id": "abc",
|
||||||
|
"type": "string",
|
||||||
|
"name": "test",
|
||||||
|
}
|
||||||
|
```
|
||||||
|
</CodeGroup>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
|
||||||
|
<hr className='ml-0 mr-0' />
|
||||||
|
|
||||||
|
<Heading
|
||||||
|
url='/datasets/{dataset_id}/metadata/{metadata_id}'
|
||||||
|
method='DELETE'
|
||||||
|
title='删除元数据'
|
||||||
|
name='#delete_metadata'
|
||||||
|
/>
|
||||||
|
<Row>
|
||||||
|
<Col>
|
||||||
|
### Params
|
||||||
|
<Properties>
|
||||||
|
<Property name='dataset_id' type='string' key='dataset_id'>
|
||||||
|
知识库 ID
|
||||||
|
</Property>
|
||||||
|
<Property name='metadata_id' type='string' key='metadata_id'>
|
||||||
|
元数据 ID
|
||||||
|
</Property>
|
||||||
|
</Properties>
|
||||||
|
</Col>
|
||||||
|
<Col sticky>
|
||||||
|
<CodeGroup
|
||||||
|
title="Request"
|
||||||
|
tag="DELETE"
|
||||||
|
label="/datasets/{dataset_id}/metadata/{metadata_id}"
|
||||||
|
targetCode={`curl --location --request DELETE '${props.apiBaseUrl}/datasets/{dataset_id}/metadata/{metadata_id}' \\\n--header 'Authorization: Bearer {api_key}'`}
|
||||||
|
>
|
||||||
|
```bash {{ title: 'cURL' }}
|
||||||
|
```
|
||||||
|
</CodeGroup>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
|
||||||
|
<hr className='ml-0 mr-0' />
|
||||||
|
|
||||||
|
<Heading
|
||||||
|
url='/datasets/{dataset_id}/metadata/built-in/{action}'
|
||||||
|
method='POST'
|
||||||
|
title='启用/禁用元数据'
|
||||||
|
name='#toggle_metadata'
|
||||||
|
/>
|
||||||
|
<Row>
|
||||||
|
<Col>
|
||||||
|
### Params
|
||||||
|
<Properties>
|
||||||
|
<Property name='dataset_id' type='string' key='dataset_id'>
|
||||||
|
知识库 ID
|
||||||
|
</Property>
|
||||||
|
<Property name='action' type='string' key='action'>
|
||||||
|
disable/enable
|
||||||
|
</Property>
|
||||||
|
</Properties>
|
||||||
|
</Col>
|
||||||
|
<Col sticky>
|
||||||
|
<CodeGroup
|
||||||
|
title="Request"
|
||||||
|
tag="POST"
|
||||||
|
label="/datasets/{dataset_id}/metadata/built-in/{action}"
|
||||||
|
targetCode={`curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/metadata/built-in/{action}' \\\n--header 'Authorization: Bearer {api_key}'`}
|
||||||
|
>
|
||||||
|
```bash {{ title: 'cURL' }}
|
||||||
|
```
|
||||||
|
</CodeGroup>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
|
||||||
|
<hr className='ml-0 mr-0' />
|
||||||
|
|
||||||
|
<Heading
|
||||||
|
url='/datasets/{dataset_id}/documents/metadata'
|
||||||
|
method='POST'
|
||||||
|
title='更新文档元数据'
|
||||||
|
name='#update_documents_metadata'
|
||||||
|
/>
|
||||||
|
<Row>
|
||||||
|
<Col>
|
||||||
|
### Params
|
||||||
|
<Properties>
|
||||||
|
<Property name='dataset_id' type='string' key='dataset_id'>
|
||||||
|
知识库 ID
|
||||||
|
</Property>
|
||||||
|
</Properties>
|
||||||
|
|
||||||
|
### Request Body
|
||||||
|
<Properties>
|
||||||
|
<Property name='operation_data' type='object list' key='segments'>
|
||||||
|
- <code>document_id</code> (string) 文档 ID
|
||||||
|
- <code>metadata_list</code> (list) 元数据列表
|
||||||
|
- <code>id</code> (string) 元数据 ID
|
||||||
|
- <code>type</code> (string) 元数据类型
|
||||||
|
- <code>name</code> (string) 元数据名称
|
||||||
|
</Property>
|
||||||
|
</Properties>
|
||||||
|
</Col>
|
||||||
|
<Col sticky>
|
||||||
|
<CodeGroup
|
||||||
|
title="Request"
|
||||||
|
tag="POST"
|
||||||
|
label="/datasets/{dataset_id}/documents/metadata"
|
||||||
|
targetCode={`curl --location --request POST '${props.apiBaseUrl}/datasets/{dataset_id}/documents/metadata' \\\n--header 'Authorization: Bearer {api_key}' \\\n--header 'Content-Type: application/json'\\\n--data-raw '{"operation_data": [{"document_id": "document_id", "metadata_list": [{"id": "id", "value": "value", "name": "name"}]}]}'`}
|
||||||
|
>
|
||||||
|
```bash {{ title: 'cURL' }}
|
||||||
|
```
|
||||||
|
</CodeGroup>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
|
||||||
|
<hr className='ml-0 mr-0' />
|
||||||
|
|
||||||
|
<Heading
|
||||||
|
url='/datasets/{dataset_id}/metadata'
|
||||||
|
method='GET'
|
||||||
|
title='查询知识库元数据列表'
|
||||||
|
name='#dataset_metadata_list'
|
||||||
|
/>
|
||||||
|
<Row>
|
||||||
|
<Col>
|
||||||
|
### Query
|
||||||
|
<Properties>
|
||||||
|
<Property name='dataset_id' type='string' key='dataset_id'>
|
||||||
|
知识库 ID
|
||||||
|
</Property>
|
||||||
|
</Properties>
|
||||||
|
</Col>
|
||||||
|
<Col sticky>
|
||||||
|
<CodeGroup
|
||||||
|
title="Request"
|
||||||
|
tag="GET"
|
||||||
|
label="/datasets/{dataset_id}/metadata"
|
||||||
|
targetCode={`curl --location --request GET '${props.apiBaseUrl}/datasets/{dataset_id}/metadata' \\\n--header 'Authorization: Bearer {api_key}'`}
|
||||||
|
>
|
||||||
|
```bash {{ title: 'cURL' }}
|
||||||
|
```
|
||||||
|
</CodeGroup>
|
||||||
|
<CodeGroup title="Response">
|
||||||
|
```json {{ title: 'Response' }}
|
||||||
|
{
|
||||||
|
"doc_metadata": [
|
||||||
|
{
|
||||||
|
"id": "",
|
||||||
|
"name": "name",
|
||||||
|
"type": "string",
|
||||||
|
"use_count": 0,
|
||||||
|
},
|
||||||
|
...
|
||||||
|
],
|
||||||
|
"built_in_field_enabled": true
|
||||||
|
}
|
||||||
|
```
|
||||||
|
</CodeGroup>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
|
||||||
<hr className='ml-0 mr-0' />
|
<hr className='ml-0 mr-0' />
|
||||||
|
|
||||||
|
|||||||
@ -12,7 +12,7 @@ const useEditDatasetMetadata = ({
|
|||||||
// dataset,
|
// dataset,
|
||||||
}: {
|
}: {
|
||||||
datasetId: string,
|
datasetId: string,
|
||||||
dataset?: DataSet
|
dataset?: DataSet,
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const [isShowEditModal, {
|
const [isShowEditModal, {
|
||||||
@ -57,7 +57,7 @@ const useEditDatasetMetadata = ({
|
|||||||
await doRenameMetaData(payload)
|
await doRenameMetaData(payload)
|
||||||
}, [checkName, doRenameMetaData])
|
}, [checkName, doRenameMetaData])
|
||||||
|
|
||||||
const { mutate: doDeleteMetaData } = useDeleteMetaData(datasetId)
|
const { mutateAsync: doDeleteMetaData } = useDeleteMetaData(datasetId)
|
||||||
const handleDeleteMetaData = useCallback((metaDataId: string) => {
|
const handleDeleteMetaData = useCallback((metaDataId: string) => {
|
||||||
doDeleteMetaData(metaDataId)
|
doDeleteMetaData(metaDataId)
|
||||||
}, [doDeleteMetaData])
|
}, [doDeleteMetaData])
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import type { BuiltInMetadataItem, MetadataBatchEditToServer, MetadataItemWithValueLength } from '@/app/components/datasets/metadata/types'
|
import type { BuiltInMetadataItem, MetadataBatchEditToServer, MetadataItemWithValueLength } from '@/app/components/datasets/metadata/types'
|
||||||
import { del, get, patch, post } from '../base'
|
import { del, get, patch, post } from '../base'
|
||||||
|
import { mutate } from 'swr'
|
||||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
||||||
import { useInvalid } from '../use-base'
|
import { useInvalid } from '../use-base'
|
||||||
import type { DocumentDetailResponse } from '@/models/datasets'
|
import type { DocumentDetailResponse } from '@/models/datasets'
|
||||||
@ -32,9 +32,33 @@ export const useCreateMetaData = (datasetId: string) => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
export const useInvalidAllDocumentMetaData = (datasetId: string) => {
|
||||||
|
const queryClient = useQueryClient()
|
||||||
|
return () => {
|
||||||
|
queryClient.invalidateQueries({
|
||||||
|
queryKey: [NAME_SPACE, 'document', datasetId],
|
||||||
|
exact: false, // invalidate all document metadata: [NAME_SPACE, 'document', datasetId, documentId]
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const useInvalidAllMetaData = (datasetId: string) => {
|
||||||
|
const invalidDatasetMetaData = useInvalidDatasetMetaData(datasetId)
|
||||||
|
const invalidateAllDocumentMetaData = useInvalidAllDocumentMetaData(datasetId)
|
||||||
|
return async () => {
|
||||||
|
// meta data in dataset
|
||||||
|
await invalidDatasetMetaData()
|
||||||
|
// meta data in document list
|
||||||
|
mutate(
|
||||||
|
(key: any) => typeof key === 'object' && key.action === 'fetchDocuments' && key.datasetId === datasetId,
|
||||||
|
)
|
||||||
|
// meta data in single document
|
||||||
|
await invalidateAllDocumentMetaData() // meta data in document
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export const useRenameMeta = (datasetId: string) => {
|
export const useRenameMeta = (datasetId: string) => {
|
||||||
const invalidDatasetMetaData = useInvalidDatasetMetaData(datasetId)
|
const invalidateAllMetaData = useInvalidAllMetaData(datasetId)
|
||||||
return useMutation({
|
return useMutation({
|
||||||
mutationFn: async (payload: MetadataItemWithValueLength) => {
|
mutationFn: async (payload: MetadataItemWithValueLength) => {
|
||||||
await patch(`/datasets/${datasetId}/metadata/${payload.id}`, {
|
await patch(`/datasets/${datasetId}/metadata/${payload.id}`, {
|
||||||
@ -42,20 +66,18 @@ export const useRenameMeta = (datasetId: string) => {
|
|||||||
name: payload.name,
|
name: payload.name,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
await invalidDatasetMetaData()
|
await invalidateAllMetaData()
|
||||||
return Promise.resolve(true)
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useDeleteMetaData = (datasetId: string) => {
|
export const useDeleteMetaData = (datasetId: string) => {
|
||||||
const invalidDatasetMetaData = useInvalidDatasetMetaData(datasetId)
|
const invalidateAllMetaData = useInvalidAllMetaData(datasetId)
|
||||||
return useMutation({
|
return useMutation({
|
||||||
mutationFn: async (metaDataId: string) => {
|
mutationFn: async (metaDataId: string) => {
|
||||||
// datasetMetaData = datasetMetaData.filter(item => item.id !== metaDataId)
|
// datasetMetaData = datasetMetaData.filter(item => item.id !== metaDataId)
|
||||||
await del(`/datasets/${datasetId}/metadata/${metaDataId}`)
|
await del(`/datasets/${datasetId}/metadata/${metaDataId}`)
|
||||||
await invalidDatasetMetaData()
|
await invalidateAllMetaData()
|
||||||
return Promise.resolve(true)
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -80,7 +102,6 @@ export const useDocumentMetaData = ({ datasetId, documentId }: { datasetId: stri
|
|||||||
|
|
||||||
export const useBatchUpdateDocMetadata = () => {
|
export const useBatchUpdateDocMetadata = () => {
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
|
|
||||||
return useMutation({
|
return useMutation({
|
||||||
mutationFn: async (payload: {
|
mutationFn: async (payload: {
|
||||||
dataset_id: string
|
dataset_id: string
|
||||||
@ -92,10 +113,15 @@ export const useBatchUpdateDocMetadata = () => {
|
|||||||
operation_data: payload.metadata_list,
|
operation_data: payload.metadata_list,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
// meta data in dataset
|
||||||
await queryClient.invalidateQueries({
|
await queryClient.invalidateQueries({
|
||||||
queryKey: [NAME_SPACE, 'dataset', payload.dataset_id],
|
queryKey: [NAME_SPACE, 'dataset', payload.dataset_id],
|
||||||
})
|
})
|
||||||
// invalidate document metadata
|
// meta data in document list
|
||||||
|
mutate(
|
||||||
|
(key: any) => typeof key === 'object' && key.action === 'fetchDocuments' && key.datasetId === payload.dataset_id,
|
||||||
|
)
|
||||||
|
// meta data in single document
|
||||||
await Promise.all(documentIds.map(documentId => queryClient.invalidateQueries(
|
await Promise.all(documentIds.map(documentId => queryClient.invalidateQueries(
|
||||||
{
|
{
|
||||||
queryKey: [NAME_SPACE, 'document', payload.dataset_id, documentId],
|
queryKey: [NAME_SPACE, 'document', payload.dataset_id, documentId],
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user