Skip to content

Commit

Permalink
remove retry logic
Browse files Browse the repository at this point in the history
  • Loading branch information
liuliming committed Dec 24, 2024
1 parent 8018c32 commit 84243de
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 26 deletions.
48 changes: 23 additions & 25 deletions controller/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ import (
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"strings"

"github.com/gin-gonic/gin"
"github.com/songquanpeng/one-api/common"
"github.com/songquanpeng/one-api/common/config"
Expand All @@ -21,6 +17,8 @@ import (
"github.com/songquanpeng/one-api/relay/controller"
"github.com/songquanpeng/one-api/relay/model"
"github.com/songquanpeng/one-api/relay/relaymode"
"io"
"net/http"
)

// https://platform.openai.com/docs/api-reference/chat
Expand Down Expand Up @@ -132,27 +130,27 @@ func shouldRetry(c *gin.Context, bizError *model.ErrorWithStatusCode) bool {
if !bizError.IsChannelResponseError {
return false
}
if bizError.StatusCode == http.StatusTooManyRequests {
return true
}
if bizError.StatusCode/100 == 5 {
return true
}
if bizError.StatusCode == http.StatusBadRequest {
if strings.Contains(bizError.Message, "Azure OpenAI's content management policy") {
return true
}
if strings.Contains(bizError.Message, "Unsupported value: 'stream' does not support true with this model") {
return true
}
if strings.Contains(bizError.Message, "Missing required parameter: 'response_format.json_schema'") {
return true
}
return false
}
if bizError.StatusCode/100 == 2 {
return false
}
//if bizError.StatusCode == http.StatusTooManyRequests {
// return true
//}
//if bizError.StatusCode/100 == 5 {
// return true
//}
//if bizError.StatusCode == http.StatusBadRequest {
// if strings.Contains(bizError.Message, "Azure OpenAI's content management policy") {
// return true
// }
// if strings.Contains(bizError.Message, "Unsupported value: 'stream' does not support true with this model") {
// return true
// }
// if strings.Contains(bizError.Message, "Missing required parameter: 'response_format.json_schema'") {
// return true
// }
// return false
//}
//if bizError.StatusCode/100 == 2 {
// return false
//}
return true
}

Expand Down
3 changes: 2 additions & 1 deletion relay/adaptor/aws/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import (

func WrapErr(err error) *relaymodel.ErrorWithStatusCode {
return &relaymodel.ErrorWithStatusCode{
StatusCode: http.StatusInternalServerError,
IsChannelResponseError: true,
StatusCode: http.StatusInternalServerError,
Error: relaymodel.Error{
Message: err.Error(),
},
Expand Down

0 comments on commit 84243de

Please sign in to comment.