@umituz/react-native-ai-generation-content 1.17.113 → 1.17.115
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 +1 -1
- package/src/domain/interfaces/ai-provider.interface.ts +50 -3
- package/src/domains/face-detection/index.ts +1 -1
- package/src/features/image-to-video/infrastructure/services/image-to-video-executor.ts +2 -2
- package/src/features/script-generator/infrastructure/services/ScriptGenerationService.ts +1 -1
- package/src/features/text-to-image/infrastructure/services/text-to-image-executor.ts +47 -18
- package/src/features/text-to-video/infrastructure/services/text-to-video-executor.ts +4 -3
- package/src/index.ts +2 -0
package/package.json
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* AI Provider Interface
|
|
3
3
|
* Provider-agnostic interface for AI generation services
|
|
4
|
-
* Implementations: FAL, Gemini, etc.
|
|
5
4
|
*/
|
|
6
5
|
|
|
7
6
|
export interface AIProviderConfig {
|
|
@@ -16,6 +15,40 @@ export interface AIProviderConfig {
|
|
|
16
15
|
textToImageModel?: string;
|
|
17
16
|
/** Image editing model ID */
|
|
18
17
|
imageEditModel?: string;
|
|
18
|
+
/** Video generation model ID */
|
|
19
|
+
videoGenerationModel?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Provider-level progress info for run/subscribe operations
|
|
24
|
+
*/
|
|
25
|
+
export interface ProviderProgressInfo {
|
|
26
|
+
/** Progress percentage (0-100) */
|
|
27
|
+
progress: number;
|
|
28
|
+
/** Current job status */
|
|
29
|
+
status?: AIJobStatusType;
|
|
30
|
+
/** Human-readable message */
|
|
31
|
+
message?: string;
|
|
32
|
+
/** Estimated time remaining in ms */
|
|
33
|
+
estimatedTimeRemaining?: number;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Provider capabilities and metadata
|
|
38
|
+
*/
|
|
39
|
+
export interface ProviderCapabilities {
|
|
40
|
+
/** Supported image features */
|
|
41
|
+
imageFeatures: readonly ImageFeatureType[];
|
|
42
|
+
/** Supported video features */
|
|
43
|
+
videoFeatures: readonly VideoFeatureType[];
|
|
44
|
+
/** Supports text-to-image generation */
|
|
45
|
+
textToImage: boolean;
|
|
46
|
+
/** Supports text-to-video generation */
|
|
47
|
+
textToVideo: boolean;
|
|
48
|
+
/** Supports image-to-video generation */
|
|
49
|
+
imageToVideo: boolean;
|
|
50
|
+
/** Supports text-to-voice generation */
|
|
51
|
+
textToVoice: boolean;
|
|
19
52
|
}
|
|
20
53
|
|
|
21
54
|
export interface JobSubmission {
|
|
@@ -46,12 +79,12 @@ export interface AILogEntry {
|
|
|
46
79
|
export interface SubscribeOptions<T = unknown> {
|
|
47
80
|
timeoutMs?: number;
|
|
48
81
|
onQueueUpdate?: (status: JobStatus) => void;
|
|
49
|
-
onProgress?: (progress:
|
|
82
|
+
onProgress?: (progress: ProviderProgressInfo) => void;
|
|
50
83
|
onResult?: (result: T) => void;
|
|
51
84
|
}
|
|
52
85
|
|
|
53
86
|
export interface RunOptions {
|
|
54
|
-
onProgress?: (progress:
|
|
87
|
+
onProgress?: (progress: ProviderProgressInfo) => void;
|
|
55
88
|
}
|
|
56
89
|
|
|
57
90
|
/**
|
|
@@ -105,6 +138,16 @@ export interface IAIProvider {
|
|
|
105
138
|
initialize(config: AIProviderConfig): void;
|
|
106
139
|
isInitialized(): boolean;
|
|
107
140
|
|
|
141
|
+
/**
|
|
142
|
+
* Get provider capabilities
|
|
143
|
+
*/
|
|
144
|
+
getCapabilities(): ProviderCapabilities;
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Check if a specific feature is supported
|
|
148
|
+
*/
|
|
149
|
+
isFeatureSupported(feature: ImageFeatureType | VideoFeatureType): boolean;
|
|
150
|
+
|
|
108
151
|
submitJob(
|
|
109
152
|
model: string,
|
|
110
153
|
input: Record<string, unknown>,
|
|
@@ -130,11 +173,13 @@ export interface IAIProvider {
|
|
|
130
173
|
|
|
131
174
|
/**
|
|
132
175
|
* Get model ID for an image feature
|
|
176
|
+
* @throws Error if feature is not supported
|
|
133
177
|
*/
|
|
134
178
|
getImageFeatureModel(feature: ImageFeatureType): string;
|
|
135
179
|
|
|
136
180
|
/**
|
|
137
181
|
* Build provider-specific input for an image feature
|
|
182
|
+
* @throws Error if feature is not supported
|
|
138
183
|
*/
|
|
139
184
|
buildImageFeatureInput(
|
|
140
185
|
feature: ImageFeatureType,
|
|
@@ -143,11 +188,13 @@ export interface IAIProvider {
|
|
|
143
188
|
|
|
144
189
|
/**
|
|
145
190
|
* Get model ID for a video feature
|
|
191
|
+
* @throws Error if feature is not supported
|
|
146
192
|
*/
|
|
147
193
|
getVideoFeatureModel(feature: VideoFeatureType): string;
|
|
148
194
|
|
|
149
195
|
/**
|
|
150
196
|
* Build provider-specific input for a video feature
|
|
197
|
+
* @throws Error if feature is not supported
|
|
151
198
|
*/
|
|
152
199
|
buildVideoFeatureInput(
|
|
153
200
|
feature: VideoFeatureType,
|
|
@@ -66,7 +66,7 @@ export async function executeImageToVideo(
|
|
|
66
66
|
|
|
67
67
|
const { model, buildInput, extractResult, onProgress } = options;
|
|
68
68
|
|
|
69
|
-
if (__DEV__) {
|
|
69
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
70
70
|
// eslint-disable-next-line no-console
|
|
71
71
|
console.log(`[ImageToVideo] Provider: ${provider.providerId}, Model: ${model}`);
|
|
72
72
|
}
|
|
@@ -98,7 +98,7 @@ export async function executeImageToVideo(
|
|
|
98
98
|
};
|
|
99
99
|
} catch (error) {
|
|
100
100
|
const message = error instanceof Error ? error.message : String(error);
|
|
101
|
-
if (__DEV__) {
|
|
101
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
102
102
|
// eslint-disable-next-line no-console
|
|
103
103
|
console.error("[ImageToVideo] Error:", message);
|
|
104
104
|
}
|
|
@@ -53,7 +53,7 @@ Format as JSON with this structure:
|
|
|
53
53
|
async generateScript(
|
|
54
54
|
_request: ScriptGenerationRequest,
|
|
55
55
|
): Promise<readonly ScriptSection[] | null> {
|
|
56
|
-
// NOTE: This will be implemented by the app using a specific AI provider
|
|
56
|
+
// NOTE: This will be implemented by the app using a specific AI provider
|
|
57
57
|
// The package provides the structure and prompt building.
|
|
58
58
|
return null;
|
|
59
59
|
}
|
|
@@ -23,29 +23,32 @@ export interface ExecuteTextToImageOptions {
|
|
|
23
23
|
function defaultExtractResult(
|
|
24
24
|
result: unknown,
|
|
25
25
|
): { imageUrl?: string; imageUrls?: string[] } | undefined {
|
|
26
|
-
if (typeof
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
// GeminiClient returns imageUrl (data URL) or imageBase64
|
|
31
|
-
if (typeof r.imageUrl === "string") {
|
|
32
|
-
return { imageUrl: r.imageUrl, imageUrls: [r.imageUrl] };
|
|
26
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
27
|
+
// eslint-disable-next-line no-console
|
|
28
|
+
console.log("[TextToImage] defaultExtractResult input:", JSON.stringify(result, null, 2));
|
|
33
29
|
}
|
|
34
30
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
31
|
+
if (typeof result !== "object" || result === null) {
|
|
32
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
33
|
+
// eslint-disable-next-line no-console
|
|
34
|
+
console.log("[TextToImage] Result is not an object");
|
|
35
|
+
}
|
|
36
|
+
return undefined;
|
|
40
37
|
}
|
|
41
38
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
39
|
+
const r = result as Record<string, unknown>;
|
|
40
|
+
|
|
41
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
42
|
+
// eslint-disable-next-line no-console
|
|
43
|
+
console.log("[TextToImage] Result keys:", Object.keys(r));
|
|
45
44
|
}
|
|
46
45
|
|
|
47
|
-
//
|
|
46
|
+
// Check for 'images' array first (most common response format)
|
|
48
47
|
if (Array.isArray(r.images)) {
|
|
48
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
49
|
+
// eslint-disable-next-line no-console
|
|
50
|
+
console.log("[TextToImage] Found images array:", r.images.length, "items");
|
|
51
|
+
}
|
|
49
52
|
const urls = r.images
|
|
50
53
|
.map((img) => {
|
|
51
54
|
if (typeof img === "string") return img;
|
|
@@ -57,10 +60,36 @@ function defaultExtractResult(
|
|
|
57
60
|
.filter((url): url is string => url !== null);
|
|
58
61
|
|
|
59
62
|
if (urls.length > 0) {
|
|
63
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
64
|
+
// eslint-disable-next-line no-console
|
|
65
|
+
console.log("[TextToImage] Extracted URLs:", urls);
|
|
66
|
+
}
|
|
60
67
|
return { imageUrl: urls[0], imageUrls: urls };
|
|
61
68
|
}
|
|
62
69
|
}
|
|
63
70
|
|
|
71
|
+
// Check for imageUrl (data URL)
|
|
72
|
+
if (typeof r.imageUrl === "string") {
|
|
73
|
+
return { imageUrl: r.imageUrl, imageUrls: [r.imageUrl] };
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Fallback: construct data URL from imageBase64
|
|
77
|
+
if (typeof r.imageBase64 === "string") {
|
|
78
|
+
const mimeType = typeof r.mimeType === "string" ? r.mimeType : "image/png";
|
|
79
|
+
const dataUrl = `data:${mimeType};base64,${r.imageBase64}`;
|
|
80
|
+
return { imageUrl: dataUrl, imageUrls: [dataUrl] };
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Legacy: check for 'image' field
|
|
84
|
+
if (typeof r.image === "string") {
|
|
85
|
+
return { imageUrl: r.image, imageUrls: [r.image] };
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
89
|
+
// eslint-disable-next-line no-console
|
|
90
|
+
console.log("[TextToImage] No image found in result");
|
|
91
|
+
}
|
|
92
|
+
|
|
64
93
|
return undefined;
|
|
65
94
|
}
|
|
66
95
|
|
|
@@ -84,7 +113,7 @@ export async function executeTextToImage(
|
|
|
84
113
|
|
|
85
114
|
const { model, buildInput, extractResult, onProgress } = options;
|
|
86
115
|
|
|
87
|
-
if (__DEV__) {
|
|
116
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
88
117
|
// eslint-disable-next-line no-console
|
|
89
118
|
console.log(`[TextToImage] Provider: ${provider.providerId}, Model: ${model}`);
|
|
90
119
|
}
|
|
@@ -113,7 +142,7 @@ export async function executeTextToImage(
|
|
|
113
142
|
};
|
|
114
143
|
} catch (error) {
|
|
115
144
|
const message = error instanceof Error ? error.message : String(error);
|
|
116
|
-
if (__DEV__) {
|
|
145
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
117
146
|
// eslint-disable-next-line no-console
|
|
118
147
|
console.error("[TextToImage] Error:", message);
|
|
119
148
|
}
|
|
@@ -93,12 +93,13 @@ export async function executeTextToVideo(
|
|
|
93
93
|
const input = buildInput(request.prompt, request.options);
|
|
94
94
|
|
|
95
95
|
const result = await provider.run(model, input, {
|
|
96
|
-
onProgress: (
|
|
96
|
+
onProgress: (progressInfo) => {
|
|
97
|
+
const progressValue = progressInfo.progress;
|
|
97
98
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
98
99
|
// eslint-disable-next-line no-console
|
|
99
|
-
console.log("[TextToVideoExecutor] Progress:",
|
|
100
|
+
console.log("[TextToVideoExecutor] Progress:", progressValue);
|
|
100
101
|
}
|
|
101
|
-
onProgress?.(
|
|
102
|
+
onProgress?.(progressValue);
|
|
102
103
|
},
|
|
103
104
|
});
|
|
104
105
|
|