fixing api calls
All checks were successful
Recommender Build and Deploy (internal) / Build Recommender Image (push) Successful in 4m4s
Recommender Build and Deploy (internal) / Deploy Recommender (internal) (push) Successful in 10s

This commit is contained in:
2026-04-03 01:15:47 -03:00
parent 0c704cf2f6
commit a7d12acce6
6 changed files with 63 additions and 35 deletions

View File

@@ -1,4 +1,4 @@
import { openai, defaultModel, serviceOptions, supportsWebSearch } from '../agent.js';
import { openai, defaultModel, serviceOptions, supportsWebSearch, parseWithRetry } from '../agent.js';
import type { InterpreterOutput, RetrievalOutput, MediaType } from '../types/agents.js';
import { z } from 'zod';
import { zodTextFormat } from 'openai/helpers/zod';
@@ -22,7 +22,7 @@ export async function runRetrieval(
const mediaLabelPlural = mediaType === 'movie' ? 'movies' : 'TV shows';
const canSearch = useWebSearch && supportsWebSearch;
const response = await openai.responses.parse({
const response = await parseWithRetry(() => openai.responses.parse({
model: defaultModel,
temperature: 0.9,
max_completion_tokens: 16384,
@@ -48,7 +48,7 @@ Avoid: ${input.avoid.join(', ') || '(none)'}
Requirements: ${input.requirements.join(', ') || '(none)'}${previousFullMatches.length > 0 ? `\n\nPrevious Full Match titles (DO NOT repeat these; use them as inspiration for NEW candidates with similar qualities): ${previousFullMatches.join(', ')}` : ''}
Generate a large, diverse pool of ${mediaLabel} candidates.`,
});
}));
return (response.output_parsed as RetrievalOutput) ?? { candidates: [] };
}