mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-24 22:03:54 +00:00
v4.5.1 (#417)
This commit is contained in:
62
packages/global/core/dataset/constant.ts
Normal file
62
packages/global/core/dataset/constant.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
export enum DatasetTypeEnum {
|
||||
folder = 'folder',
|
||||
dataset = 'dataset'
|
||||
}
|
||||
|
||||
export const DatasetTypeMap = {
|
||||
[DatasetTypeEnum.folder]: {
|
||||
name: 'folder'
|
||||
},
|
||||
[DatasetTypeEnum.dataset]: {
|
||||
name: 'dataset'
|
||||
}
|
||||
};
|
||||
|
||||
export enum DatasetCollectionTypeEnum {
|
||||
file = 'file',
|
||||
folder = 'folder',
|
||||
link = 'link',
|
||||
virtual = 'virtual'
|
||||
}
|
||||
|
||||
export const DatasetCollectionTypeMap = {
|
||||
[DatasetCollectionTypeEnum.file]: {
|
||||
name: 'dataset.file'
|
||||
},
|
||||
[DatasetCollectionTypeEnum.folder]: {
|
||||
name: 'dataset.folder'
|
||||
},
|
||||
[DatasetCollectionTypeEnum.link]: {
|
||||
name: 'dataset.link'
|
||||
},
|
||||
[DatasetCollectionTypeEnum.virtual]: {
|
||||
name: 'dataset.Virtual File'
|
||||
}
|
||||
};
|
||||
|
||||
export enum TrainingModeEnum {
|
||||
'qa' = 'qa',
|
||||
'index' = 'index'
|
||||
}
|
||||
export const TrainingTypeMap = {
|
||||
[TrainingModeEnum.qa]: 'qa',
|
||||
[TrainingModeEnum.index]: 'index'
|
||||
};
|
||||
|
||||
export enum DatasetSpecialIdEnum {
|
||||
manual = 'manual',
|
||||
mark = 'mark'
|
||||
}
|
||||
export const datasetSpecialIdMap = {
|
||||
[DatasetSpecialIdEnum.manual]: {
|
||||
name: 'kb.Manual Data',
|
||||
sourceName: 'kb.Manual Input'
|
||||
},
|
||||
[DatasetSpecialIdEnum.mark]: {
|
||||
name: 'kb.Mark Data',
|
||||
sourceName: 'kb.Manual Mark'
|
||||
}
|
||||
};
|
||||
export const datasetSpecialIds: string[] = [DatasetSpecialIdEnum.manual, DatasetSpecialIdEnum.mark];
|
||||
|
||||
export const FolderAvatarSrc = '/imgs/files/folder.svg';
|
75
packages/global/core/dataset/type.d.ts
vendored
Normal file
75
packages/global/core/dataset/type.d.ts
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
import { DatasetCollectionTypeEnum, DatasetTypeEnum, TrainingModeEnum } from './constant';
|
||||
|
||||
export type DatasetSchemaType = {
|
||||
_id: string;
|
||||
userId: string;
|
||||
parentId: string;
|
||||
updateTime: Date;
|
||||
avatar: string;
|
||||
name: string;
|
||||
vectorModel: string;
|
||||
tags: string[];
|
||||
type: `${DatasetTypeEnum}`;
|
||||
};
|
||||
|
||||
export type DatasetCollectionSchemaType = {
|
||||
_id: string;
|
||||
userId: string;
|
||||
datasetId: string;
|
||||
parentId?: string;
|
||||
name: string;
|
||||
type: `${DatasetCollectionTypeEnum}`;
|
||||
updateTime: Date;
|
||||
metadata: {
|
||||
fileId?: string;
|
||||
rawLink?: string;
|
||||
pgCollectionId?: string;
|
||||
};
|
||||
};
|
||||
|
||||
export type DatasetTrainingSchemaType = {
|
||||
_id: string;
|
||||
userId: string;
|
||||
datasetId: string;
|
||||
datasetCollectionId: string;
|
||||
billId: string;
|
||||
expireAt: Date;
|
||||
lockTime: Date;
|
||||
mode: `${TrainingModeEnum}`;
|
||||
model: string;
|
||||
prompt: string;
|
||||
q: string;
|
||||
a: string;
|
||||
};
|
||||
|
||||
/* ================= dataset ===================== */
|
||||
|
||||
/* ================= collection ===================== */
|
||||
|
||||
/* ================= data ===================== */
|
||||
export type PgDataItemType = {
|
||||
id: string;
|
||||
q: string;
|
||||
a: string;
|
||||
dataset_id: string;
|
||||
collection_id: string;
|
||||
};
|
||||
export type DatasetChunkItemType = {
|
||||
q: string;
|
||||
a: string;
|
||||
};
|
||||
export type DatasetDataItemType = DatasetChunkItemType & {
|
||||
id: string;
|
||||
datasetId: string;
|
||||
collectionId: string;
|
||||
sourceName: string;
|
||||
sourceId?: string;
|
||||
};
|
||||
|
||||
/* ============= search =============== */
|
||||
export type SearchDataResultItemType = PgDataItemType & {
|
||||
score: number;
|
||||
};
|
||||
export type SearchDataResponseItemType = DatasetDataItemType & {
|
||||
score: number;
|
||||
};
|
21
packages/global/core/dataset/utils.ts
Normal file
21
packages/global/core/dataset/utils.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { DatasetCollectionTypeEnum } from './constant';
|
||||
import { getFileIcon } from '../../common/file/icon';
|
||||
|
||||
export function getCollectionIcon(
|
||||
type: `${DatasetCollectionTypeEnum}` = DatasetCollectionTypeEnum.file,
|
||||
name = ''
|
||||
) {
|
||||
if (type === DatasetCollectionTypeEnum.folder) {
|
||||
return '/imgs/files/folder.svg';
|
||||
} else if (type === DatasetCollectionTypeEnum.link) {
|
||||
return '/imgs/files/link.svg';
|
||||
} else if (type === DatasetCollectionTypeEnum.virtual) {
|
||||
if (name === '手动录入') {
|
||||
return '/imgs/files/manual.svg';
|
||||
} else if (name === '手动标注') {
|
||||
return '/imgs/files/mark.svg';
|
||||
}
|
||||
return '/imgs/files/collection.svg';
|
||||
}
|
||||
return getFileIcon(name);
|
||||
}
|
Reference in New Issue
Block a user