initial commit
Some checks failed
Recommender Build and Deploy (internal) / Build Recommender Image (push) Failing after 3m48s
Recommender Build and Deploy (internal) / Deploy Recommender (internal) (push) Has been skipped

This commit is contained in:
2026-03-25 17:34:37 -03:00
commit f9c7582e4d
52 changed files with 7022 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
import { openai } from '../agent.js';
import type { InterpreterOutput, RetrievalOutput } from '../types/agents.js';
export async function runRetrieval(input: InterpreterOutput): Promise<RetrievalOutput> {
const response = await openai.chat.completions.create({
model: 'gpt-5.4',
temperature: 0.9,
service_tier: 'flex',
response_format: { type: 'json_object' },
messages: [
{
role: 'system',
content: `You are a TV show candidate generator. Your goal is to brainstorm a LARGE, DIVERSE pool of 6080 TV show candidates that match the user's structured preferences.
Your output MUST be valid JSON matching this schema:
{
"candidates": [
{ "title": string, "reason": string }
]
}
Rules:
- Include both well-known and obscure shows
- Prioritize RECALL over precision — it's better to include too many than too few
- Each "reason" should briefly explain why the show matches the preferences
- Avoid duplicates
- Include shows from different decades, countries, and networks
- Aim for 6080 candidates minimum`,
},
{
role: 'user',
content: `Structured preferences:
Liked shows: ${JSON.stringify(input.liked)}
Disliked shows: ${JSON.stringify(input.disliked)}
Themes: ${JSON.stringify(input.themes)}
Character preferences: ${JSON.stringify(input.character_preferences)}
Tone: ${JSON.stringify(input.tone)}
Avoid: ${JSON.stringify(input.avoid)}
Generate a large, diverse pool of TV show candidates.`,
},
],
});
const content = response.choices[0]?.message?.content ?? '{"candidates":[]}';
return JSON.parse(content) as RetrievalOutput;
}