Skip to content

Commit c01393c

Browse files
committed
fix: image
1 parent dbfd0bd commit c01393c

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

common/constants.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package common
22

3-
var Version = "v4.5.9" // this hard coding will be replaced automatically when building, no need to manually change
3+
var Version = "v4.5.10" // this hard coding will be replaced automatically when building, no need to manually change
44

55
const (
66
RequestIdKey = "X-Request-Id"

discord/processmessage.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,17 @@ func processMessageUpdateForOpenAI(m *discordgo.MessageUpdate) model.OpenAIChatC
3838
}
3939
}
4040

41+
if len(m.Attachments) != 0 {
42+
for _, attachment := range m.Attachments {
43+
if attachment.ProxyURL != "" && !strings.Contains(m.Content, attachment.ProxyURL) {
44+
if m.Content != "" {
45+
m.Content += "\n"
46+
}
47+
m.Content += fmt.Sprintf("%s\n![Image](%s)", attachment.ProxyURL, attachment.ProxyURL)
48+
}
49+
}
50+
}
51+
4152
promptTokens := common.CountTokens(m.ReferencedMessage.Content)
4253
completionTokens := common.CountTokens(m.Content)
4354

@@ -158,6 +169,17 @@ func processMessageCreateForOpenAI(m *discordgo.MessageCreate) model.OpenAIChatC
158169
}
159170
}
160171

172+
if len(m.Attachments) != 0 {
173+
for _, attachment := range m.Attachments {
174+
if attachment.ProxyURL != "" && !strings.Contains(m.Content, attachment.ProxyURL) {
175+
if m.Content != "" {
176+
m.Content += "\n"
177+
}
178+
m.Content += fmt.Sprintf("%s\n![Image](%s)", attachment.ProxyURL, attachment.ProxyURL)
179+
}
180+
}
181+
}
182+
161183
promptTokens := common.CountTokens(m.ReferencedMessage.Content)
162184
completionTokens := common.CountTokens(m.Content)
163185

0 commit comments

Comments
 (0)