changes and improvements
All checks were successful
Recommender Build and Deploy (internal) / Build Recommender Image (push) Successful in 5m40s
Recommender Build and Deploy (internal) / Deploy Recommender (internal) (push) Successful in 38s

This commit is contained in:
2026-04-01 18:31:14 -03:00
parent a73bc27356
commit 39edec4a7c
10 changed files with 114 additions and 31 deletions

View File

@@ -4,6 +4,7 @@ import { z } from 'zod';
import { zodTextFormat } from 'openai/helpers/zod';
const RankingSchema = z.object({
full_match: z.array(z.string()),
definitely_like: z.array(z.string()),
might_like: z.array(z.string()),
questionable: z.array(z.string()),
@@ -32,6 +33,7 @@ export async function runRanking(
}
const allTags: RankingOutput = {
full_match: [],
definitely_like: [],
might_like: [],
questionable: [],
@@ -46,21 +48,23 @@ export async function runRanking(
temperature: 0.2,
...serviceOptions,
text: { format: zodTextFormat(RankingSchema, "ranking") },
instructions: `You are a ${mediaLabel} ranking critic. Assign each ${mediaLabel} to exactly one of four confidence tags based on how well it matches the user's preferences.
instructions: `You are a ${mediaLabel} ranking critic. Assign each ${mediaLabel} to exactly one of five confidence tags based on how well it matches the user's preferences.
Tags:
- "definitely_like": Near-perfect match to all preferences
- "full_match": 100% match — perfectly satisfies every stated preference, requirement, and avoidance criteria with no compromises
- "definitely_like": Near-perfect match to all preferences with only minor caveats
- "might_like": Strong match to most preferences
- "questionable": Partial alignment, some aspects don't match
- "will_not_like": Likely mismatch, conflicts with preferences or avoidance criteria
Every ${mediaLabel} in the input must appear in exactly one tag. Use the title exactly as given.`,
input: `User preferences:
Liked ${mediaLabel}s: ${JSON.stringify(interpreter.liked)}
Themes: ${JSON.stringify(interpreter.themes)}
Character preferences: ${JSON.stringify(interpreter.character_preferences)}
Tone: ${JSON.stringify(interpreter.tone)}
Avoid: ${JSON.stringify(interpreter.avoid)}
Liked ${mediaLabel}s: ${interpreter.liked.join(', ') || '(none)'}
Themes: ${interpreter.themes.join(', ') || '(none)'}
Character preferences: ${interpreter.character_preferences.join(', ') || '(none)'}
Tone: ${interpreter.tone.join(', ') || '(none)'}
Avoid: ${interpreter.avoid.join(', ') || '(none)'}
Requirements: ${interpreter.requirements.join(', ') || '(none)'}
Rank these ${mediaLabel}s:
${chunkTitles}`,
@@ -68,6 +72,7 @@ ${chunkTitles}`,
const chunkResult = (response.output_parsed as Partial<RankingOutput>) ?? {};
allTags.full_match.push(...(chunkResult.full_match ?? []));
allTags.definitely_like.push(...(chunkResult.definitely_like ?? []));
allTags.might_like.push(...(chunkResult.might_like ?? []));
allTags.questionable.push(...(chunkResult.questionable ?? []));