chore: 优化relay代码

This commit is contained in:
CalciumIon 2024-08-03 17:07:14 +08:00
parent 8a9ff36fbf
commit fbe6cd75b1

View File

@ -47,8 +47,14 @@ func Relay(c *gin.Context) {
for i := 0; i <= common.RetryTimes; i++ { for i := 0; i <= common.RetryTimes; i++ {
channel, err := getChannel(c, group, originalModel, i) channel, err := getChannel(c, group, originalModel, i)
if err != nil { if err != nil {
common.LogError(c, fmt.Sprintf("Failed to get channel: %s", err.Error())) errMsg := fmt.Sprintf("获取渠道出错: %s", err.Error())
break common.LogError(c, errMsg)
openaiErr = service.OpenAIErrorWrapperLocal(err, "get_channel_failed", http.StatusInternalServerError)
openaiErr.Error.Message = common.MessageWithRequestId(errMsg, requestId)
c.JSON(openaiErr.StatusCode, gin.H{
"error": openaiErr.Error,
})
return
} }
openaiErr = relayRequest(c, relayMode, channel) openaiErr = relayRequest(c, relayMode, channel)