Skip to content

Commit

Permalink
fix: image
Browse files Browse the repository at this point in the history
  • Loading branch information
deanxv committed Jul 10, 2024
1 parent dbfd0bd commit c01393c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
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.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"
Expand Down
22 changes: 22 additions & 0 deletions discord/processmessage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit c01393c

Please sign in to comment.