fix: auto ban
Some checks failed
Publish Docker image (Multi Registries) / Push Docker image to multiple registries (push) Has been cancelled
Some checks failed
Publish Docker image (Multi Registries) / Push Docker image to multiple registries (push) Has been cancelled
This commit is contained in:
parent
a1caf37f5b
commit
efb7c6a15e
@ -209,7 +209,7 @@ func testChannel(channel *model.Channel, testModel string) testResult {
|
|||||||
return testResult{
|
return testResult{
|
||||||
context: c,
|
context: c,
|
||||||
localErr: err,
|
localErr: err,
|
||||||
newAPIError: types.NewError(err, types.ErrorCodeDoRequestFailed),
|
newAPIError: types.NewOpenAIError(err, types.ErrorCodeDoRequestFailed, http.StatusInternalServerError),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var httpResp *http.Response
|
var httpResp *http.Response
|
||||||
@ -220,7 +220,7 @@ func testChannel(channel *model.Channel, testModel string) testResult {
|
|||||||
return testResult{
|
return testResult{
|
||||||
context: c,
|
context: c,
|
||||||
localErr: err,
|
localErr: err,
|
||||||
newAPIError: types.NewError(err, types.ErrorCodeBadResponse),
|
newAPIError: types.NewOpenAIError(err, types.ErrorCodeBadResponse, http.StatusInternalServerError),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -236,7 +236,7 @@ func testChannel(channel *model.Channel, testModel string) testResult {
|
|||||||
return testResult{
|
return testResult{
|
||||||
context: c,
|
context: c,
|
||||||
localErr: errors.New("usage is nil"),
|
localErr: errors.New("usage is nil"),
|
||||||
newAPIError: types.NewError(errors.New("usage is nil"), types.ErrorCodeBadResponseBody),
|
newAPIError: types.NewOpenAIError(errors.New("usage is nil"), types.ErrorCodeBadResponseBody, http.StatusInternalServerError),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
usage := usageA.(*dto.Usage)
|
usage := usageA.(*dto.Usage)
|
||||||
@ -246,7 +246,7 @@ func testChannel(channel *model.Channel, testModel string) testResult {
|
|||||||
return testResult{
|
return testResult{
|
||||||
context: c,
|
context: c,
|
||||||
localErr: err,
|
localErr: err,
|
||||||
newAPIError: types.NewError(err, types.ErrorCodeReadResponseBodyFailed),
|
newAPIError: types.NewOpenAIError(err, types.ErrorCodeReadResponseBodyFailed, http.StatusInternalServerError),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
info.PromptTokens = usage.PromptTokens
|
info.PromptTokens = usage.PromptTokens
|
||||||
@ -417,7 +417,7 @@ func testAllChannels(notify bool) error {
|
|||||||
if common.AutomaticDisableChannelEnabled && !shouldBanChannel {
|
if common.AutomaticDisableChannelEnabled && !shouldBanChannel {
|
||||||
if milliseconds > disableThreshold {
|
if milliseconds > disableThreshold {
|
||||||
err := errors.New(fmt.Sprintf("响应时间 %.2fs 超过阈值 %.2fs", float64(milliseconds)/1000.0, float64(disableThreshold)/1000.0))
|
err := errors.New(fmt.Sprintf("响应时间 %.2fs 超过阈值 %.2fs", float64(milliseconds)/1000.0, float64(disableThreshold)/1000.0))
|
||||||
newAPIError = types.NewError(err, types.ErrorCodeChannelResponseTimeExceeded)
|
newAPIError = types.NewOpenAIError(err, types.ErrorCodeChannelResponseTimeExceeded, http.StatusRequestTimeout)
|
||||||
shouldBanChannel = true
|
shouldBanChannel = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
package service
|
package service
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
@ -112,7 +111,7 @@ func ResetStatusCode(newApiErr *types.NewAPIError, statusCodeMappingStr string)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
statusCodeMapping := make(map[string]string)
|
statusCodeMapping := make(map[string]string)
|
||||||
err := json.Unmarshal([]byte(statusCodeMappingStr), &statusCodeMapping)
|
err := common.Unmarshal([]byte(statusCodeMappingStr), &statusCodeMapping)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user