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
|
||||
url='/datasets/{dataset_id}/metadata'
|
||||
method='POST'
|
||||
title='Create a Knowledge metadata'
|
||||
title='Create a Knowledge Metadata'
|
||||
name='#create_metadata'
|
||||
/>
|
||||
<Row>
|
||||
<Col>
|
||||
### POST
|
||||
### Params
|
||||
<Properties>
|
||||
<Property name='dataset_id' type='string' key='dataset_id'>
|
||||
Knowledge ID
|
||||
@ -1561,8 +1561,8 @@ import { Row, Col, Properties, Property, Heading, SubProperty, PropertyInstructi
|
||||
### Request Body
|
||||
<Properties>
|
||||
<Property name='segment' type='object' key='segment'>
|
||||
- <code>type</code> (string) metadata type, required
|
||||
- <code>name</code> (string) metadata name, required
|
||||
- <code>type</code> (string) Metadata type, required
|
||||
- <code>name</code> (string) Metadata name, required
|
||||
</Property>
|
||||
</Properties>
|
||||
</Col>
|
||||
@ -1571,23 +1571,219 @@ import { Row, Col, Properties, Property, Heading, SubProperty, PropertyInstructi
|
||||
title="Request"
|
||||
tag="POST"
|
||||
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' }}
|
||||
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 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>
|
||||
|
@ -1547,6 +1547,254 @@ import { Row, Col, Properties, Property, Heading, SubProperty, PropertyInstructi
|
||||
</Col>
|
||||
</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' />
|
||||
|
||||
|
@ -12,7 +12,7 @@ const useEditDatasetMetadata = ({
|
||||
// dataset,
|
||||
}: {
|
||||
datasetId: string,
|
||||
dataset?: DataSet
|
||||
dataset?: DataSet,
|
||||
}) => {
|
||||
const { t } = useTranslation()
|
||||
const [isShowEditModal, {
|
||||
@ -57,7 +57,7 @@ const useEditDatasetMetadata = ({
|
||||
await doRenameMetaData(payload)
|
||||
}, [checkName, doRenameMetaData])
|
||||
|
||||
const { mutate: doDeleteMetaData } = useDeleteMetaData(datasetId)
|
||||
const { mutateAsync: doDeleteMetaData } = useDeleteMetaData(datasetId)
|
||||
const handleDeleteMetaData = useCallback((metaDataId: string) => {
|
||||
doDeleteMetaData(metaDataId)
|
||||
}, [doDeleteMetaData])
|
||||
|
@ -1,6 +1,6 @@
|
||||
import type { BuiltInMetadataItem, MetadataBatchEditToServer, MetadataItemWithValueLength } from '@/app/components/datasets/metadata/types'
|
||||
import { del, get, patch, post } from '../base'
|
||||
|
||||
import { mutate } from 'swr'
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { useInvalid } from '../use-base'
|
||||
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) => {
|
||||
const invalidDatasetMetaData = useInvalidDatasetMetaData(datasetId)
|
||||
const invalidateAllMetaData = useInvalidAllMetaData(datasetId)
|
||||
return useMutation({
|
||||
mutationFn: async (payload: MetadataItemWithValueLength) => {
|
||||
await patch(`/datasets/${datasetId}/metadata/${payload.id}`, {
|
||||
@ -42,20 +66,18 @@ export const useRenameMeta = (datasetId: string) => {
|
||||
name: payload.name,
|
||||
},
|
||||
})
|
||||
await invalidDatasetMetaData()
|
||||
return Promise.resolve(true)
|
||||
await invalidateAllMetaData()
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export const useDeleteMetaData = (datasetId: string) => {
|
||||
const invalidDatasetMetaData = useInvalidDatasetMetaData(datasetId)
|
||||
const invalidateAllMetaData = useInvalidAllMetaData(datasetId)
|
||||
return useMutation({
|
||||
mutationFn: async (metaDataId: string) => {
|
||||
// datasetMetaData = datasetMetaData.filter(item => item.id !== metaDataId)
|
||||
await del(`/datasets/${datasetId}/metadata/${metaDataId}`)
|
||||
await invalidDatasetMetaData()
|
||||
return Promise.resolve(true)
|
||||
await invalidateAllMetaData()
|
||||
},
|
||||
})
|
||||
}
|
||||
@ -80,7 +102,6 @@ export const useDocumentMetaData = ({ datasetId, documentId }: { datasetId: stri
|
||||
|
||||
export const useBatchUpdateDocMetadata = () => {
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async (payload: {
|
||||
dataset_id: string
|
||||
@ -92,10 +113,15 @@ export const useBatchUpdateDocMetadata = () => {
|
||||
operation_data: payload.metadata_list,
|
||||
},
|
||||
})
|
||||
// meta data in dataset
|
||||
await queryClient.invalidateQueries({
|
||||
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(
|
||||
{
|
||||
queryKey: [NAME_SPACE, 'document', payload.dataset_id, documentId],
|
||||
|
Loading…
Reference in New Issue
Block a user