fixes dead keys being 'revived' by a queued check

This commit is contained in:
nai-degen
2023-04-10 19:57:32 -07:00
committed by nai-degen
parent 885487a61d
commit f3a13129f9
+17
View File
@@ -97,6 +97,14 @@ export class KeyChecker {
}
private async checkKey(key: Key) {
// It's possible this key might have been disabled while we were waiting
// for the next check.
if (key.isDisabled) {
this.log.warn({ key: key.hash }, "Skipping check for disabled key.");
this.scheduleNextCheck();
return;
}
this.log.info({ key: key.hash }, "Checking key...");
try {
// During the initial check we need to get the subscription first because
@@ -196,6 +204,15 @@ export class KeyChecker {
}
}
// TODO: Trial key usage reporting is very unreliable and keys with supposedly
// no usage are already exhausted. Instead we should try generating some text
// on the first check to quickly determine if the key is alive.
private async doTestGeneration(key: Key) {
// Generate only a single token with a very short prompt to avoid using
// too much of the key's quota.
// NYI
}
static getUsageQuerystring(isTrial: boolean) {
// For paid keys, the limit resets every month, so we can use the current
// month as the start date.