mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-22 20:37:48 +00:00
24 lines
732 B
TypeScript
24 lines
732 B
TypeScript
import { StandSubPlanLevelMapType } from '@fastgpt/global/support/wallet/sub/type';
|
|
import { getVectorCountByTeamId } from '../../../common/vectorStore/controller';
|
|
import { getTeamDatasetMaxSize } from '../../wallet/sub/utils';
|
|
|
|
export const checkDatasetLimit = async ({
|
|
teamId,
|
|
insertLen = 0,
|
|
standardPlans
|
|
}: {
|
|
teamId: string;
|
|
insertLen?: number;
|
|
standardPlans?: StandSubPlanLevelMapType;
|
|
}) => {
|
|
const [{ maxSize }, usedSize] = await Promise.all([
|
|
getTeamDatasetMaxSize({ teamId, standardPlans }),
|
|
getVectorCountByTeamId(teamId)
|
|
]);
|
|
|
|
if (usedSize + insertLen >= maxSize) {
|
|
return Promise.reject(`数据库容量不足,无法继续添加。可以在账号页面进行扩容。`);
|
|
}
|
|
return;
|
|
};
|