Skip to content

Commit

Permalink
fix: handle rate_limit_exceeded in openai assistants (#210)
Browse files Browse the repository at this point in the history
Co-authored-by: Saikat Mitra <saikatmitra91@gmail.com>
  • Loading branch information
arjunattam and saikatmitra91 authored May 6, 2024
1 parent 973c9b2 commit 0b2d1c0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/wild-owls-agree.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@empiricalrun/ai": patch
---

fix: handle rate_limit_exceeded in openai assistants
6 changes: 5 additions & 1 deletion packages/ai/src/providers/openai/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,11 @@ const runAssistant: ICreateAndRunAssistantThread = async (body) => {
}
return asstRunResp;
})().catch((err: any) => {
if ((err.message as string).includes("server_error")) {
const serverError = (err.message as string).includes("server_error");
const rateLimitError = (err.message as string).includes(
"rate_limit_exceeded",
);
if (serverError || rateLimitError) {
console.warn(
`Retrying request due to server error (attempt ${attempt})`,
);
Expand Down

0 comments on commit 0b2d1c0

Please sign in to comment.