trigger endpoint and retry suggestions

This commit is contained in:
2026-04-25 15:21:09 +02:00
parent 20ebe5a49f
commit 846083e230
6 changed files with 103 additions and 37 deletions

View File

@@ -119,12 +119,14 @@ func parseMovieSuggestions(content string) ([]model.MovieSuggestion, error) {
}
// BuildPrompt constructs the recommendation prompt sent to the LLM.
func BuildPrompt(favorites, watched, library []model.Movie, count int) string {
// previouslySuggested contains movies returned in prior retry attempts that must not be repeated.
func BuildPrompt(favorites, watched, library, previouslySuggested []model.Movie, count int) string {
var sb strings.Builder
sb.WriteString(fmt.Sprintf(
"You are a movie recommendation engine. Based on the user's favorite and recently watched movies below, suggest exactly %d movies they would enjoy.\n\n"+
"IMPORTANT:\n"+
"- Do NOT suggest any movie from the \"Already In Library\" list.\n"+
"- Do NOT suggest any movie from the \"Already Suggested\" list.\n"+
"- Return ONLY a JSON array, no other text.\n"+
"- Each entry: {\"title\": \"Movie Title\", \"year\": 2024, \"reason\": \"brief reason\"}\n\n"+
"User's favorite movies:\n", count))
@@ -150,5 +152,13 @@ func BuildPrompt(favorites, watched, library []model.Movie, count int) string {
for _, m := range library {
sb.WriteString(fmt.Sprintf("- %s (%d)\n", m.Name, m.Year))
}
if len(previouslySuggested) > 0 {
sb.WriteString("\nAlready suggested (DO NOT repeat these):\n")
for _, m := range previouslySuggested {
sb.WriteString(fmt.Sprintf("- %s (%d)\n", m.Name, m.Year))
}
}
return sb.String()
}