Open source AI coding agent. Designed for large projects and real world tasks.
Go aiai-agentsai-developer-toolsai-toolsclicommand-linedeveloper-toolsgitgolanggpt-4llmopenaipolyglot-programmingterminalterminal-basedterminal-ui
cap OpenAI rate limit wait to 30s
Dane Schneider6075c65c08c2
diff --git a/app/server/model/client.go b/app/server/model/client.goindex 04819faf..e175eb1f 100644--- a/app/server/model/client.go+++ b/app/server/model/client.go@@ -72,6 +72,11 @@ func createChatCompletionStream(if numRetry < 5 {// check if the error message contains a retry durationif duration := parseRetryAfter(err.Error()); duration != nil {+ // ensure wait duration is less than 20 seconds+ if *duration > 20*time.Second {+ return nil, err+ }+log.Printf("Retry duration found: %v\n", *duration)// wait for the duration times 1.5 to give some bufferwaitDuration := time.Duration(float64(*duration) * 1.5)@@ -123,8 +128,15 @@ func createChatCompletion(// check if the error message contains a retry durationif duration := parseRetryAfter(err.Error()); duration != nil {log.Printf("Retry duration found: %v\n", *duration)++ // ensure wait duration is less than 20 seconds+ if *duration > 20*time.Second {+ return openai.ChatCompletionResponse{}, err+ }+// wait for the duration times 1.5 to give some bufferwaitDuration := time.Duration(float64(*duration) * 1.5)+time.Sleep(waitDuration)return createChatCompletion(client, ctx, req, numRetry+1)}