@@ -86,9 +86,10 @@ func (m *Model) Prompt(p PromptVars) (string, error) {
86
86
return prompt .String (), nil
87
87
}
88
88
89
- func (m * Model ) ChatPrompt (msgs []api.Message ) (string , error ) {
89
+ func (m * Model ) ChatPrompt (msgs []api.Message ) (string , []api. ImageData , error ) {
90
90
// build the prompt from the list of messages
91
91
var prompt strings.Builder
92
+ var currentImages []api.ImageData
92
93
currentVars := PromptVars {
93
94
First : true ,
94
95
}
@@ -108,35 +109,36 @@ func (m *Model) ChatPrompt(msgs []api.Message) (string, error) {
108
109
case "system" :
109
110
if currentVars .System != "" {
110
111
if err := writePrompt (); err != nil {
111
- return "" , err
112
+ return "" , nil , err
112
113
}
113
114
}
114
115
currentVars .System = msg .Content
115
116
case "user" :
116
117
if currentVars .Prompt != "" {
117
118
if err := writePrompt (); err != nil {
118
- return "" , err
119
+ return "" , nil , err
119
120
}
120
121
}
121
122
currentVars .Prompt = msg .Content
123
+ currentImages = msg .Images
122
124
case "assistant" :
123
125
currentVars .Response = msg .Content
124
126
if err := writePrompt (); err != nil {
125
- return "" , err
127
+ return "" , nil , err
126
128
}
127
129
default :
128
- return "" , fmt .Errorf ("invalid role: %s, role must be one of [system, user, assistant]" , msg .Role )
130
+ return "" , nil , fmt .Errorf ("invalid role: %s, role must be one of [system, user, assistant]" , msg .Role )
129
131
}
130
132
}
131
133
132
134
// Append the last set of vars if they are non-empty
133
135
if currentVars .Prompt != "" || currentVars .System != "" {
134
136
if err := writePrompt (); err != nil {
135
- return "" , err
137
+ return "" , nil , err
136
138
}
137
139
}
138
140
139
- return prompt .String (), nil
141
+ return prompt .String (), currentImages , nil
140
142
}
141
143
142
144
type ManifestV2 struct {
0 commit comments