mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-12-28 02:35:56 +08:00
Merge commit '3d149fedf45472eff92910324974c762fc37dad6'
This commit is contained in:
@@ -48,15 +48,15 @@ func Relay(c *gin.Context) {
|
||||
requestBody, _ := common.GetRequestBody(c)
|
||||
logger.Debugf(ctx, "request body: %s", string(requestBody))
|
||||
}
|
||||
channelId := c.GetInt("channel_id")
|
||||
channelId := c.GetInt(ctxkey.ChannelId)
|
||||
bizErr := relayHelper(c, relayMode)
|
||||
if bizErr == nil {
|
||||
monitor.Emit(channelId, true)
|
||||
return
|
||||
}
|
||||
lastFailedChannelId := channelId
|
||||
channelName := c.GetString("channel_name")
|
||||
group := c.GetString("group")
|
||||
channelName := c.GetString(ctxkey.ChannelName)
|
||||
group := c.GetString(ctxkey.Group)
|
||||
originalModel := c.GetString(ctxkey.OriginalModel)
|
||||
go processChannelRelayError(ctx, channelId, channelName, bizErr)
|
||||
requestId := c.GetString(logger.RequestIdKey)
|
||||
@@ -82,9 +82,9 @@ func Relay(c *gin.Context) {
|
||||
if bizErr == nil {
|
||||
return
|
||||
}
|
||||
channelId := c.GetInt("channel_id")
|
||||
channelId := c.GetInt(ctxkey.ChannelId)
|
||||
lastFailedChannelId = channelId
|
||||
channelName := c.GetString("channel_name")
|
||||
channelName := c.GetString(ctxkey.ChannelName)
|
||||
go processChannelRelayError(ctx, channelId, channelName, bizErr)
|
||||
}
|
||||
if bizErr != nil {
|
||||
@@ -100,14 +100,14 @@ func Relay(c *gin.Context) {
|
||||
|
||||
// shouldRetry returns nil if should retry, otherwise returns error
|
||||
func shouldRetry(c *gin.Context, statusCode int) error {
|
||||
if v, ok := c.Get("specific_channel_id"); ok {
|
||||
if v, ok := c.Get(ctxkey.SpecificChannelId); ok {
|
||||
return errors.Errorf("specific channel = %v", v)
|
||||
}
|
||||
|
||||
if statusCode == http.StatusBadRequest {
|
||||
if statusCode == http.StatusTooManyRequests {
|
||||
return errors.Errorf("status code = %d", statusCode)
|
||||
}
|
||||
if statusCode/100 == 2 {
|
||||
if statusCode/100 == 5 {
|
||||
return errors.Errorf("status code = %d", statusCode)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user