prepend image tags (#2789)

instead of appending image tags, prepend them - this generally produces better results
This commit is contained in:
Michael Yang
2024-02-29 11:30:14 -08:00
committed by GitHub
parent fa2f2b3563
commit 0e19476b56
3 changed files with 21 additions and 18 deletions

View File

@@ -121,13 +121,15 @@ func ChatPrompt(tmpl string, messages []api.Message, window int, encode func(str
p = prompt{}
}
p.Prompt = msg.Content
var sb strings.Builder
for range msg.Images {
p.Prompt += fmt.Sprintf(" [img-%d]", imgId)
fmt.Fprintf(&sb, "[img-%d] ", imgId)
p.images = append(p.images, imgId)
imgId += 1
}
sb.WriteString(msg.Content)
p.Prompt = sb.String()
case "assistant":
if p.Response != "" {
prompts = append(prompts, p)