import { RECAP_PROMPT } from '../../../prompts/recap.js'; import { tryModels, getPrompt, DEFAULT_SAFETY_SETTINGS } from '@/backend/services/ai/utils'; export async function recap(media, mimeType, targetLanguage, apiKey, isOwnApi = false) { // UPDATED: Aligned with the 'no Pro' preference const models = ['gemini-3-flash-preview', 'gemini-flash-lite-latest']; const finalPrompt = RECAP_PROMPT(targetLanguage); return await tryModels(apiKey, models, async (ai, model) => { const response = await ai.models.generateContent({ model: model, contents: { parts: [ { inlineData: { data: media, mimeType } }, { text: "Narrate an extremely detailed cinematic recap." } ] }, config: { temperature: 0.4, systemInstruction: finalPrompt, safetySettings: DEFAULT_SAFETY_SETTINGS, thinkingConfig: { thinkingBudget: 0 } } }); const text = response.text; if (!text || text.trim().length < 10) { throw new Error("MODEL_FAILED_TO_GENERATE_RECAP"); } return text; }); }