mirror of
https://github.com/FJurmanovic/sugarr.git
synced 2026-11-11 15:51:09 +00:00
Fix final review findings: key leak, model fallback, error resilience, docs
- ApiClient: strip query string from ApiError messages so API keys (e.g. TMDb's api_key query param) never leak into 500 response bodies or logs. - LlmTool: accept an optional defaultModel, wired from AppConfig's LLM_MODEL, so Langfuse prompts that omit a model config fall back to the configured LLM rather than silently requesting gpt-4o-mini. - RecommendationPipeline: restore the Go original's graceful degradation — library/Radarr fetch failures, per-suggestion TMDb resolution failures, and per-signal TMDb similarity/recommendation failures are now logged and skipped instead of aborting the whole run (applies to both runInternal and searchAsync). - RecommendationsController: validate the ?count= query param (must be a positive integer) instead of silently producing NaN. - Commit the Langfuse prompt definitions (langfuse/*.prompt.json) and add a README covering setup, prompt seeding, cache invalidation, and the HTTP API surface — the branch was not otherwise runnable by anyone but the author.
This commit is contained in:
20
langfuse/movie-recommender.prompt.json
Normal file
20
langfuse/movie-recommender.prompt.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "movie-recommender",
|
||||
"type": "chat",
|
||||
"prompt": [
|
||||
{
|
||||
"role": "system",
|
||||
"content": "You are a movie recommendation engine. Based on the user's favorite and recently watched movies below, suggest exactly {{count}} movies they would enjoy.\n\nIMPORTANT:\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\"}"
|
||||
},
|
||||
{
|
||||
"role": "user",
|
||||
"content": "User's favorite movies:\n{{favorites}}\n\nUser's recently watched movies:\n{{watched}}\n\nAlready in library (DO NOT suggest these):\n{{library}}\n\nAlready suggested (DO NOT repeat these):\n{{previouslySuggested}}"
|
||||
}
|
||||
],
|
||||
"config": {
|
||||
"model": "llama3",
|
||||
"temperature": 0.7,
|
||||
"maxTokens": 1024
|
||||
},
|
||||
"labels": ["production"]
|
||||
}
|
||||
20
langfuse/movie-search.prompt.json
Normal file
20
langfuse/movie-search.prompt.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "movie-search",
|
||||
"type": "chat",
|
||||
"prompt": [
|
||||
{
|
||||
"role": "system",
|
||||
"content": "You are a movie recommendation engine. Return ONLY a JSON array of {{count}} movies matching the user's request. No other text.\nEach entry: {\"title\": \"Movie Title\", \"year\": 2024, \"reason\": \"brief reason\"}"
|
||||
},
|
||||
{
|
||||
"role": "user",
|
||||
"content": "The user is looking for: {{query}}"
|
||||
}
|
||||
],
|
||||
"config": {
|
||||
"model": "llama3",
|
||||
"temperature": 0.7,
|
||||
"maxTokens": 1024
|
||||
},
|
||||
"labels": ["production"]
|
||||
}
|
||||
Reference in New Issue
Block a user