@umituz/react-native-ai-fal-provider 1.0.87 → 1.0.88

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-ai-fal-provider",
3
- "version": "1.0.87",
3
+ "version": "1.0.88",
4
4
  "description": "FAL AI provider for React Native - implements IAIProvider interface for unified AI generation",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -1,22 +1,15 @@
1
1
  /**
2
2
  * FAL Feature Models Catalog
3
- * Provider-specific model IDs for image and video processing features
3
+ * Default model IDs for image processing features
4
+ * Video models are provided by the app via config
4
5
  */
5
6
 
6
- import type {
7
- ImageFeatureType,
8
- VideoFeatureType,
9
- } from "@umituz/react-native-ai-generation-content";
10
-
11
- export interface FeatureModelConfig {
12
- readonly id: string;
13
- readonly feature: ImageFeatureType | VideoFeatureType;
14
- }
7
+ import type { ImageFeatureType } from "@umituz/react-native-ai-generation-content";
15
8
 
16
9
  /**
17
10
  * FAL model IDs for IMAGE processing features
18
11
  */
19
- export const FAL_IMAGE_FEATURE_MODELS = {
12
+ export const FAL_IMAGE_FEATURE_MODELS: Record<ImageFeatureType, string> = {
20
13
  "upscale": "fal-ai/clarity-upscaler",
21
14
  "photo-restore": "fal-ai/aura-sr",
22
15
  "face-swap": "fal-ai/face-swap",
@@ -25,35 +18,4 @@ export const FAL_IMAGE_FEATURE_MODELS = {
25
18
  "remove-object": "fal-ai/fooocus/inpaint",
26
19
  "hd-touch-up": "fal-ai/clarity-upscaler",
27
20
  "replace-background": "fal-ai/bria/background/replace",
28
- } as const satisfies Record<ImageFeatureType, string>;
29
-
30
- /**
31
- * FAL model IDs for VIDEO processing features
32
- * Vidu Q1 Reference-to-Video supports up to 7 reference images
33
- * Perfect for multi-person scenarios like kiss/hug with two different people
34
- */
35
- export const FAL_VIDEO_FEATURE_MODELS = {
36
- "ai-hug": "fal-ai/vidu/q1/reference-to-video",
37
- "ai-kiss": "fal-ai/vidu/q1/reference-to-video",
38
- } as const satisfies Record<VideoFeatureType, string>;
39
-
40
- /**
41
- * Get all feature model configs
42
- */
43
- export function getAllFeatureModels(): readonly FeatureModelConfig[] {
44
- const imageModels = Object.entries(FAL_IMAGE_FEATURE_MODELS).map(
45
- ([feature, id]) => ({
46
- id,
47
- feature: feature as ImageFeatureType,
48
- } satisfies FeatureModelConfig)
49
- );
50
-
51
- const videoModels = Object.entries(FAL_VIDEO_FEATURE_MODELS).map(
52
- ([feature, id]) => ({
53
- id,
54
- feature: feature as VideoFeatureType,
55
- } satisfies FeatureModelConfig)
56
- );
57
-
58
- return [...imageModels, ...videoModels];
59
- }
21
+ } as const;
@@ -33,15 +33,13 @@ export interface ReplaceBackgroundOptions {
33
33
  }
34
34
 
35
35
  export interface VideoFromImageOptions {
36
- readonly target_image?: string;
37
36
  readonly prompt?: string;
38
37
  /** @deprecated Use prompt instead */
39
38
  readonly motion_prompt?: string;
40
- readonly duration?: number;
41
- /** Vidu Q1: Video aspect ratio - "16:9", "9:16", or "1:1" */
42
- readonly aspect_ratio?: "16:9" | "9:16" | "1:1";
43
- /** Vidu Q1: Movement intensity - "auto", "small", "medium", or "large" */
44
- readonly movement_amplitude?: "auto" | "small" | "medium" | "large";
39
+ /** Video duration in seconds (5 or 10 for Wan 2.5) */
40
+ readonly duration?: 5 | 10;
41
+ /** Video resolution (480p, 720p, or 1080p) */
42
+ readonly resolution?: "480p" | "720p" | "1080p";
45
43
  }
46
44
 
47
45
  export interface FaceSwapOptions {
package/src/index.ts CHANGED
@@ -41,19 +41,12 @@ export {
41
41
  } from "./domain/constants/default-models.constants";
42
42
  export type { FalModelConfig } from "./domain/constants/default-models.constants";
43
43
 
44
- export {
45
- FAL_IMAGE_FEATURE_MODELS,
46
- FAL_VIDEO_FEATURE_MODELS,
47
- getAllFeatureModels,
48
- } from "./domain/constants/feature-models.constants";
49
- export type { FeatureModelConfig } from "./domain/constants/feature-models.constants";
44
+ export { FAL_IMAGE_FEATURE_MODELS } from "./domain/constants/feature-models.constants";
50
45
 
51
46
  export {
52
47
  FalProvider,
53
48
  falProvider,
54
49
  falModelsService,
55
- getImageFeatureModel,
56
- getVideoFeatureModel,
57
50
  NSFWContentError,
58
51
  cancelCurrentFalRequest,
59
52
  hasRunningFalRequest,
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Video Feature Input Builder
3
- * Builds inputs for video-based AI features
3
+ * Builds inputs for video-based AI features (Wan 2.5)
4
4
  */
5
5
 
6
6
  import type {
@@ -9,23 +9,24 @@ import type {
9
9
  } from "@umituz/react-native-ai-generation-content";
10
10
  import { buildVideoFromImageInput } from "../utils/video-feature-builders.util";
11
11
 
12
- const DEFAULT_VIDEO_PROMPTS: Record<VideoFeatureType, string> = {
13
- "ai-kiss": "A romantic couple kissing tenderly, the two reference people sharing an intimate kiss moment, smooth natural movement, cinematic lighting, high quality video",
14
- "ai-hug": "A heartwarming embrace between two people, the reference characters hugging warmly with genuine emotion, gentle natural movement, cinematic quality, touching moment",
12
+ const DEFAULT_VIDEO_PROMPTS: Partial<Record<VideoFeatureType, string>> = {
13
+ "ai-kiss": "A romantic couple kissing tenderly, smooth natural movement, cinematic lighting",
14
+ "ai-hug": "A heartwarming embrace between two people, gentle natural movement, cinematic quality",
15
+ "image-to-video": "Animate this image with natural, smooth motion while preserving all details",
16
+ "text-to-video": "Generate a high-quality video based on the description, smooth motion",
15
17
  } as const;
16
18
 
17
19
  export function buildVideoFeatureInput(
18
20
  feature: VideoFeatureType,
19
21
  data: VideoFeatureInputData,
20
22
  ): Record<string, unknown> {
21
- const { sourceImageBase64, targetImageBase64, prompt, options } = data;
23
+ const { sourceImageBase64, prompt, options } = data;
22
24
 
23
25
  const effectivePrompt = prompt || DEFAULT_VIDEO_PROMPTS[feature] || "Generate video with natural motion";
24
26
 
25
27
  return buildVideoFromImageInput(sourceImageBase64, {
26
28
  prompt: effectivePrompt,
27
- target_image: targetImageBase64,
28
- aspect_ratio: (options?.aspect_ratio as "16:9" | "9:16" | "1:1") || "9:16",
29
- movement_amplitude: (options?.movement_amplitude as "auto" | "small" | "medium" | "large") || "medium",
29
+ duration: (options?.duration as 5 | 10) || 5,
30
+ resolution: (options?.resolution as "480p" | "720p" | "1080p") || "720p",
30
31
  });
31
32
  }
@@ -21,10 +21,6 @@ import type { FalQueueStatus } from "../../domain/entities/fal.types";
21
21
  import type { CostTrackerConfig } from "../../domain/entities/cost-tracking.types";
22
22
  import { DEFAULT_FAL_CONFIG, FAL_CAPABILITIES } from "./fal-provider.constants";
23
23
  import { mapFalStatusToJobStatus } from "./fal-status-mapper";
24
- import {
25
- FAL_IMAGE_FEATURE_MODELS,
26
- FAL_VIDEO_FEATURE_MODELS,
27
- } from "../../domain/constants/feature-models.constants";
28
24
  import {
29
25
  buildImageFeatureInput as buildImageFeatureInputImpl,
30
26
  buildVideoFeatureInput as buildVideoFeatureInputImpl,
@@ -45,9 +41,13 @@ export class FalProvider implements IAIProvider {
45
41
  private initialized = false;
46
42
  private currentAbortController: AbortController | null = null;
47
43
  private costTracker: CostTracker | null = null;
44
+ private videoFeatureModels: Record<string, string> = {};
45
+ private imageFeatureModels: Record<string, string> = {};
48
46
 
49
47
  initialize(configData: AIProviderConfig): void {
50
48
  this.apiKey = configData.apiKey;
49
+ this.videoFeatureModels = configData.videoFeatureModels ?? {};
50
+ this.imageFeatureModels = configData.imageFeatureModels ?? {};
51
51
 
52
52
  fal.config({
53
53
  credentials: configData.apiKey,
@@ -218,7 +218,11 @@ export class FalProvider implements IAIProvider {
218
218
  }
219
219
 
220
220
  getImageFeatureModel(feature: ImageFeatureType): string {
221
- return FAL_IMAGE_FEATURE_MODELS[feature];
221
+ const model = this.imageFeatureModels[feature];
222
+ if (!model) {
223
+ throw new Error(`No model configured for image feature: ${feature}`);
224
+ }
225
+ return model;
222
226
  }
223
227
 
224
228
  buildImageFeatureInput(
@@ -229,7 +233,11 @@ export class FalProvider implements IAIProvider {
229
233
  }
230
234
 
231
235
  getVideoFeatureModel(feature: VideoFeatureType): string {
232
- return FAL_VIDEO_FEATURE_MODELS[feature];
236
+ const model = this.videoFeatureModels[feature];
237
+ if (!model) {
238
+ throw new Error(`No model configured for video feature: ${feature}`);
239
+ }
240
+ return model;
233
241
  }
234
242
 
235
243
  buildVideoFeatureInput(
@@ -2,8 +2,6 @@
2
2
  * Services Index
3
3
  */
4
4
 
5
- import { FAL_IMAGE_FEATURE_MODELS, FAL_VIDEO_FEATURE_MODELS } from "../../domain/constants/feature-models.constants";
6
- import type { ImageFeatureType, VideoFeatureType } from "@umituz/react-native-ai-generation-content";
7
5
  import { falProvider } from "./fal-provider";
8
6
 
9
7
  export { FalProvider, falProvider } from "./fal-provider";
@@ -11,14 +9,6 @@ export type { FalProvider as FalProviderType } from "./fal-provider";
11
9
  export { falModelsService, type FalModelConfig } from "./fal-models.service";
12
10
  export { NSFWContentError } from "./nsfw-content-error";
13
11
 
14
- export function getImageFeatureModel(feature: ImageFeatureType): string {
15
- return FAL_IMAGE_FEATURE_MODELS[feature];
16
- }
17
-
18
- export function getVideoFeatureModel(feature: VideoFeatureType): string {
19
- return FAL_VIDEO_FEATURE_MODELS[feature];
20
- }
21
-
22
12
  /**
23
13
  * Cancel the current running FAL request
24
14
  */
@@ -29,15 +29,10 @@ export function buildVideoFromImageInput(
29
29
  const formatImage = (b64: string) =>
30
30
  b64.startsWith("data:") ? b64 : `data:image/jpeg;base64,${b64}`;
31
31
 
32
- const referenceImages: string[] = [formatImage(base64)];
33
- if (options?.target_image) {
34
- referenceImages.push(formatImage(options.target_image));
35
- }
36
-
37
32
  return {
38
33
  prompt: options?.prompt || options?.motion_prompt || "Generate natural motion video",
39
- reference_image_urls: referenceImages,
40
- aspect_ratio: options?.aspect_ratio || "9:16",
41
- movement_amplitude: options?.movement_amplitude || "auto",
34
+ image_url: formatImage(base64),
35
+ duration: options?.duration || 5,
36
+ resolution: options?.resolution || "720p",
42
37
  };
43
38
  }