mirror of
https://github.com/labring/FastGPT.git
synced 2025-08-01 03:48:24 +00:00
Collection tag (#2266)
* feat: collection metadata filter (#2211) * feat: add dataset collection tags (#2231) * dataset page * workflow page * move * fix * add plus filter * fix * fix * fix * perf: collection tag code * fix: collection tags (#2249) * fix * fix * fix tags of dataset page * fix tags of workflow page * doc * add comments * fix: collection tags (#2264) * fix: metadata filter * feat: search filter --------- Co-authored-by: heheer <1239331448@qq.com> Co-authored-by: heheer <heheer@sealos.io>
This commit is contained in:
@@ -6,18 +6,23 @@ import type {
|
||||
import type {
|
||||
DatasetItemType,
|
||||
DatasetListItemType,
|
||||
DatasetSimpleItemType
|
||||
DatasetSimpleItemType,
|
||||
DatasetTagType,
|
||||
TagUsageType
|
||||
} from '@fastgpt/global/core/dataset/type.d';
|
||||
import type { GetDatasetCollectionsProps } from '@/global/core/api/datasetReq.d';
|
||||
import type {
|
||||
AddTagsToCollectionsParams,
|
||||
CreateDatasetCollectionParams,
|
||||
CreateDatasetCollectionTagParams,
|
||||
CsvTableCreateDatasetCollectionParams,
|
||||
DatasetUpdateBody,
|
||||
ExternalFileCreateDatasetCollectionParams,
|
||||
FileIdCreateDatasetCollectionParams,
|
||||
LinkCreateDatasetCollectionParams,
|
||||
PostWebsiteSyncParams,
|
||||
TextCreateDatasetCollectionParams
|
||||
TextCreateDatasetCollectionParams,
|
||||
UpdateDatasetCollectionTagParams
|
||||
} from '@fastgpt/global/core/dataset/api.d';
|
||||
import type {
|
||||
GetTrainingQueueProps,
|
||||
@@ -43,6 +48,8 @@ import type { UpdateDatasetCollectionParams } from '@/pages/api/core/dataset/col
|
||||
import type { GetDatasetDataListProps } from '@/pages/api/core/dataset/data/list';
|
||||
import type { UpdateDatasetDataProps } from '@fastgpt/global/core/dataset/controller';
|
||||
import type { DatasetFolderCreateBody } from '@/pages/api/core/dataset/folder/create';
|
||||
import { PaginationProps, PaginationResponse } from '@fastgpt/web/common/fetch/type';
|
||||
import { GetScrollCollectionsProps } from '@/pages/api/core/dataset/collection/scrollList';
|
||||
|
||||
/* ======================== dataset ======================= */
|
||||
export const getDatasets = (data: GetDatasetListBody) =>
|
||||
@@ -117,6 +124,32 @@ export const postLinkCollectionSync = (collectionId: string) =>
|
||||
collectionId
|
||||
});
|
||||
|
||||
/* =============================== tag ==================================== */
|
||||
|
||||
export const postCreateDatasetCollectionTag = (data: CreateDatasetCollectionTagParams) =>
|
||||
POST(`/proApi/core/dataset/tag/create`, data);
|
||||
export const postAddTagsToCollections = (data: AddTagsToCollectionsParams) =>
|
||||
POST(`/proApi/core/dataset/tag/addToCollections`, data);
|
||||
export const delDatasetCollectionTag = (data: { id: string; datasetId: string }) =>
|
||||
DELETE(`/proApi/core/dataset/tag/delete`, data);
|
||||
export const updateDatasetCollectionTag = (data: UpdateDatasetCollectionTagParams) =>
|
||||
POST(`/proApi/core/dataset/tag/update`, data);
|
||||
export const getDatasetCollectionTags = (
|
||||
data: PaginationProps<{
|
||||
datasetId: string;
|
||||
searchText?: string;
|
||||
}>
|
||||
) => GET<PaginationResponse<DatasetTagType>>(`/proApi/core/dataset/tag/list`, data);
|
||||
export const getTagUsage = (datasetId: string) =>
|
||||
GET<TagUsageType[]>(`/proApi/core/dataset/tag/tagUsage?datasetId=${datasetId}`);
|
||||
export const getAllTags = (datasetId: string) =>
|
||||
GET<{ list: DatasetTagType[] }>(`/proApi/core/dataset/tag/getAllTags?datasetId=${datasetId}`);
|
||||
export const getScrollCollectionList = (data: GetScrollCollectionsProps) =>
|
||||
GET<PaginationResponse<DatasetCollectionsListItemType>>(
|
||||
`/core/dataset/collection/scrollList`,
|
||||
data
|
||||
);
|
||||
|
||||
/* =============================== data ==================================== */
|
||||
/* get dataset list */
|
||||
export const getDatasetDataList = (data: GetDatasetDataListProps) =>
|
||||
|
@@ -3,7 +3,6 @@ import MyModal from '@fastgpt/web/components/common/MyModal';
|
||||
import ParentPaths from '@/components/common/ParentPaths';
|
||||
import { useRequest } from '@fastgpt/web/hooks/useRequest';
|
||||
import { getDatasetCollectionPathById, getDatasetCollections } from '@/web/core/dataset/api';
|
||||
import { useDatasetStore } from '@/web/core/dataset/store/dataset';
|
||||
import { Box, Flex, ModalFooter, Button, useTheme, Grid, Card, ModalBody } from '@chakra-ui/react';
|
||||
import { DatasetCollectionTypeEnum } from '@fastgpt/global/core/dataset/constants';
|
||||
import { getCollectionIcon } from '@fastgpt/global/core/dataset/utils';
|
||||
|
@@ -51,6 +51,7 @@ export const defaultCollectionDetail: DatasetCollectionItemType = {
|
||||
defaultPermission: DatasetDefaultPermissionVal,
|
||||
inheritPermission: true
|
||||
},
|
||||
tags: [],
|
||||
parentId: '',
|
||||
name: '',
|
||||
type: DatasetCollectionTypeEnum.file,
|
||||
|
@@ -1,22 +1,30 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { ReactNode, useMemo, useState } from 'react';
|
||||
import { ReactNode, SetStateAction, useMemo, useState } from 'react';
|
||||
import { useTranslation } from 'next-i18next';
|
||||
import { createContext } from 'use-context-selector';
|
||||
import {
|
||||
getAllTags,
|
||||
getDatasetById,
|
||||
getDatasetCollectionTags,
|
||||
getDatasetTrainingQueue,
|
||||
getTrainingQueueLen,
|
||||
putDatasetById
|
||||
} from '../api';
|
||||
import { defaultDatasetDetail } from '../constants';
|
||||
import { DatasetUpdateBody } from '@fastgpt/global/core/dataset/api';
|
||||
import { DatasetItemType } from '@fastgpt/global/core/dataset/type';
|
||||
import { DatasetItemType, DatasetTagType } from '@fastgpt/global/core/dataset/type';
|
||||
|
||||
type DatasetPageContextType = {
|
||||
datasetId: string;
|
||||
datasetDetail: DatasetItemType;
|
||||
loadDatasetDetail: (id: string) => Promise<DatasetItemType>;
|
||||
updateDataset: (data: DatasetUpdateBody) => Promise<void>;
|
||||
datasetTags: DatasetTagType[];
|
||||
loadDatasetTags: (data: { id: string; searchKey: string }) => Promise<void>;
|
||||
allDatasetTags: DatasetTagType[];
|
||||
loadAllDatasetTags: (data: { id: string }) => Promise<void>;
|
||||
checkedDatasetTag: DatasetTagType[];
|
||||
setCheckedDatasetTag: React.Dispatch<SetStateAction<DatasetTagType[]>>;
|
||||
|
||||
vectorTrainingMap: {
|
||||
colorSchema: string;
|
||||
@@ -52,6 +60,18 @@ export const DatasetPageContext = createContext<DatasetPageContextType>({
|
||||
},
|
||||
updateDataset: function (data: DatasetUpdateBody): Promise<void> {
|
||||
throw new Error('Function not implemented.');
|
||||
},
|
||||
datasetTags: [],
|
||||
loadDatasetTags: function (data: { id: string; searchKey: string }): Promise<void> {
|
||||
throw new Error('Function not implemented.');
|
||||
},
|
||||
allDatasetTags: [],
|
||||
loadAllDatasetTags: function (data: { id: string }): Promise<void> {
|
||||
throw new Error('Function not implemented.');
|
||||
},
|
||||
checkedDatasetTag: [],
|
||||
setCheckedDatasetTag: function (): void {
|
||||
throw new Error('Function not implemented.');
|
||||
}
|
||||
});
|
||||
|
||||
@@ -85,6 +105,28 @@ export const DatasetPageContextProvider = ({
|
||||
}
|
||||
};
|
||||
|
||||
// dataset tags
|
||||
const [datasetTags, setDatasetTags] = useState<DatasetTagType[]>([]);
|
||||
|
||||
const loadDatasetTags = async ({ id, searchKey }: { id: string; searchKey: string }) => {
|
||||
const { list } = await getDatasetCollectionTags({
|
||||
datasetId: id,
|
||||
searchText: searchKey,
|
||||
current: 1,
|
||||
pageSize: 15
|
||||
});
|
||||
setDatasetTags(list);
|
||||
};
|
||||
|
||||
const [checkedDatasetTag, setCheckedDatasetTag] = useState<DatasetTagType[]>([]);
|
||||
|
||||
const [allDatasetTags, setAllDatasetTags] = useState<DatasetTagType[]>([]);
|
||||
|
||||
const loadAllDatasetTags = async ({ id }: { id: string }) => {
|
||||
const { list } = await getAllTags(id);
|
||||
setAllDatasetTags(list);
|
||||
};
|
||||
|
||||
// global queue
|
||||
const { data: { vectorTrainingCount = 0, agentTrainingCount = 0 } = {} } = useQuery(
|
||||
['getTrainingQueueLen'],
|
||||
@@ -152,7 +194,13 @@ export const DatasetPageContextProvider = ({
|
||||
agentTrainingMap,
|
||||
rebuildingCount,
|
||||
trainingCount,
|
||||
refetchDatasetTraining
|
||||
refetchDatasetTraining,
|
||||
datasetTags,
|
||||
loadDatasetTags,
|
||||
checkedDatasetTag,
|
||||
setCheckedDatasetTag,
|
||||
allDatasetTags,
|
||||
loadAllDatasetTags
|
||||
};
|
||||
|
||||
return <DatasetPageContext.Provider value={contextValue}>{children}</DatasetPageContext.Provider>;
|
||||
|
Reference in New Issue
Block a user