Skip to content

Commit

Permalink
Exponent withretry backoff
Browse files Browse the repository at this point in the history
  • Loading branch information
elie222 committed Dec 26, 2024
1 parent 8949337 commit 3c887cb
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 24 deletions.
2 changes: 1 addition & 1 deletion apps/web/utils/ai/choose-rule/ai-choose-args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ async function getArgsAiResponse({
{
retryIf: (error: unknown) => InvalidToolArgumentsError.isInstance(error),
maxRetries: 3,
delayMs: 1_000,
delayMs: 2_000,
},
);

Expand Down
3 changes: 2 additions & 1 deletion apps/web/utils/llms/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,8 @@ export async function withRetry<T>(
if (retryIf(error)) {
console.warn(`Attempt ${attempts}: Operation failed. Retrying...`);
if (attempts < maxRetries) {
await sleep(delayMs);
const backoffDelay = delayMs * 2 ** (attempts - 1);
await sleep(backoffDelay);
continue;
}
}
Expand Down
22 changes: 0 additions & 22 deletions apps/web/utils/retry.ts

This file was deleted.

1 comment on commit 3c887cb

@vercel
Copy link

@vercel vercel bot commented on 3c887cb Dec 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.