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

@@ -171,7 +171,7 @@ func Relay(c *gin.Context) {
channelId := c.GetInt("channel_id")
common.SysError(fmt.Sprintf("relay error (channel #%d): %s", channelId, err.Message))
// https://platform.openai.com/docs/guides/error-codes/api-errors
if common.AutomaticDisableChannelEnabled && (err.Type == "insufficient_quota" || err.Code == "invalid_api_key" || err.Code == "account_deactivated") {
if shouldDisableChannel(&err.OpenAIError) {
channelId := c.GetInt("channel_id")
channelName := c.GetString("channel_name")
disableChannel(channelId, channelName, err.Message)