MCPcopy
hub / github.com/CapSoftware/Cap / generateAiWorkflow

Function generateAiWorkflow

apps/web/workflows/generate-ai.ts:75–100  ·  view source on GitHub ↗
(payload: GenerateAiWorkflowPayload)

Source from the content-addressed store, hash-verified

73}
74
75export 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
102async function validateAndSetProcessing(videoId: string): Promise<VideoData> {
103 "use step";

Callers

nothing calls this directly

Calls 5

validateAndSetProcessingFunction · 0.85
fetchTranscriptFunction · 0.85
generateWithAiFunction · 0.85
saveResultsFunction · 0.85
markSkippedFunction · 0.70

Tested by

no test coverage detected