@umituz/react-native-ai-fal-provider 1.0.35 → 1.0.37
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.
|
|
3
|
+
"version": "1.0.37",
|
|
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",
|
|
@@ -21,6 +21,17 @@ import type { FalQueueStatus } from "../../domain/entities/fal.types";
|
|
|
21
21
|
import { DEFAULT_FAL_CONFIG, FAL_CAPABILITIES } from "./fal-provider.constants";
|
|
22
22
|
import { mapFalStatusToJobStatus } from "./fal-status-mapper";
|
|
23
23
|
import { FAL_IMAGE_FEATURE_MODELS, FAL_VIDEO_FEATURE_MODELS } from "../../domain/constants/feature-models.constants";
|
|
24
|
+
import {
|
|
25
|
+
buildSingleImageInput,
|
|
26
|
+
buildUpscaleInput,
|
|
27
|
+
buildPhotoRestoreInput,
|
|
28
|
+
buildFaceSwapInput,
|
|
29
|
+
buildRemoveBackgroundInput,
|
|
30
|
+
buildRemoveObjectInput,
|
|
31
|
+
buildReplaceBackgroundInput,
|
|
32
|
+
buildImageToImageInput,
|
|
33
|
+
buildVideoFromImageInput,
|
|
34
|
+
} from "../utils/input-builders.util";
|
|
24
35
|
|
|
25
36
|
declare const __DEV__: boolean;
|
|
26
37
|
|
|
@@ -176,16 +187,58 @@ export class FalProvider implements IAIProvider {
|
|
|
176
187
|
return FAL_IMAGE_FEATURE_MODELS[feature];
|
|
177
188
|
}
|
|
178
189
|
|
|
179
|
-
buildImageFeatureInput(
|
|
180
|
-
|
|
190
|
+
buildImageFeatureInput(feature: ImageFeatureType, data: ImageFeatureInputData): Record<string, unknown> {
|
|
191
|
+
const { imageBase64, targetImageBase64, prompt, options } = data;
|
|
192
|
+
|
|
193
|
+
switch (feature) {
|
|
194
|
+
case "upscale":
|
|
195
|
+
case "hd-touch-up":
|
|
196
|
+
return buildUpscaleInput(imageBase64, options);
|
|
197
|
+
|
|
198
|
+
case "photo-restore":
|
|
199
|
+
return buildPhotoRestoreInput(imageBase64, options);
|
|
200
|
+
|
|
201
|
+
case "face-swap":
|
|
202
|
+
if (!targetImageBase64) throw new Error("Face swap requires target image");
|
|
203
|
+
return buildFaceSwapInput(imageBase64, targetImageBase64, options);
|
|
204
|
+
|
|
205
|
+
case "remove-background":
|
|
206
|
+
return buildRemoveBackgroundInput(imageBase64, options);
|
|
207
|
+
|
|
208
|
+
case "remove-object":
|
|
209
|
+
return buildRemoveObjectInput(imageBase64, options);
|
|
210
|
+
|
|
211
|
+
case "replace-background":
|
|
212
|
+
if (!prompt) throw new Error("Replace background requires prompt");
|
|
213
|
+
return buildReplaceBackgroundInput(imageBase64, { prompt, ...options });
|
|
214
|
+
|
|
215
|
+
case "anime-selfie":
|
|
216
|
+
return buildImageToImageInput(imageBase64, {
|
|
217
|
+
prompt: prompt || (options?.prompt as string) || "",
|
|
218
|
+
negativePrompt: (options?.negativePrompt as string) || "",
|
|
219
|
+
strength: options?.strength as number,
|
|
220
|
+
num_inference_steps: options?.num_inference_steps as number,
|
|
221
|
+
guidance_scale: options?.guidance_scale as number,
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
default:
|
|
225
|
+
return buildSingleImageInput(imageBase64, options);
|
|
226
|
+
}
|
|
181
227
|
}
|
|
182
228
|
|
|
183
229
|
getVideoFeatureModel(feature: VideoFeatureType): string {
|
|
184
230
|
return FAL_VIDEO_FEATURE_MODELS[feature];
|
|
185
231
|
}
|
|
186
232
|
|
|
187
|
-
buildVideoFeatureInput(_feature: VideoFeatureType,
|
|
188
|
-
|
|
233
|
+
buildVideoFeatureInput(_feature: VideoFeatureType, data: VideoFeatureInputData): Record<string, unknown> {
|
|
234
|
+
const { sourceImageBase64, targetImageBase64, prompt, options } = data;
|
|
235
|
+
|
|
236
|
+
return buildVideoFromImageInput(sourceImageBase64, {
|
|
237
|
+
motion_prompt: prompt,
|
|
238
|
+
target_image: targetImageBase64,
|
|
239
|
+
duration: options?.duration as number,
|
|
240
|
+
...options,
|
|
241
|
+
});
|
|
189
242
|
}
|
|
190
243
|
}
|
|
191
244
|
|