(payload: GenerateAiWorkflowPayload)
| 73 | } |
| 74 | |
| 75 | export async function generateAiWorkflow(payload: GenerateAiWorkflowPayload) { |
| 76 | "use workflow"; |
| 77 | |
| 78 | const { videoId, userId } = payload; |
| 79 | |
| 80 | const videoData = await validateAndSetProcessing(videoId); |
| 81 | |
| 82 | const transcript = await fetchTranscript(videoId, userId, videoData.video); |
| 83 | |
| 84 | if (!transcript) { |
| 85 | await markSkipped(videoId, videoData.metadata); |
| 86 | return { |
| 87 | success: true, |
| 88 | message: "Transcript empty or too short - skipped", |
| 89 | }; |
| 90 | } |
| 91 | |
| 92 | const result = await generateWithAi( |
| 93 | transcript, |
| 94 | videoData.aiGenerationLanguage, |
| 95 | ); |
| 96 | |
| 97 | await saveResults(videoId, videoData, result); |
| 98 | |
| 99 | return { success: true, message: "AI generation completed successfully" }; |
| 100 | } |
| 101 | |
| 102 | async function validateAndSetProcessing(videoId: string): Promise<VideoData> { |
| 103 | "use step"; |
nothing calls this directly
no test coverage detected