@umituz/react-native-ai-fal-provider 1.1.1 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -42,6 +42,20 @@ export interface VideoFromImageOptions {
|
|
|
42
42
|
readonly resolution?: string;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Options for text-to-video generation (no image input)
|
|
47
|
+
*/
|
|
48
|
+
export interface TextToVideoOptions {
|
|
49
|
+
/** Generation prompt (required) */
|
|
50
|
+
readonly prompt: string;
|
|
51
|
+
/** Video duration in seconds */
|
|
52
|
+
readonly duration?: number;
|
|
53
|
+
/** Aspect ratio (e.g., "16:9", "9:16") */
|
|
54
|
+
readonly aspectRatio?: string;
|
|
55
|
+
/** Video resolution */
|
|
56
|
+
readonly resolution?: string;
|
|
57
|
+
}
|
|
58
|
+
|
|
45
59
|
export interface FaceSwapOptions {
|
|
46
60
|
// No additional options
|
|
47
61
|
}
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Video Feature Input Builder
|
|
3
|
-
* Builds inputs for video-based AI features
|
|
3
|
+
* Builds inputs for video-based AI features
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import type {
|
|
7
7
|
VideoFeatureType,
|
|
8
8
|
VideoFeatureInputData,
|
|
9
9
|
} from "@umituz/react-native-ai-generation-content";
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
buildVideoFromImageInput,
|
|
12
|
+
buildTextToVideoInput,
|
|
13
|
+
} from "../utils/video-feature-builders.util";
|
|
11
14
|
|
|
12
15
|
const DEFAULT_VIDEO_PROMPTS: Partial<Record<VideoFeatureType, string>> = {
|
|
13
16
|
"ai-kiss": "A romantic couple kissing tenderly, smooth natural movement, cinematic lighting",
|
|
@@ -16,17 +19,38 @@ const DEFAULT_VIDEO_PROMPTS: Partial<Record<VideoFeatureType, string>> = {
|
|
|
16
19
|
"text-to-video": "Generate a high-quality video based on the description, smooth motion",
|
|
17
20
|
} as const;
|
|
18
21
|
|
|
22
|
+
/**
|
|
23
|
+
* Features that require image input
|
|
24
|
+
*/
|
|
25
|
+
const IMAGE_REQUIRED_FEATURES: readonly VideoFeatureType[] = [
|
|
26
|
+
"image-to-video",
|
|
27
|
+
"ai-kiss",
|
|
28
|
+
"ai-hug",
|
|
29
|
+
] as const;
|
|
30
|
+
|
|
31
|
+
function isImageRequiredFeature(feature: VideoFeatureType): boolean {
|
|
32
|
+
return IMAGE_REQUIRED_FEATURES.includes(feature);
|
|
33
|
+
}
|
|
34
|
+
|
|
19
35
|
export function buildVideoFeatureInput(
|
|
20
36
|
feature: VideoFeatureType,
|
|
21
37
|
data: VideoFeatureInputData,
|
|
22
38
|
): Record<string, unknown> {
|
|
23
39
|
const { sourceImageBase64, prompt, options } = data;
|
|
40
|
+
const effectivePrompt = prompt || DEFAULT_VIDEO_PROMPTS[feature] || "Generate video";
|
|
24
41
|
|
|
25
|
-
|
|
42
|
+
if (isImageRequiredFeature(feature)) {
|
|
43
|
+
return buildVideoFromImageInput(sourceImageBase64 || "", {
|
|
44
|
+
prompt: effectivePrompt,
|
|
45
|
+
duration: options?.duration as number | undefined,
|
|
46
|
+
resolution: options?.resolution as string | undefined,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
26
49
|
|
|
27
|
-
return
|
|
50
|
+
return buildTextToVideoInput({
|
|
28
51
|
prompt: effectivePrompt,
|
|
29
|
-
duration: options?.duration,
|
|
30
|
-
|
|
52
|
+
duration: options?.duration as number | undefined,
|
|
53
|
+
aspectRatio: options?.aspect_ratio as string | undefined,
|
|
54
|
+
resolution: options?.resolution as string | undefined,
|
|
31
55
|
});
|
|
32
56
|
}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import type {
|
|
7
7
|
ImageToImagePromptConfig,
|
|
8
8
|
VideoFromImageOptions,
|
|
9
|
+
TextToVideoOptions,
|
|
9
10
|
} from "../../domain/types";
|
|
10
11
|
import { buildSingleImageInput } from "./base-builders.util";
|
|
11
12
|
|
|
@@ -36,3 +37,19 @@ export function buildVideoFromImageInput(
|
|
|
36
37
|
...(options?.resolution && { resolution: options.resolution }),
|
|
37
38
|
};
|
|
38
39
|
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Build input for text-to-video generation (no image required)
|
|
43
|
+
*/
|
|
44
|
+
export function buildTextToVideoInput(
|
|
45
|
+
options: TextToVideoOptions,
|
|
46
|
+
): Record<string, unknown> {
|
|
47
|
+
const { prompt, duration, aspectRatio, resolution } = options;
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
prompt,
|
|
51
|
+
...(duration && { duration }),
|
|
52
|
+
...(aspectRatio && { aspect_ratio: aspectRatio }),
|
|
53
|
+
...(resolution && { resolution }),
|
|
54
|
+
};
|
|
55
|
+
}
|