fix: retry model capacity transient errors

This commit is contained in:
weak-fox 2026-05-15 10:43:29 +08:00
parent ed7ef86347
commit 9f07741c13

View File

@ -1113,6 +1113,9 @@ func isOpenAITransientProcessingError(upstreamStatusCode int, upstreamMsg string
if strings.Contains(lower, "an error occurred while processing your request") {
return true
}
if strings.Contains(lower, "selected model is at capacity") {
return true
}
return strings.Contains(lower, "you can retry your request") &&
strings.Contains(lower, "help.openai.com") &&
strings.Contains(lower, "request id")
@ -3400,6 +3403,9 @@ func openAIStreamDataStartsClientOutput(data, eventType string) bool {
}
func openAIStreamFailedEventShouldFailover(payload []byte, message string) bool {
if isOpenAITransientProcessingError(http.StatusBadRequest, message, payload) {
return true
}
code := strings.ToLower(strings.TrimSpace(gjson.GetBytes(payload, "response.error.code").String()))
if code == "" {
code = strings.ToLower(strings.TrimSpace(gjson.GetBytes(payload, "error.code").String()))