quota/tokenCount: fix "null from a database"
This commit is contained in:
parent
2629659ffc
commit
94992743e8
1 changed files with 4 additions and 3 deletions
|
@ -51,12 +51,13 @@ export default class tokenCount implements IQuota {
|
||||||
}
|
}
|
||||||
}))._sum;
|
}))._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 = (() => {
|
const usedUnits = (() => {
|
||||||
if (this.considerInputTokensAsHalf)
|
if (this.considerInputTokensAsHalf)
|
||||||
return usedTokens.usageResponse + usedTokens.usageRequest / 2;
|
return usageResponse + usageRequest / 2;
|
||||||
return usedTokens.usageResponse + usedTokens.usageRequest;
|
return usageResponse + usageRequest;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
if (userQuota?.vip) return this.createUserQuotaData(Infinity, usedUnits);
|
if (userQuota?.vip) return this.createUserQuotaData(Infinity, usedUnits);
|
||||||
|
|
Loading…
Reference in a new issue