Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
deanxv committed Jul 4, 2024
1 parent ec716f5 commit dbfd0bd
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 33 deletions.
2 changes: 1 addition & 1 deletion common/constants.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package common

var Version = "v4.5.8" // this hard coding will be replaced automatically when building, no need to manually change
var Version = "v4.5.9" // this hard coding will be replaced automatically when building, no need to manually change

const (
RequestIdKey = "X-Request-Id"
Expand Down
66 changes: 34 additions & 32 deletions controller/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -580,40 +580,42 @@ func ImagesForOpenAI(c *gin.Context) {
for {
select {
case reply := <-replyChan:
if common.SliceContains(common.CozeErrorMessages, reply.Data[0].RevisedPrompt) {
if common.SliceContains(common.CozeUserDailyLimitErrorMessages, reply.Data[0].RevisedPrompt) {
common.LogWarn(c, fmt.Sprintf("USER_AUTHORIZATION:%s DAILY LIMIT", userAuth))
discord.UserAuthorizations = common.FilterSlice(discord.UserAuthorizations, userAuth)
}
if common.SliceContains(common.CozeCreatorDailyLimitErrorMessages, reply.Data[0].RevisedPrompt) {
common.LogWarn(c, fmt.Sprintf("BOT_ID:%s DAILY LIMIT", calledCozeBotId))
//discord.BotConfigList = discord.FilterBotConfigByBotId(discord.BotConfigList, calledCozeBotId)
discord.DelLimitBot(calledCozeBotId)
if len(reply.Data) > 0 {
if common.SliceContains(common.CozeErrorMessages, reply.Data[0].RevisedPrompt) {
if common.SliceContains(common.CozeUserDailyLimitErrorMessages, reply.Data[0].RevisedPrompt) {
common.LogWarn(c, fmt.Sprintf("USER_AUTHORIZATION:%s DAILY LIMIT", userAuth))
discord.UserAuthorizations = common.FilterSlice(discord.UserAuthorizations, userAuth)
}
if common.SliceContains(common.CozeCreatorDailyLimitErrorMessages, reply.Data[0].RevisedPrompt) {
common.LogWarn(c, fmt.Sprintf("BOT_ID:%s DAILY LIMIT", calledCozeBotId))
//discord.BotConfigList = discord.FilterBotConfigByBotId(discord.BotConfigList, calledCozeBotId)
discord.DelLimitBot(calledCozeBotId)
}
c.JSON(http.StatusInternalServerError, model.OpenAIErrorResponse{
OpenAIError: model.OpenAIError{
Message: reply.Data[0].RevisedPrompt,
Type: "request_error",
Code: "500",
},
})
return
}
c.JSON(http.StatusInternalServerError, model.OpenAIErrorResponse{
OpenAIError: model.OpenAIError{
Message: reply.Data[0].RevisedPrompt,
Type: "request_error",
Code: "500",
},
})
return
}
if request.ResponseFormat == "b64_json" && reply.Data != nil && len(reply.Data) > 0 {
for _, data := range reply.Data {
if data.URL != "" {
base64Str, err := getBase64ByUrl(data.URL)
if err != nil {
c.JSON(http.StatusInternalServerError, model.OpenAIErrorResponse{
OpenAIError: model.OpenAIError{
Message: err.Error(),
Type: "request_error",
Code: "500",
},
})
return
if request.ResponseFormat == "b64_json" && reply.Data != nil && len(reply.Data) > 0 {
for _, data := range reply.Data {
if data.URL != "" {
base64Str, err := getBase64ByUrl(data.URL)
if err != nil {
c.JSON(http.StatusInternalServerError, model.OpenAIErrorResponse{
OpenAIError: model.OpenAIError{
Message: err.Error(),
Type: "request_error",
Code: "500",
},
})
return
}
data.B64Json = "data:image/webp;base64," + base64Str
}
data.B64Json = "data:image/webp;base64," + base64Str
}
}
}
Expand Down

0 comments on commit dbfd0bd

Please sign in to comment.