Files
FastGPT/packages/service/support/permission/limit/dataset.ts
Archer c031e6dcc9 4.6.7-alpha commit (#743)
Co-authored-by: Archer <545436317@qq.com>
Co-authored-by: heheer <71265218+newfish-cmyk@users.noreply.github.com>
2024-01-19 11:17:28 +08:00

21 lines
614 B
TypeScript

import { getVectorCountByTeamId } from '../../../common/vectorStore/controller';
import { getTeamDatasetValidSub } from '../../wallet/sub/utils';
export const checkDatasetLimit = async ({
teamId,
freeSize = Infinity,
insertLen = 0
}: {
teamId: string;
freeSize?: number;
insertLen?: number;
}) => {
const { maxSize } = await getTeamDatasetValidSub({ teamId, freeSize });
const usedSize = await getVectorCountByTeamId(teamId);
if (usedSize + insertLen >= maxSize) {
return Promise.reject(`数据库容量不足,无法继续添加。可以在账号页面进行扩容。`);
}
return;
};