diff --git a/src/quota/tokenCount.ts b/src/quota/tokenCount.ts index 263ba13..47e9e99 100644 --- a/src/quota/tokenCount.ts +++ b/src/quota/tokenCount.ts @@ -51,12 +51,13 @@ export default class tokenCount implements IQuota { } }))._sum; - if (!usedTokens.usageRequest || !usedTokens.usageResponse) throw new Error("Null from a database!! (tokenCount Quota)"); + const usageRequest = usedTokens.usageRequest === null ? 0 : usedTokens.usageRequest; + const usageResponse = usedTokens.usageResponse === null ? 0 : usedTokens.usageResponse; const usedUnits = (() => { if (this.considerInputTokensAsHalf) - return usedTokens.usageResponse + usedTokens.usageRequest / 2; - return usedTokens.usageResponse + usedTokens.usageRequest; + return usageResponse + usageRequest / 2; + return usageResponse + usageRequest; })(); if (userQuota?.vip) return this.createUserQuotaData(Infinity, usedUnits);