@umituz/react-native-ai-generation-content 1.17.229 → 1.17.230
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/LICENSE +21 -0
- package/README.md +346 -0
- package/package.json +1 -3
- package/src/domain/README.md +503 -0
- package/src/domains/content-moderation/README.md +363 -0
- package/src/domains/creations/README.md +394 -0
- package/src/domains/face-detection/README.md +395 -0
- package/src/domains/prompts/README.md +387 -0
- package/src/features/ai-hug/README.md +276 -0
- package/src/features/ai-kiss/README.md +276 -0
- package/src/features/anime-selfie/README.md +325 -0
- package/src/features/audio-generation/README.md +370 -0
- package/src/features/colorization/README.md +289 -0
- package/src/features/couple-future/README.md +270 -0
- package/src/features/face-swap/README.md +234 -0
- package/src/features/future-prediction/README.md +281 -0
- package/src/features/hd-touch-up/README.md +309 -0
- package/src/features/image-captioning/README.md +361 -0
- package/src/features/image-to-image/README.md +418 -0
- package/src/features/image-to-video/README.md +369 -0
- package/src/features/inpainting/README.md +302 -0
- package/src/features/meme-generator/README.md +327 -0
- package/src/features/photo-restoration/README.md +286 -0
- package/src/features/remove-background/README.md +292 -0
- package/src/features/remove-object/README.md +352 -0
- package/src/features/replace-background/README.md +288 -0
- package/src/features/script-generator/README.md +362 -0
- package/src/features/shared/README.md +280 -0
- package/src/features/sketch-to-image/README.md +296 -0
- package/src/features/style-transfer/README.md +301 -0
- package/src/features/text-to-image/README.md +228 -0
- package/src/features/text-to-video/README.md +245 -0
- package/src/features/text-to-voice/README.md +335 -0
- package/src/features/upscaling/README.md +247 -0
- package/src/infrastructure/config/README.md +310 -0
- package/src/infrastructure/middleware/README.md +378 -0
- package/src/infrastructure/orchestration/README.md +362 -0
- package/src/infrastructure/services/README.md +382 -0
- package/src/infrastructure/utils/README.md +523 -0
- package/src/infrastructure/wrappers/README.md +336 -0
- package/src/presentation/components/README.md +535 -0
- package/src/presentation/hooks/README.md +380 -0
- package/src/presentation/layouts/README.md +374 -0
- package/src/presentation/screens/README.md +430 -0
- package/src/presentation/layouts/types/.npmignore.tmp +0 -0
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
# Infrastructure Services
|
|
2
|
+
|
|
3
|
+
Core AI generation services.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The services module provides the core AI generation services that power all features. These services handle communication with AI providers, manage generation requests, and process responses.
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- Image generation (text-to-image, image-to-image)
|
|
12
|
+
- Video generation (text-to-video, image-to-video)
|
|
13
|
+
- Audio generation (text-to-voice)
|
|
14
|
+
- Face operations (swap, detection)
|
|
15
|
+
- Image enhancement (restoration, upscaling, etc.)
|
|
16
|
+
|
|
17
|
+
## Core Services
|
|
18
|
+
|
|
19
|
+
### Image Generation Services
|
|
20
|
+
|
|
21
|
+
#### executeImageFeature
|
|
22
|
+
|
|
23
|
+
Execute image-based AI features:
|
|
24
|
+
|
|
25
|
+
```tsx
|
|
26
|
+
import { executeImageFeature } from '@umituz/react-native-ai-generation-content';
|
|
27
|
+
|
|
28
|
+
const result = await executeImageFeature({
|
|
29
|
+
featureType: 'text-to-image',
|
|
30
|
+
inputData: {
|
|
31
|
+
prompt: 'A beautiful sunset over mountains',
|
|
32
|
+
style: 'realistic',
|
|
33
|
+
aspectRatio: '16:9',
|
|
34
|
+
},
|
|
35
|
+
userId: 'user-123',
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
if (result.success) {
|
|
39
|
+
console.log('Generated image:', result.imageUrl);
|
|
40
|
+
} else {
|
|
41
|
+
console.error('Error:', result.error);
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
#### hasImageFeatureSupport
|
|
46
|
+
|
|
47
|
+
Check if an image feature is supported:
|
|
48
|
+
|
|
49
|
+
```tsx
|
|
50
|
+
import { hasImageFeatureSupport } from '@umituz/react-native-ai-generation-content';
|
|
51
|
+
|
|
52
|
+
if (hasImageFeatureSupport('text-to-image')) {
|
|
53
|
+
// Feature is supported
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Video Generation Services
|
|
58
|
+
|
|
59
|
+
#### executeVideoFeature
|
|
60
|
+
|
|
61
|
+
Execute video-based AI features:
|
|
62
|
+
|
|
63
|
+
```tsx
|
|
64
|
+
import { executeVideoFeature } from '@umituz/react-native-ai-generation-content';
|
|
65
|
+
|
|
66
|
+
const result = await executeVideoFeature({
|
|
67
|
+
featureType: 'text-to-video',
|
|
68
|
+
inputData: {
|
|
69
|
+
prompt: 'A drone flying over a forest',
|
|
70
|
+
duration: 5,
|
|
71
|
+
aspectRatio: '16:9',
|
|
72
|
+
},
|
|
73
|
+
userId: 'user-123',
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
if (result.success) {
|
|
77
|
+
console.log('Generated video:', result.videoUrl);
|
|
78
|
+
console.log('Thumbnail:', result.thumbnailUrl);
|
|
79
|
+
} else {
|
|
80
|
+
console.error('Error:', result.error);
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
#### hasVideoFeatureSupport
|
|
85
|
+
|
|
86
|
+
Check if a video feature is supported:
|
|
87
|
+
|
|
88
|
+
```tsx
|
|
89
|
+
import { hasVideoFeatureSupport } from '@umituz/react-native-ai-generation-content';
|
|
90
|
+
|
|
91
|
+
if (hasVideoFeatureSupport('text-to-video')) {
|
|
92
|
+
// Feature is supported
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Feature Types
|
|
97
|
+
|
|
98
|
+
### Image Features
|
|
99
|
+
|
|
100
|
+
```tsx
|
|
101
|
+
type ImageFeatureType =
|
|
102
|
+
| 'text-to-image'
|
|
103
|
+
| 'face-swap'
|
|
104
|
+
| 'photo-restoration'
|
|
105
|
+
| 'upscaling'
|
|
106
|
+
| 'style-transfer'
|
|
107
|
+
| 'remove-background'
|
|
108
|
+
| 'replace-background'
|
|
109
|
+
| 'remove-object'
|
|
110
|
+
| 'inpainting'
|
|
111
|
+
| 'colorization'
|
|
112
|
+
| 'hd-touch-up'
|
|
113
|
+
| 'image-to-image';
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Video Features
|
|
117
|
+
|
|
118
|
+
```tsx
|
|
119
|
+
type VideoFeatureType =
|
|
120
|
+
| 'text-to-video'
|
|
121
|
+
| 'image-to-video';
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Input Data Types
|
|
125
|
+
|
|
126
|
+
### ImageFeatureInputData
|
|
127
|
+
|
|
128
|
+
```tsx
|
|
129
|
+
interface ImageFeatureInputData {
|
|
130
|
+
prompt?: string;
|
|
131
|
+
imageBase64?: string;
|
|
132
|
+
targetImageBase64?: string; // For dual-image features
|
|
133
|
+
options?: Record<string, any>;
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### VideoFeatureInputData
|
|
138
|
+
|
|
139
|
+
```tsx
|
|
140
|
+
interface VideoFeatureInputData {
|
|
141
|
+
prompt?: string;
|
|
142
|
+
imageBase64?: string;
|
|
143
|
+
videoBase64?: string;
|
|
144
|
+
duration?: number;
|
|
145
|
+
aspectRatio?: string;
|
|
146
|
+
options?: Record<string, any>;
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## Result Types
|
|
151
|
+
|
|
152
|
+
### ImageFeatureResult
|
|
153
|
+
|
|
154
|
+
```tsx
|
|
155
|
+
interface ImageFeatureResult {
|
|
156
|
+
success: boolean;
|
|
157
|
+
imageUrl?: string;
|
|
158
|
+
imageUrls?: string[];
|
|
159
|
+
thumbnailUrl?: string;
|
|
160
|
+
metadata?: {
|
|
161
|
+
prompt: string;
|
|
162
|
+
model: string;
|
|
163
|
+
timestamp: string;
|
|
164
|
+
[key: string]: any;
|
|
165
|
+
};
|
|
166
|
+
error?: string;
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### VideoFeatureResult
|
|
171
|
+
|
|
172
|
+
```tsx
|
|
173
|
+
interface VideoFeatureResult {
|
|
174
|
+
success: boolean;
|
|
175
|
+
videoUrl?: string;
|
|
176
|
+
thumbnailUrl?: string;
|
|
177
|
+
duration?: number;
|
|
178
|
+
metadata?: {
|
|
179
|
+
prompt: string;
|
|
180
|
+
model: string;
|
|
181
|
+
timestamp: string;
|
|
182
|
+
[key: string]: any;
|
|
183
|
+
};
|
|
184
|
+
error?: string;
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
## Execution Options
|
|
189
|
+
|
|
190
|
+
### ExecuteImageFeatureOptions
|
|
191
|
+
|
|
192
|
+
```tsx
|
|
193
|
+
interface ExecuteImageFeatureOptions {
|
|
194
|
+
featureType: ImageFeatureType;
|
|
195
|
+
inputData: ImageFeatureInputData;
|
|
196
|
+
userId: string;
|
|
197
|
+
providerId?: string;
|
|
198
|
+
onProgress?: (progress: number) => void;
|
|
199
|
+
timeout?: number;
|
|
200
|
+
}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### ExecuteVideoFeatureOptions
|
|
204
|
+
|
|
205
|
+
```tsx
|
|
206
|
+
interface ExecuteVideoFeatureOptions {
|
|
207
|
+
featureType: VideoFeatureType;
|
|
208
|
+
inputData: VideoFeatureInputData;
|
|
209
|
+
userId: string;
|
|
210
|
+
providerId?: string;
|
|
211
|
+
onProgress?: (progress: number) => void;
|
|
212
|
+
timeout?: number;
|
|
213
|
+
}
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
## Usage Examples
|
|
217
|
+
|
|
218
|
+
### Text to Image
|
|
219
|
+
|
|
220
|
+
```tsx
|
|
221
|
+
const result = await executeImageFeature({
|
|
222
|
+
featureType: 'text-to-image',
|
|
223
|
+
inputData: {
|
|
224
|
+
prompt: 'A majestic lion in the savanna',
|
|
225
|
+
style: 'realistic',
|
|
226
|
+
aspectRatio: '16:9',
|
|
227
|
+
numberOfImages: 1,
|
|
228
|
+
},
|
|
229
|
+
userId: 'user-123',
|
|
230
|
+
});
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### Face Swap
|
|
234
|
+
|
|
235
|
+
```tsx
|
|
236
|
+
const result = await executeImageFeature({
|
|
237
|
+
featureType: 'face-swap',
|
|
238
|
+
inputData: {
|
|
239
|
+
imageBase64: sourceImage,
|
|
240
|
+
targetImageBase64: targetImage,
|
|
241
|
+
options: {
|
|
242
|
+
enhanceFace: true,
|
|
243
|
+
matchSkinTone: true,
|
|
244
|
+
},
|
|
245
|
+
},
|
|
246
|
+
userId: 'user-123',
|
|
247
|
+
});
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
### Photo Restoration
|
|
251
|
+
|
|
252
|
+
```tsx
|
|
253
|
+
const result = await executeImageFeature({
|
|
254
|
+
featureType: 'photo-restoration',
|
|
255
|
+
inputData: {
|
|
256
|
+
imageBase64: oldPhoto,
|
|
257
|
+
options: {
|
|
258
|
+
restorationType: 'auto',
|
|
259
|
+
removeScratches: true,
|
|
260
|
+
fixBlur: true,
|
|
261
|
+
},
|
|
262
|
+
},
|
|
263
|
+
userId: 'user-123',
|
|
264
|
+
});
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
### Text to Video
|
|
268
|
+
|
|
269
|
+
```tsx
|
|
270
|
+
const result = await executeVideoFeature({
|
|
271
|
+
featureType: 'text-to-video',
|
|
272
|
+
inputData: {
|
|
273
|
+
prompt: 'A futuristic city at night',
|
|
274
|
+
duration: 5,
|
|
275
|
+
aspectRatio: '16:9',
|
|
276
|
+
style: 'cinematic',
|
|
277
|
+
},
|
|
278
|
+
userId: 'user-123',
|
|
279
|
+
});
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
### Image to Video
|
|
283
|
+
|
|
284
|
+
```tsx
|
|
285
|
+
const result = await executeVideoFeature({
|
|
286
|
+
featureType: 'image-to-video',
|
|
287
|
+
inputData: {
|
|
288
|
+
imageBase64: staticImage,
|
|
289
|
+
motionType: 'zoom-in',
|
|
290
|
+
duration: 4,
|
|
291
|
+
},
|
|
292
|
+
userId: 'user-123',
|
|
293
|
+
});
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
## Progress Tracking
|
|
297
|
+
|
|
298
|
+
```tsx
|
|
299
|
+
const result = await executeImageFeature({
|
|
300
|
+
featureType: 'text-to-image',
|
|
301
|
+
inputData: { prompt: 'A sunset' },
|
|
302
|
+
userId: 'user-123',
|
|
303
|
+
onProgress: (progress) => {
|
|
304
|
+
console.log(`Progress: ${progress}%`);
|
|
305
|
+
// Update UI progress bar
|
|
306
|
+
},
|
|
307
|
+
});
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
## Error Handling
|
|
311
|
+
|
|
312
|
+
```tsx
|
|
313
|
+
try {
|
|
314
|
+
const result = await executeImageFeature({
|
|
315
|
+
featureType: 'text-to-image',
|
|
316
|
+
inputData: { prompt: 'A sunset' },
|
|
317
|
+
userId: 'user-123',
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
if (!result.success) {
|
|
321
|
+
// Handle error
|
|
322
|
+
console.error('Generation failed:', result.error);
|
|
323
|
+
Alert.alert('Error', result.error);
|
|
324
|
+
} else {
|
|
325
|
+
// Success
|
|
326
|
+
console.log('Image generated:', result.imageUrl);
|
|
327
|
+
}
|
|
328
|
+
} catch (error) {
|
|
329
|
+
// Handle unexpected errors
|
|
330
|
+
console.error('Unexpected error:', error);
|
|
331
|
+
}
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
## Provider Selection
|
|
335
|
+
|
|
336
|
+
```tsx
|
|
337
|
+
// Use specific provider
|
|
338
|
+
const result = await executeImageFeature({
|
|
339
|
+
featureType: 'text-to-image',
|
|
340
|
+
inputData: { prompt: 'A sunset' },
|
|
341
|
+
userId: 'user-123',
|
|
342
|
+
providerId: 'openai', // Use OpenAI provider
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
// Or let system choose based on capabilities
|
|
346
|
+
const result = await executeImageFeature({
|
|
347
|
+
featureType: 'text-to-image',
|
|
348
|
+
inputData: { prompt: 'A sunset' },
|
|
349
|
+
userId: 'user-123',
|
|
350
|
+
// No providerId - system will choose best provider
|
|
351
|
+
});
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
## Timeout Handling
|
|
355
|
+
|
|
356
|
+
```tsx
|
|
357
|
+
const result = await executeImageFeature({
|
|
358
|
+
featureType: 'text-to-image',
|
|
359
|
+
inputData: { prompt: 'A sunset' },
|
|
360
|
+
userId: 'user-123',
|
|
361
|
+
timeout: 60000, // 60 second timeout
|
|
362
|
+
});
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
## Best Practices
|
|
366
|
+
|
|
367
|
+
1. **Error Handling**: Always check result.success
|
|
368
|
+
2. **Progress Tracking**: Use onProgress for long-running operations
|
|
369
|
+
3. **Timeout**: Set appropriate timeouts for each feature
|
|
370
|
+
4. **Provider Selection**: Let system choose unless you need specific provider
|
|
371
|
+
5. **Type Safety**: Use proper input data types
|
|
372
|
+
|
|
373
|
+
## Related
|
|
374
|
+
|
|
375
|
+
- [Config](../config/) - Service configuration
|
|
376
|
+
- [Middleware](../middleware/) - Request/response middleware
|
|
377
|
+
- [Orchestration](../orchestration/) - Generation orchestration
|
|
378
|
+
- [Utils](../utils/) - Utility functions
|
|
379
|
+
|
|
380
|
+
## License
|
|
381
|
+
|
|
382
|
+
MIT
|