-
Notifications
You must be signed in to change notification settings - Fork 354
/
Copy pathtextToVideo.ts
27 lines (24 loc) · 1.17 KB
/
textToVideo.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import type { TextToVideoInput } from "@huggingface/tasks";
import { getProviderHelper } from "../../lib/getProviderHelper";
import { makeRequestOptions } from "../../lib/makeRequestOptions";
import type { FalAiQueueOutput } from "../../providers/fal-ai";
import type { NovitaOutput } from "../../providers/novita";
import type { ReplicateOutput } from "../../providers/replicate";
import type { BaseArgs, Options } from "../../types";
import { innerRequest } from "../../utils/request";
export type TextToVideoArgs = BaseArgs & TextToVideoInput;
export type TextToVideoOutput = Blob;
export async function textToVideo(args: TextToVideoArgs, options?: Options): Promise<TextToVideoOutput> {
const provider = args.provider ?? "hf-inference";
const providerHelper = getProviderHelper(provider, "text-to-video");
const { data: response } = await innerRequest<FalAiQueueOutput | ReplicateOutput | NovitaOutput>(
args,
providerHelper,
{
...options,
task: "text-to-video",
}
);
const { url, info } = await makeRequestOptions(args, providerHelper, { ...options, task: "text-to-video" });
return providerHelper.getResponse(response, url, info.headers as Record<string, string>);
}