Files
FastGPT/packages/global/core/dataset/utils.ts
Archer e812ad6e84 feat: chunk index independent config (#4271)
* sync collection

* remove lock

* feat: chunk index independent config

* feat: add max chunksize to split chunk function

* remove log

* update doc

* remove

* remove log
2025-03-27 10:05:31 +08:00

45 lines
1.2 KiB
TypeScript

import { TrainingModeEnum, DatasetCollectionTypeEnum } from './constants';
import { getFileIcon } from '../../common/file/icon';
import { strIsLink } from '../../common/string/tools';
export function getCollectionIcon(
type: DatasetCollectionTypeEnum = DatasetCollectionTypeEnum.file,
name = ''
) {
if (type === DatasetCollectionTypeEnum.folder) {
return 'common/folderFill';
}
if (type === DatasetCollectionTypeEnum.link) {
return 'common/linkBlue';
}
if (type === DatasetCollectionTypeEnum.virtual) {
return 'file/fill/manual';
}
return getFileIcon(name);
}
export function getSourceNameIcon({
sourceName,
sourceId
}: {
sourceName: string;
sourceId?: string;
}) {
try {
const fileIcon = getFileIcon(decodeURIComponent(sourceName.replace(/%/g, '%25')), '');
if (fileIcon) {
return fileIcon;
}
if (strIsLink(sourceId)) {
return 'common/linkBlue';
}
} catch (error) {}
return 'file/fill/file';
}
export const predictDataLimitLength = (mode: TrainingModeEnum, data: any[]) => {
if (mode === TrainingModeEnum.qa) return data.length * 20;
if (mode === TrainingModeEnum.auto) return data.length * 5;
return data.length;
};