diff --git a/common/constants.go b/common/constants.go index 20773a9b..6cf7851a 100644 --- a/common/constants.go +++ b/common/constants.go @@ -1,6 +1,6 @@ package common -var Version = "v4.5.9" // this hard coding will be replaced automatically when building, no need to manually change +var Version = "v4.5.10" // this hard coding will be replaced automatically when building, no need to manually change const ( RequestIdKey = "X-Request-Id" diff --git a/discord/processmessage.go b/discord/processmessage.go index 577615e5..be77d50f 100644 --- a/discord/processmessage.go +++ b/discord/processmessage.go @@ -38,6 +38,17 @@ func processMessageUpdateForOpenAI(m *discordgo.MessageUpdate) model.OpenAIChatC } } + if len(m.Attachments) != 0 { + for _, attachment := range m.Attachments { + if attachment.ProxyURL != "" && !strings.Contains(m.Content, attachment.ProxyURL) { + if m.Content != "" { + m.Content += "\n" + } + m.Content += fmt.Sprintf("%s\n![Image](%s)", attachment.ProxyURL, attachment.ProxyURL) + } + } + } + promptTokens := common.CountTokens(m.ReferencedMessage.Content) completionTokens := common.CountTokens(m.Content) @@ -158,6 +169,17 @@ func processMessageCreateForOpenAI(m *discordgo.MessageCreate) model.OpenAIChatC } } + if len(m.Attachments) != 0 { + for _, attachment := range m.Attachments { + if attachment.ProxyURL != "" && !strings.Contains(m.Content, attachment.ProxyURL) { + if m.Content != "" { + m.Content += "\n" + } + m.Content += fmt.Sprintf("%s\n![Image](%s)", attachment.ProxyURL, attachment.ProxyURL) + } + } + } + promptTokens := common.CountTokens(m.ReferencedMessage.Content) completionTokens := common.CountTokens(m.Content)