Skip to content

Commit ca349ab

Browse files
authored
Do not retry if OpenAI returns a 429 error. (#26)
1 parent 01291ac commit ca349ab

File tree

3 files changed

+76
-80
lines changed

3 files changed

+76
-80
lines changed

app/v1/chat/completions/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export async function POST(request: NextRequest) {
1515
while (true) {
1616
let response = await chat(apiKey, body)
1717
const status = response.status
18-
if (status < 300 || status === 400) {
18+
if (status < 300 || (status >= 400 && status < 500)) {
1919
return response
2020
}
2121
if (retryCount >= MAX_RETRY_COUNT) {

package-lock.json

Lines changed: 71 additions & 75 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
"format": "prettier --write '**/*.{ts,tsx,js,html,css,md}'"
1111
},
1212
"dependencies": {
13-
"@types/node": "20.4.4",
14-
"@types/react": "18.2.15",
13+
"@types/node": "20.6.1",
14+
"@types/react": "18.2.21",
1515
"@types/react-dom": "18.2.7",
16-
"next": "13.4.12",
16+
"next": "13.4.19",
1717
"prettier": "^3.0.0",
1818
"react": "18.2.0",
1919
"react-dom": "18.2.0",
20-
"typescript": "5.1.6"
20+
"typescript": "5.2.2"
2121
}
2222
}

0 commit comments

Comments
 (0)