|
|
@@ -42,7 +42,7 @@ func EnableChannel(channelId int, usingKey string, channelName string) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-func ShouldDisableChannel(channelType int, err *types.NewAPIError) bool {
|
|
|
+func ShouldDisableChannel(err *types.NewAPIError) bool {
|
|
|
if !common.AutomaticDisableChannelEnabled {
|
|
|
return false
|
|
|
}
|
|
|
@@ -58,41 +58,6 @@ func ShouldDisableChannel(channelType int, err *types.NewAPIError) bool {
|
|
|
if operation_setting.ShouldDisableByStatusCode(err.StatusCode) {
|
|
|
return true
|
|
|
}
|
|
|
- //if err.StatusCode == http.StatusUnauthorized {
|
|
|
- // return true
|
|
|
- //}
|
|
|
- //if err.StatusCode == http.StatusForbidden {
|
|
|
- // switch channelType {
|
|
|
- // case constant.ChannelTypeGemini:
|
|
|
- // return true
|
|
|
- // }
|
|
|
- //}
|
|
|
- oaiErr := err.ToOpenAIError()
|
|
|
- switch oaiErr.Code {
|
|
|
- case "invalid_api_key":
|
|
|
- return true
|
|
|
- case "account_deactivated":
|
|
|
- return true
|
|
|
- case "billing_not_active":
|
|
|
- return true
|
|
|
- case "pre_consume_token_quota_failed":
|
|
|
- return true
|
|
|
- case "Arrearage":
|
|
|
- return true
|
|
|
- }
|
|
|
- switch oaiErr.Type {
|
|
|
- case "insufficient_quota":
|
|
|
- return true
|
|
|
- case "insufficient_user_quota":
|
|
|
- return true
|
|
|
- // https://docs.anthropic.com/claude/reference/errors
|
|
|
- case "authentication_error":
|
|
|
- return true
|
|
|
- case "permission_error":
|
|
|
- return true
|
|
|
- case "forbidden":
|
|
|
- return true
|
|
|
- }
|
|
|
|
|
|
lowerMessage := strings.ToLower(err.Error())
|
|
|
search, _ := AcSearch(lowerMessage, operation_setting.AutomaticDisableKeywords, true)
|