@umituz/react-native-ai-fal-provider 1.0.19 → 1.0.21
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.21",
|
|
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",
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FAL Provider Constants
|
|
3
|
+
* Configuration and capability definitions for FAL AI provider
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { ProviderCapabilities } from "@umituz/react-native-ai-generation-content";
|
|
7
|
+
|
|
8
|
+
export const DEFAULT_FAL_CONFIG = {
|
|
9
|
+
maxRetries: 3,
|
|
10
|
+
baseDelay: 1000,
|
|
11
|
+
maxDelay: 10000,
|
|
12
|
+
defaultTimeoutMs: 300000,
|
|
13
|
+
pollInterval: 1000,
|
|
14
|
+
} as const;
|
|
15
|
+
|
|
16
|
+
export const FAL_CAPABILITIES: ProviderCapabilities = {
|
|
17
|
+
imageFeatures: [
|
|
18
|
+
"upscale",
|
|
19
|
+
"photo-restore",
|
|
20
|
+
"face-swap",
|
|
21
|
+
"anime-selfie",
|
|
22
|
+
"remove-background",
|
|
23
|
+
"remove-object",
|
|
24
|
+
"hd-touch-up",
|
|
25
|
+
"replace-background",
|
|
26
|
+
] as const,
|
|
27
|
+
videoFeatures: ["ai-hug", "ai-kiss"] as const,
|
|
28
|
+
textToImage: true,
|
|
29
|
+
textToVideo: true,
|
|
30
|
+
imageToVideo: true,
|
|
31
|
+
textToVoice: true,
|
|
32
|
+
textToText: false,
|
|
33
|
+
};
|
|
@@ -9,7 +9,6 @@ import type {
|
|
|
9
9
|
AIProviderConfig,
|
|
10
10
|
JobSubmission,
|
|
11
11
|
JobStatus,
|
|
12
|
-
AIJobStatusType,
|
|
13
12
|
SubscribeOptions,
|
|
14
13
|
RunOptions,
|
|
15
14
|
ImageFeatureType,
|
|
@@ -18,7 +17,9 @@ import type {
|
|
|
18
17
|
VideoFeatureInputData,
|
|
19
18
|
ProviderCapabilities,
|
|
20
19
|
} from "@umituz/react-native-ai-generation-content";
|
|
21
|
-
import type { FalQueueStatus
|
|
20
|
+
import type { FalQueueStatus } from "../../domain/entities/fal.types";
|
|
21
|
+
import { DEFAULT_FAL_CONFIG, FAL_CAPABILITIES } from "./fal-provider.constants";
|
|
22
|
+
import { mapFalStatusToJobStatus } from "./fal-status-mapper";
|
|
22
23
|
import {
|
|
23
24
|
getImageFeatureModel,
|
|
24
25
|
getVideoFeatureModel,
|
|
@@ -28,51 +29,6 @@ import {
|
|
|
28
29
|
|
|
29
30
|
declare const __DEV__: boolean;
|
|
30
31
|
|
|
31
|
-
const DEFAULT_CONFIG = {
|
|
32
|
-
maxRetries: 3,
|
|
33
|
-
baseDelay: 1000,
|
|
34
|
-
maxDelay: 10000,
|
|
35
|
-
defaultTimeoutMs: 300000,
|
|
36
|
-
pollInterval: 1000,
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const FAL_CAPABILITIES: ProviderCapabilities = {
|
|
40
|
-
imageFeatures: [
|
|
41
|
-
"upscale",
|
|
42
|
-
"photo-restore",
|
|
43
|
-
"face-swap",
|
|
44
|
-
"anime-selfie",
|
|
45
|
-
"remove-background",
|
|
46
|
-
"remove-object",
|
|
47
|
-
"hd-touch-up",
|
|
48
|
-
"replace-background",
|
|
49
|
-
] as const,
|
|
50
|
-
videoFeatures: ["ai-hug", "ai-kiss"] as const,
|
|
51
|
-
textToImage: true,
|
|
52
|
-
textToVideo: true,
|
|
53
|
-
imageToVideo: true,
|
|
54
|
-
textToVoice: true,
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
function mapFalStatusToJobStatus(status: FalQueueStatus): JobStatus {
|
|
58
|
-
const statusMap: Record<string, AIJobStatusType> = {
|
|
59
|
-
IN_QUEUE: "IN_QUEUE",
|
|
60
|
-
IN_PROGRESS: "IN_PROGRESS",
|
|
61
|
-
COMPLETED: "COMPLETED",
|
|
62
|
-
FAILED: "FAILED",
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
return {
|
|
66
|
-
status: statusMap[status.status] ?? "IN_PROGRESS",
|
|
67
|
-
logs: status.logs?.map((log: FalLogEntry) => ({
|
|
68
|
-
message: log.message,
|
|
69
|
-
level: log.level ?? "info",
|
|
70
|
-
timestamp: log.timestamp,
|
|
71
|
-
})),
|
|
72
|
-
queuePosition: status.queuePosition,
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
|
|
76
32
|
export class FalProvider implements IAIProvider {
|
|
77
33
|
readonly providerId = "fal";
|
|
78
34
|
readonly providerName = "FAL AI";
|
|
@@ -83,14 +39,14 @@ export class FalProvider implements IAIProvider {
|
|
|
83
39
|
|
|
84
40
|
initialize(configData: AIProviderConfig): void {
|
|
85
41
|
this.apiKey = configData.apiKey;
|
|
86
|
-
this.config = { ...
|
|
42
|
+
this.config = { ...DEFAULT_FAL_CONFIG, ...configData };
|
|
87
43
|
|
|
88
44
|
fal.config({
|
|
89
45
|
credentials: configData.apiKey,
|
|
90
46
|
retry: {
|
|
91
|
-
maxRetries: configData.maxRetries ??
|
|
92
|
-
baseDelay: configData.baseDelay ??
|
|
93
|
-
maxDelay: configData.maxDelay ??
|
|
47
|
+
maxRetries: configData.maxRetries ?? DEFAULT_FAL_CONFIG.maxRetries,
|
|
48
|
+
baseDelay: configData.baseDelay ?? DEFAULT_FAL_CONFIG.baseDelay,
|
|
49
|
+
maxDelay: configData.maxDelay ?? DEFAULT_FAL_CONFIG.maxDelay,
|
|
94
50
|
},
|
|
95
51
|
});
|
|
96
52
|
|
|
@@ -151,8 +107,7 @@ export class FalProvider implements IAIProvider {
|
|
|
151
107
|
options?: SubscribeOptions<T>,
|
|
152
108
|
): Promise<T> {
|
|
153
109
|
this.validateInitialization();
|
|
154
|
-
|
|
155
|
-
const timeoutMs = options?.timeoutMs ?? this.config?.defaultTimeoutMs ?? DEFAULT_CONFIG.defaultTimeoutMs;
|
|
110
|
+
const timeoutMs = options?.timeoutMs ?? this.config?.defaultTimeoutMs ?? DEFAULT_FAL_CONFIG.defaultTimeoutMs;
|
|
156
111
|
let timeoutId: ReturnType<typeof setTimeout> | null = null;
|
|
157
112
|
|
|
158
113
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
@@ -164,7 +119,7 @@ export class FalProvider implements IAIProvider {
|
|
|
164
119
|
fal.subscribe(model, {
|
|
165
120
|
input,
|
|
166
121
|
logs: true,
|
|
167
|
-
pollInterval:
|
|
122
|
+
pollInterval: DEFAULT_FAL_CONFIG.pollInterval,
|
|
168
123
|
onQueueUpdate: (update: { status: string; logs?: unknown[] }) => {
|
|
169
124
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
170
125
|
console.log("[FalProvider] Queue update:", JSON.stringify(update));
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FAL Status Mapper
|
|
3
|
+
* Maps FAL queue status to standardized job status
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { JobStatus, AIJobStatusType } from "@umituz/react-native-ai-generation-content";
|
|
7
|
+
import type { FalQueueStatus, FalLogEntry } from "../../domain/entities/fal.types";
|
|
8
|
+
|
|
9
|
+
const STATUS_MAP: Record<string, AIJobStatusType> = {
|
|
10
|
+
IN_QUEUE: "IN_QUEUE",
|
|
11
|
+
IN_PROGRESS: "IN_PROGRESS",
|
|
12
|
+
COMPLETED: "COMPLETED",
|
|
13
|
+
FAILED: "FAILED",
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export function mapFalStatusToJobStatus(status: FalQueueStatus): JobStatus {
|
|
17
|
+
return {
|
|
18
|
+
status: STATUS_MAP[status.status] ?? "IN_PROGRESS",
|
|
19
|
+
logs: status.logs?.map((log: FalLogEntry) => ({
|
|
20
|
+
message: log.message,
|
|
21
|
+
level: log.level ?? "info",
|
|
22
|
+
timestamp: log.timestamp,
|
|
23
|
+
})),
|
|
24
|
+
queuePosition: status.queuePosition,
|
|
25
|
+
};
|
|
26
|
+
}
|