diff --git a/common/gin.go b/common/gin.go index b6ef96a6..33d6923c 100644 --- a/common/gin.go +++ b/common/gin.go @@ -3,9 +3,10 @@ package common import ( "bytes" "encoding/json" - "github.com/gin-gonic/gin" "io" "strings" + + "github.com/gin-gonic/gin" ) const KeyRequestBody = "key_request_body" diff --git a/controller/relay.go b/controller/relay.go index 14d0a0ab..98db0f98 100644 --- a/controller/relay.go +++ b/controller/relay.go @@ -5,7 +5,6 @@ import ( "context" "fmt" "net/http" - "strconv" "github.com/gin-gonic/gin" "github.com/songquanpeng/one-api/common" @@ -21,8 +20,6 @@ import ( "github.com/songquanpeng/one-api/relay/util" "io" - "net/http" - ) // https://platform.openai.com/docs/api-reference/chat @@ -122,6 +119,7 @@ func shouldRetry(c *gin.Context, statusCode int) bool { } func processChannelRelayError(ctx context.Context, channelId int, channelName string, err *model.ErrorWithStatusCode) { + logger.Errorf(ctx, "relay error (channel #%d): %s", channelId, err.Message) // https://platform.openai.com/docs/guides/error-codes/api-errors if util.ShouldDisableChannel(&err.Error, err.StatusCode) { diff --git a/middleware/distributor.go b/middleware/distributor.go index eebccae5..f57d3cfc 100644 --- a/middleware/distributor.go +++ b/middleware/distributor.go @@ -69,9 +69,9 @@ func Distribute() func(c *gin.Context) { } if strings.HasPrefix(modelRequest.Model, "gpt-4-gizmo") { - channel, err = model.CacheGetRandomSatisfiedChannel(userGroup, "gpt-4-gizmo") + channel, err = model.CacheGetRandomSatisfiedChannel(userGroup, "gpt-4-gizmo",false) } else { - channel, err = model.CacheGetRandomSatisfiedChannel(userGroup, modelRequest.Model) + channel, err = model.CacheGetRandomSatisfiedChannel(userGroup, modelRequest.Model,false) } if err != nil {