Skip to content

Commit

Permalink
Do not retry if OpenAI returns a 429 error. (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
blrchen committed Sep 15, 2023
1 parent 01291ac commit ca349ab
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 80 deletions.
2 changes: 1 addition & 1 deletion app/v1/chat/completions/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export async function POST(request: NextRequest) {
while (true) {
let response = await chat(apiKey, body)
const status = response.status
if (status < 300 || status === 400) {
if (status < 300 || (status >= 400 && status < 500)) {
return response
}
if (retryCount >= MAX_RETRY_COUNT) {
Expand Down
146 changes: 71 additions & 75 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
"format": "prettier --write '**/*.{ts,tsx,js,html,css,md}'"
},
"dependencies": {
"@types/node": "20.4.4",
"@types/react": "18.2.15",
"@types/node": "20.6.1",
"@types/react": "18.2.21",
"@types/react-dom": "18.2.7",
"next": "13.4.12",
"next": "13.4.19",
"prettier": "^3.0.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"typescript": "5.1.6"
"typescript": "5.2.2"
}
}

0 comments on commit ca349ab

Please sign in to comment.