fixing api calls
This commit is contained in:
@@ -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: [] };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user