mirror of
https://github.com/labring/FastGPT.git
synced 2025-08-03 13:38:00 +00:00
4.6.3-website dataset (#532)
This commit is contained in:
@@ -1095,7 +1095,7 @@ export const appTemplates: (AppItemType & {
|
||||
key: 'text',
|
||||
type: 'textarea',
|
||||
valueType: 'string',
|
||||
value: '你好,我是 laf 助手,有什么可以帮助你的?',
|
||||
value: '你好,有什么可以帮助你的?',
|
||||
label: '回复的内容',
|
||||
description:
|
||||
'可以使用 \\n 来实现连续换行。\n\n可以通过外部模块输入实现回复,外部模块输入时会覆盖当前填写的内容',
|
||||
|
@@ -1,13 +1,16 @@
|
||||
import { GET, POST, PUT, DELETE } from '@/web/common/api/request';
|
||||
import type { ParentTreePathItemType } from '@fastgpt/global/common/parentFolder/type.d';
|
||||
import type { DatasetItemType } from '@fastgpt/global/core/dataset/type.d';
|
||||
import type { DatasetItemType, DatasetListItemType } from '@fastgpt/global/core/dataset/type.d';
|
||||
import type {
|
||||
DatasetUpdateParams,
|
||||
GetDatasetCollectionsProps,
|
||||
GetDatasetDataListProps,
|
||||
CreateDatasetCollectionParams,
|
||||
UpdateDatasetCollectionParams
|
||||
} from '@/global/core/api/datasetReq.d';
|
||||
import type {
|
||||
CreateDatasetCollectionParams,
|
||||
DatasetUpdateBody,
|
||||
PostWebsiteSyncParams
|
||||
} from '@fastgpt/global/core/dataset/api.d';
|
||||
import type { SearchTestProps, SearchTestResponse } from '@/global/core/dataset/api.d';
|
||||
import type {
|
||||
PushDatasetDataProps,
|
||||
@@ -24,12 +27,12 @@ import { PagingData } from '@/types';
|
||||
|
||||
/* ======================== dataset ======================= */
|
||||
export const getDatasets = (data: { parentId?: string; type?: `${DatasetTypeEnum}` }) =>
|
||||
GET<DatasetItemType[]>(`/core/dataset/list`, data);
|
||||
GET<DatasetListItemType[]>(`/core/dataset/list`, data);
|
||||
|
||||
/**
|
||||
* get type=dataset list
|
||||
*/
|
||||
export const getAllDataset = () => GET<DatasetItemType[]>(`/core/dataset/allDataset`);
|
||||
export const getAllDataset = () => GET<DatasetListItemType[]>(`/core/dataset/allDataset`);
|
||||
|
||||
export const getDatasetPaths = (parentId?: string) =>
|
||||
GET<ParentTreePathItemType[]>('/core/dataset/paths', { parentId });
|
||||
@@ -39,7 +42,7 @@ export const getDatasetById = (id: string) => GET<DatasetItemType>(`/core/datase
|
||||
export const postCreateDataset = (data: CreateDatasetParams) =>
|
||||
POST<string>(`/core/dataset/create`, data);
|
||||
|
||||
export const putDatasetById = (data: DatasetUpdateParams) => PUT(`/core/dataset/update`, data);
|
||||
export const putDatasetById = (data: DatasetUpdateBody) => PUT<void>(`/core/dataset/update`, data);
|
||||
|
||||
export const delDatasetById = (id: string) => DELETE(`/core/dataset/delete?id=${id}`);
|
||||
|
||||
@@ -62,7 +65,11 @@ export const postDatasetCollection = (data: CreateDatasetCollectionParams) =>
|
||||
export const putDatasetCollectionById = (data: UpdateDatasetCollectionParams) =>
|
||||
POST(`/core/dataset/collection/update`, data);
|
||||
export const delDatasetCollectionById = (params: { collectionId: string }) =>
|
||||
DELETE(`/core/dataset/collection/delById`, params);
|
||||
DELETE(`/core/dataset/collection/delete`, params);
|
||||
export const postWebsiteSync = (data: PostWebsiteSyncParams) =>
|
||||
POST(`/plusApi/core/dataset/websiteSync`, data, {
|
||||
timeout: 600000
|
||||
}).catch();
|
||||
|
||||
/* =============================== data ==================================== */
|
||||
/* get dataset list */
|
||||
|
@@ -1,20 +1,20 @@
|
||||
import { create } from 'zustand';
|
||||
import { devtools, persist } from 'zustand/middleware';
|
||||
import { immer } from 'zustand/middleware/immer';
|
||||
import type { DatasetItemType } from '@fastgpt/global/core/dataset/type.d';
|
||||
import type { DatasetItemType, DatasetListItemType } from '@fastgpt/global/core/dataset/type.d';
|
||||
import { getAllDataset, getDatasets, getDatasetById, putDatasetById } from '@/web/core/dataset/api';
|
||||
import { defaultDatasetDetail } from '@/constants/dataset';
|
||||
import type { DatasetUpdateParams } from '@/global/core/api/datasetReq.d';
|
||||
import type { DatasetUpdateBody } from '@fastgpt/global/core/dataset/api.d';
|
||||
|
||||
type State = {
|
||||
allDatasets: DatasetItemType[];
|
||||
loadAllDatasets: () => Promise<DatasetItemType[]>;
|
||||
myDatasets: DatasetItemType[];
|
||||
allDatasets: DatasetListItemType[];
|
||||
loadAllDatasets: () => Promise<DatasetListItemType[]>;
|
||||
myDatasets: DatasetListItemType[];
|
||||
loadDatasets: (parentId?: string) => Promise<any>;
|
||||
setDatasets(val: DatasetItemType[]): void;
|
||||
setDatasets(val: DatasetListItemType[]): void;
|
||||
datasetDetail: DatasetItemType;
|
||||
loadDatasetDetail: (id: string, init?: boolean) => Promise<DatasetItemType>;
|
||||
updateDataset: (data: DatasetUpdateParams) => Promise<any>;
|
||||
updateDataset: (data: DatasetUpdateBody) => Promise<any>;
|
||||
};
|
||||
|
||||
export const useDatasetStore = create<State>()(
|
||||
@@ -55,10 +55,12 @@ export const useDatasetStore = create<State>()(
|
||||
return data;
|
||||
},
|
||||
async updateDataset(data) {
|
||||
await putDatasetById(data);
|
||||
|
||||
if (get().datasetDetail._id === data.id) {
|
||||
set((state) => {
|
||||
state.datasetDetail = {
|
||||
...state.datasetDetail,
|
||||
...get().datasetDetail,
|
||||
...data
|
||||
};
|
||||
});
|
||||
@@ -74,7 +76,6 @@ export const useDatasetStore = create<State>()(
|
||||
: item
|
||||
);
|
||||
});
|
||||
await putDatasetById(data);
|
||||
}
|
||||
})),
|
||||
{
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import { getFileViewUrl, postChunks2Dataset } from '@/web/core/dataset/api';
|
||||
import { TrainingModeEnum } from '@fastgpt/global/core/dataset/constant';
|
||||
import { delay } from '@/utils/tools';
|
||||
import { delay } from '@fastgpt/global/common/system/utils';
|
||||
import { strIsLink } from '@fastgpt/global/common/string/tools';
|
||||
import type { PushDatasetDataChunkProps } from '@fastgpt/global/core/dataset/api.d';
|
||||
|
||||
|
Reference in New Issue
Block a user