/** * Consistency Check Prompt Builder * * Phase 3: After all segments are generated, AI reviews the entire * script for tone consistency, flow, pacing, and logical connections. * * TR: Tutarlılık kontrolü — tüm segmentler üretildikten sonra ton, akış ve mantık kontrolü. */ export interface ConsistencyCheckInput { segments: { type: string; narratorScript: string; visualDescription?: string; }[]; speechStyles: string[]; targetAudience: string[]; topic: string; language: string; } export function buildConsistencyCheckPrompt(input: ConsistencyCheckInput) { const segmentText = input.segments .map( (s, i) => `[Segment ${i + 1} — ${s.type}]\n${s.narratorScript}\nVisual: ${s.visualDescription || 'N/A'}`, ) .join('\n\n'); const prompt = `You are a senior script editor and quality assurance specialist. TASK: Review the entire script below for consistency, quality, and flow. TOPIC: "${input.topic}" SPEECH STYLE: ${input.speechStyles.join(', ')} TARGET AUDIENCE: ${input.targetAudience.join(', ')} LANGUAGE: ${input.language} FULL SCRIPT: ${segmentText} EVALUATE AND PROVIDE: 1. "overallScore" — Quality score 1-100 2. "toneConsistency" — Score 1-10 for consistent tone/voice throughout 3. "flowScore" — Score 1-10 for smooth transitions and logical progression 4. "pacingScore" — Score 1-10 for good pacing (not too fast/slow) 5. "engagementScore" — Score 1-10 for how engaging the content is 6. "issues" — Array of specific issues found: - "segmentIndex": which segment (0-based) - "type": "tone_mismatch" | "flow_break" | "pacing_issue" | "repetition" | "logic_gap" | "weak_content" - "description": human-readable explanation - "severity": "low" | "medium" | "high" - "suggestedFix": how to fix this issue 7. "segmentsToRewrite" — Array of segment indexes (0-based) that should be rewritten 8. "generalSuggestions" — Overall improvement suggestions (max 5) Be rigorous but fair. Only flag genuine issues that would impact the audience experience. Respond in ${input.language}.`; const schema = { type: 'object' as const, properties: { overallScore: { type: 'number' as const }, toneConsistency: { type: 'number' as const }, flowScore: { type: 'number' as const }, pacingScore: { type: 'number' as const }, engagementScore: { type: 'number' as const }, issues: { type: 'array' as const, items: { type: 'object' as const, properties: { segmentIndex: { type: 'number' as const }, type: { type: 'string' as const }, description: { type: 'string' as const }, severity: { type: 'string' as const }, suggestedFix: { type: 'string' as const }, }, }, }, segmentsToRewrite: { type: 'array' as const, items: { type: 'number' as const }, }, generalSuggestions: { type: 'array' as const, items: { type: 'string' as const }, }, }, required: [ 'overallScore', 'toneConsistency', 'flowScore', 'pacingScore', 'engagementScore', 'issues', 'segmentsToRewrite', 'generalSuggestions', ], }; return { prompt, temperature: 0.3, schema: JSON.stringify(schema) }; }