quota/tokenCount: fix "null from a database"

This commit is contained in:
Wroclaw 2023-09-21 21:51:03 +02:00
parent 2629659ffc
commit 94992743e8

View file

@ -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);