mirror of
https://github.com/labring/FastGPT.git
synced 2025-10-15 23:55:36 +00:00
4.6.7 first pr (#726)
This commit is contained in:
20
packages/service/support/permission/limit/dataset.ts
Normal file
20
packages/service/support/permission/limit/dataset.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
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;
|
||||
};
|
Reference in New Issue
Block a user