Remove budget saver mode (#378)
This code was quite complex and hairy and resulted in very opaque errors (for both free and pro users). There's not much benefit to budget saver because Google removed 2.5 Pro free quota a while ago (after it graduated the model from experimental to preview). Dyad Pro users can still use 2.5 Flash free quota by disabling Dyad Pro by clicking on the Dyad Pro button at the top.
This commit is contained in:
@@ -1,35 +0,0 @@
|
||||
class LlmErrorStore {
|
||||
private modelErrorToTimestamp: Record<string, number> = {};
|
||||
|
||||
constructor() {}
|
||||
|
||||
recordModelError({ model, provider }: { model: string; provider: string }) {
|
||||
this.modelErrorToTimestamp[this.getKey({ model, provider })] = Date.now();
|
||||
}
|
||||
|
||||
clearModelError({ model, provider }: { model: string; provider: string }) {
|
||||
delete this.modelErrorToTimestamp[this.getKey({ model, provider })];
|
||||
}
|
||||
|
||||
modelHasNoRecentError({
|
||||
model,
|
||||
provider,
|
||||
}: {
|
||||
model: string;
|
||||
provider: string;
|
||||
}): boolean {
|
||||
const key = this.getKey({ model, provider });
|
||||
const timestamp = this.modelErrorToTimestamp[key];
|
||||
if (!timestamp) {
|
||||
return true;
|
||||
}
|
||||
const oneHourAgo = Date.now() - 1000 * 60 * 60;
|
||||
return timestamp < oneHourAgo;
|
||||
}
|
||||
|
||||
private getKey({ model, provider }: { model: string; provider: string }) {
|
||||
return `${provider}::${model}`;
|
||||
}
|
||||
}
|
||||
|
||||
export const llmErrorStore = new LlmErrorStore();
|
||||
Reference in New Issue
Block a user