buildPrompt formats the user messages into the system+user message pair sent to the model.
(userMessages []string)
| 188 | // buildPrompt formats the user messages into the system+user message pair |
| 189 | // sent to the model. |
| 190 | func buildPrompt(userMessages []string) []chat.Message { |
| 191 | var formatted strings.Builder |
| 192 | for i, msg := range userMessages { |
| 193 | fmt.Fprintf(&formatted, "%d. %s\n", i+1, msg) |
| 194 | } |
| 195 | return []chat.Message{ |
| 196 | {Role: chat.MessageRoleSystem, Content: systemPrompt}, |
| 197 | {Role: chat.MessageRoleUser, Content: fmt.Sprintf(userPromptFormat, formatted.String())}, |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | // sanitizeTitle returns the first non-empty trimmed line of title, with any |
| 202 | // stray carriage returns removed. This guarantees a single-line title safe |