Fix LLM reasoning mismatches by validating title and strengthening prompt
Add title validation in mood router to detect when the LLM returns reasoning for a different movie than the jellyfin_id it selected. Also add explicit prompt instruction to double-check reasoning matches the selected movie. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
22cec43b51
commit
0ca43f1d13
2 files changed
+10
No files matched your search
@@ -83,6 +83,15 @@ async def get_mood_recommendations(request: Request, body: MoodRequest):
|
||||
continue
|
||||
|
||||
movie = candidate_map[jf_id]
|
||||
|
||||
# Validate that the LLM's title matches the actual movie to catch mix-ups
|
||||
rec_title = rec.get("title", "").strip().lower()
|
||||
if rec_title and rec_title != movie.title.strip().lower():
|
||||
logger.warning(
|
||||
f"LLM title mismatch: returned '{rec.get('title')}' for jellyfin_id "
|
||||
f"'{jf_id}' which is actually '{movie.title}' — skipping"
|
||||
)
|
||||
continue
|
||||
recommendations.append(
|
||||
Recommendation(
|
||||
jellyfin_id=movie.jellyfin_id,
|
||||
|
||||
Reference in new issue
Block a user