AI Video Generation Implementation

This commit is contained in:
ajaysi
2025-11-17 17:38:23 +05:30
parent 4901b7eb72
commit bf7493c366
132 changed files with 6200 additions and 19475 deletions

View File

@@ -185,6 +185,8 @@ function coerceUsageStats(raw: any): UsageStats {
metaphor_calls: raw?.limits?.limits?.metaphor_calls ?? 0,
firecrawl_calls: raw?.limits?.limits?.firecrawl_calls ?? 0,
stability_calls: raw?.limits?.limits?.stability_calls ?? 0,
video_calls: raw?.limits?.limits?.video_calls ?? 0,
image_edit_calls: raw?.limits?.limits?.image_edit_calls ?? 0,
gemini_tokens: raw?.limits?.limits?.gemini_tokens ?? 0,
openai_tokens: raw?.limits?.limits?.openai_tokens ?? 0,
anthropic_tokens: raw?.limits?.limits?.anthropic_tokens ?? 0,

View File

@@ -427,6 +427,104 @@ class StoryWriterApi {
return response.data;
}
/**
* Generate video asynchronously (returns task_id for polling)
*/
async generateStoryVideoAsync(
request: StoryVideoGenerationRequest
): Promise<{ task_id: string; status: string; message: string }> {
const response = await aiApiClient.post<{ task_id: string; status: string; message: string }>(
"/api/story/generate-video-async",
request
);
return response.data;
}
/**
* Generate HD AI animation via Hugging Face text-to-video (server saves and returns url)
*/
async generateHdVideo(payload: {
prompt: string;
provider?: string;
model?: string;
num_frames?: number;
guidance_scale?: number;
num_inference_steps?: number;
negative_prompt?: string;
seed?: number;
}): Promise<{ success: boolean; video_filename: string; video_url: string; provider: string; model: string }> {
// Long-running request - use longRunningApiClient to allow more time
const { longRunningApiClient } = await import("../api/client");
const response = await longRunningApiClient.post(
"/api/story/hd-video",
{
provider: "huggingface",
...payload,
}
);
return response.data;
}
/**
* Generate HD AI animation asynchronously (returns task_id for polling)
*/
async generateHdVideoAsync(payload: {
prompt: string;
provider?: string;
model?: string;
num_frames?: number;
guidance_scale?: number;
num_inference_steps?: number;
negative_prompt?: string;
seed?: number;
}): Promise<{ task_id: string; status: string; message: string }> {
const response = await aiApiClient.post<{ task_id: string; status: string; message: string }>(
"/api/story/hd-video-async",
{
provider: "huggingface",
...payload,
}
);
return response.data;
}
/**
* Generate HD AI video for a single scene with AI-enhanced prompt
*/
async generateHdVideoScene(payload: {
scene_number: number;
scene_data: StoryScene;
story_context: Record<string, any>;
all_scenes: StoryScene[];
scene_image_url?: string;
provider?: string;
model?: string;
num_frames?: number;
guidance_scale?: number;
num_inference_steps?: number;
negative_prompt?: string;
seed?: number;
}): Promise<{
success: boolean;
scene_number: number;
video_filename: string;
video_url: string;
prompt_used: string;
provider: string;
model: string;
}> {
// Long-running request - use longRunningApiClient to allow more time
const { longRunningApiClient } = await import("../api/client");
const response = await longRunningApiClient.post(
"/api/story/hd-video-scene",
{
provider: "huggingface",
...payload,
}
);
return response.data;
}
/**
* Get video URL for a story video file
*/