|
1 | | -import type { BaseArgs, InferenceProvider, Options } from "../../types"; |
2 | 1 | import type { TextToVideoInput } from "@huggingface/tasks"; |
3 | | -import { request } from "../custom/request"; |
4 | | -import { omit } from "../../utils/omit"; |
5 | | -import { isUrl } from "../../lib/isUrl"; |
6 | 2 | import { InferenceOutputError } from "../../lib/InferenceOutputError"; |
7 | | -import { typedInclude } from "../../utils/typedInclude"; |
8 | | -import { makeRequestOptions } from "../../lib/makeRequestOptions"; |
| 3 | +import { isUrl } from "../../lib/isUrl"; |
9 | 4 | import { pollFalResponse, type FalAiQueueOutput } from "../../providers/fal-ai"; |
| 5 | +import type { BaseArgs, InferenceProvider, Options } from "../../types"; |
| 6 | +import { omit } from "../../utils/omit"; |
| 7 | +import { typedInclude } from "../../utils/typedInclude"; |
| 8 | +import { request, type ResponseWrapper } from "../custom/request"; |
10 | 9 |
|
11 | 10 | export type TextToVideoArgs = BaseArgs & TextToVideoInput; |
12 | 11 |
|
@@ -35,13 +34,15 @@ export async function textToVideo(args: TextToVideoArgs, options?: Options): Pro |
35 | 34 | args.provider === "fal-ai" || args.provider === "replicate" || args.provider === "novita" |
36 | 35 | ? { ...omit(args, ["inputs", "parameters"]), ...args.parameters, prompt: args.inputs } |
37 | 36 | : args; |
38 | | - const res = await request<FalAiQueueOutput | ReplicateOutput | NovitaOutput>(payload, { |
| 37 | + const response = await request<ResponseWrapper<FalAiQueueOutput | ReplicateOutput | NovitaOutput>>(payload, { |
39 | 38 | ...options, |
40 | 39 | task: "text-to-video", |
| 40 | + withRequestContext: true, |
41 | 41 | }); |
| 42 | + |
| 43 | + const { data: res, requestContext } = response; |
42 | 44 | if (args.provider === "fal-ai") { |
43 | | - const { url, info } = await makeRequestOptions(args, { ...options, task: "text-to-video" }); |
44 | | - return await pollFalResponse(res as FalAiQueueOutput, url, info.headers as Record<string, string>); |
| 45 | + return await pollFalResponse(res as FalAiQueueOutput, requestContext.url, requestContext.headers); |
45 | 46 | } else if (args.provider === "novita") { |
46 | 47 | const isValidOutput = |
47 | 48 | typeof res === "object" && |
|
0 commit comments