generated from fahricansecer/boilerplate-be
This commit is contained in:
@@ -546,4 +546,44 @@ export class VideoAiService {
|
||||
|
||||
return parsed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tekil sahne yeniden üretimi — sınırlı bağlam ile sadece 1 sahne üretir.
|
||||
*/
|
||||
async generateSingleScene(contextPrompt: string): Promise<{
|
||||
narrationText: string;
|
||||
visualPrompt: string;
|
||||
subtitleText: string;
|
||||
durationSeconds: number;
|
||||
}> {
|
||||
if (!this.genAI) {
|
||||
throw new InternalServerErrorException('AI servisi etkin değil — Google API Key gerekli.');
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await this.genAI.models.generateContent({
|
||||
model: this.modelName,
|
||||
contents: contextPrompt,
|
||||
config: {
|
||||
responseMimeType: 'application/json',
|
||||
temperature: 0.8,
|
||||
maxOutputTokens: 1024,
|
||||
},
|
||||
});
|
||||
|
||||
const rawText = response.text || '';
|
||||
const cleaned = rawText.replace(/```json\n?/g, '').replace(/```\n?/g, '').trim();
|
||||
const parsed = JSON.parse(cleaned);
|
||||
|
||||
return {
|
||||
narrationText: parsed.narrationText || 'Yeniden üretilen sahne.',
|
||||
visualPrompt: parsed.visualPrompt || 'Cinematic establishing shot.',
|
||||
subtitleText: parsed.subtitleText || parsed.narrationText || '',
|
||||
durationSeconds: parsed.durationSeconds || 5,
|
||||
};
|
||||
} catch (error) {
|
||||
this.logger.error(`Tekil sahne üretim hatası: ${error}`);
|
||||
throw new InternalServerErrorException('Sahne yeniden üretilemedi.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user