fix: using whitelist when disabling channels (close #292)

This commit is contained in:
JustSong
2023-07-22 18:15:30 +08:00
parent 12a0e7105e
commit 0495b9a0d7
3 changed files with 28 additions and 14 deletions

View File

@@ -91,3 +91,16 @@ func errorWrapper(err error, code string, statusCode int) *OpenAIErrorWithStatus
StatusCode: statusCode,
}
}
func shouldDisableChannel(err *OpenAIError) bool {
if !common.AutomaticDisableChannelEnabled {
return false
}
if err == nil {
return false
}
if err.Type == "insufficient_quota" || err.Code == "invalid_api_key" || err.Code == "account_deactivated" {
return true
}
return false
}