@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,336 @@
|
|
|
1
|
+
# Infrastructure Wrappers
|
|
2
|
+
|
|
3
|
+
Wrapper utilities and enhancements for AI generation operations.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The wrappers module provides wrapper utilities that add additional functionality to core AI generation operations, such as language enhancement, moderation, and synchronous execution.
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- Language enhancement for prompts
|
|
12
|
+
- Content moderation wrapper
|
|
13
|
+
- Synchronous generation support
|
|
14
|
+
- Prompt augmentation
|
|
15
|
+
- Result filtering
|
|
16
|
+
|
|
17
|
+
## Language Enhancement
|
|
18
|
+
|
|
19
|
+
### enhancePromptWithLanguage
|
|
20
|
+
|
|
21
|
+
Enhance prompts with language support:
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import { enhancePromptWithLanguage } from '@umituz/react-native-ai-generation-content';
|
|
25
|
+
|
|
26
|
+
// Enhance prompt for better results
|
|
27
|
+
const enhanced = enhancePromptWithLanguage({
|
|
28
|
+
prompt: 'A beautiful sunset',
|
|
29
|
+
targetLanguage: 'en', // Translate to English first
|
|
30
|
+
enhance: true, // Add descriptive details
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
console.log('Enhanced prompt:', enhanced);
|
|
34
|
+
// "A beautiful sunset over the ocean with vibrant orange and pink colors,
|
|
35
|
+
// captured during golden hour with dramatic cloud formations"
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### getSupportedLanguages
|
|
39
|
+
|
|
40
|
+
Get list of supported languages:
|
|
41
|
+
|
|
42
|
+
```tsx
|
|
43
|
+
import { getSupportedLanguages } from '@umituz/react-native-ai-generation-content';
|
|
44
|
+
|
|
45
|
+
const languages = getSupportedLanguages();
|
|
46
|
+
console.log('Supported languages:', languages);
|
|
47
|
+
// [
|
|
48
|
+
// { code: 'en', name: 'English' },
|
|
49
|
+
// { code: 'es', name: 'Spanish' },
|
|
50
|
+
// { code: 'fr', name: 'French' },
|
|
51
|
+
// ...
|
|
52
|
+
// ]
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### getLanguageName
|
|
56
|
+
|
|
57
|
+
Get language name from code:
|
|
58
|
+
|
|
59
|
+
```tsx
|
|
60
|
+
import { getLanguageName } from '@umituz/react-native-ai-generation-content';
|
|
61
|
+
|
|
62
|
+
const name = getLanguageName('es');
|
|
63
|
+
console.log('Language:', name); // "Spanish"
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Content Moderation
|
|
67
|
+
|
|
68
|
+
### ModerationWrapper
|
|
69
|
+
|
|
70
|
+
Wrap generation with content moderation:
|
|
71
|
+
|
|
72
|
+
```tsx
|
|
73
|
+
import { ModerationWrapper } from '@umituz/react-native-ai-generation-content';
|
|
74
|
+
|
|
75
|
+
const wrapper = new ModerationWrapper({
|
|
76
|
+
enabled: true,
|
|
77
|
+
rules: [
|
|
78
|
+
{
|
|
79
|
+
id: 'no-violence',
|
|
80
|
+
category: 'violence',
|
|
81
|
+
severity: 'high',
|
|
82
|
+
enabled: true,
|
|
83
|
+
action: 'block',
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
id: 'no-adult',
|
|
87
|
+
category: 'sexual',
|
|
88
|
+
severity: 'high',
|
|
89
|
+
enabled: true,
|
|
90
|
+
action: 'block',
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
onViolation: (result) => {
|
|
94
|
+
Alert.alert('Content Warning', result.warning, [
|
|
95
|
+
{ text: 'OK', onPress: () => console.log('Acknowledged') },
|
|
96
|
+
]);
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// Wrap generation
|
|
101
|
+
const wrapped = wrapper.wrap({
|
|
102
|
+
type: 'text-to-image',
|
|
103
|
+
generate: async (input) => {
|
|
104
|
+
return await generateImage(input);
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
// Execute with moderation
|
|
109
|
+
const result = await wrapped.generate({
|
|
110
|
+
prompt: 'Your prompt here',
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
if (result.isModerated) {
|
|
114
|
+
console.log('Content was moderated');
|
|
115
|
+
console.log('Violations:', result.violations);
|
|
116
|
+
} else {
|
|
117
|
+
console.log('Content is safe:', result.output);
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Moderation Result
|
|
122
|
+
|
|
123
|
+
```tsx
|
|
124
|
+
interface ModerationResult {
|
|
125
|
+
isSafe: boolean;
|
|
126
|
+
isModerated: boolean;
|
|
127
|
+
violations: {
|
|
128
|
+
category: string;
|
|
129
|
+
severity: 'low' | 'medium' | 'high';
|
|
130
|
+
confidence: number;
|
|
131
|
+
}[];
|
|
132
|
+
warning?: string;
|
|
133
|
+
output?: any;
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Synchronous Generation
|
|
138
|
+
|
|
139
|
+
### generateSynchronously
|
|
140
|
+
|
|
141
|
+
Generate content synchronously (blocks until complete):
|
|
142
|
+
|
|
143
|
+
```tsx
|
|
144
|
+
import { generateSynchronously } from '@umituz/react-native-ai-generation-content';
|
|
145
|
+
|
|
146
|
+
// ⚠️ Warning: This blocks the thread
|
|
147
|
+
const result = await generateSynchronously({
|
|
148
|
+
featureType: 'text-to-image',
|
|
149
|
+
inputData: {
|
|
150
|
+
prompt: 'A sunset',
|
|
151
|
+
},
|
|
152
|
+
userId: 'user-123',
|
|
153
|
+
timeout: 30000, // 30 second timeout
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
console.log('Result:', result);
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
**⚠️ Use with caution**: Synchronous generation blocks the UI thread. Only use for:
|
|
160
|
+
- Testing
|
|
161
|
+
- Very fast operations
|
|
162
|
+
- Background workers
|
|
163
|
+
|
|
164
|
+
### SynchronousGenerationConfig
|
|
165
|
+
|
|
166
|
+
```tsx
|
|
167
|
+
interface SynchronousGenerationConfig {
|
|
168
|
+
featureType: string;
|
|
169
|
+
inputData: any;
|
|
170
|
+
userId: string;
|
|
171
|
+
providerId?: string;
|
|
172
|
+
timeout?: number;
|
|
173
|
+
onProgress?: (progress: number) => void;
|
|
174
|
+
}
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Prompt Augmentation
|
|
178
|
+
|
|
179
|
+
### Auto-Enhance Prompts
|
|
180
|
+
|
|
181
|
+
Automatically enhance prompts for better results:
|
|
182
|
+
|
|
183
|
+
```tsx
|
|
184
|
+
import { ModerationWrapper } from '@umituz/react-native-ai-generation-content';
|
|
185
|
+
|
|
186
|
+
const wrapper = new ModerationWrapper({
|
|
187
|
+
enabled: true,
|
|
188
|
+
autoEnhance: true,
|
|
189
|
+
enhancementOptions: {
|
|
190
|
+
addDetail: true,
|
|
191
|
+
addStyle: true,
|
|
192
|
+
improveGrammar: true,
|
|
193
|
+
},
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
const enhanced = await wrapper.enhancePrompt('A cat');
|
|
197
|
+
// "A highly detailed, professional photograph of a beautiful cat,
|
|
198
|
+
// with perfect lighting and composition, captured with a DSLR camera"
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### Style Prompts
|
|
202
|
+
|
|
203
|
+
Add style to prompts:
|
|
204
|
+
|
|
205
|
+
```tsx
|
|
206
|
+
import { enhancePromptWithLanguage } from '@umituz/react-native-ai-generation-content';
|
|
207
|
+
|
|
208
|
+
const styled = enhancePromptWithLanguage({
|
|
209
|
+
prompt: 'A sunset',
|
|
210
|
+
style: 'photorealistic',
|
|
211
|
+
quality: 'high',
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
// "A photorealistic, high-quality image of a sunset over the ocean,
|
|
215
|
+
// with dramatic lighting and vivid colors"
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
## Result Filtering
|
|
219
|
+
|
|
220
|
+
### FilterResults
|
|
221
|
+
|
|
222
|
+
Filter and clean generation results:
|
|
223
|
+
|
|
224
|
+
```tsx
|
|
225
|
+
import { ModerationWrapper } from '@umituz/react-native-ai-generation-content';
|
|
226
|
+
|
|
227
|
+
const wrapper = new ModerationWrapper({
|
|
228
|
+
enabled: true,
|
|
229
|
+
filterResults: true,
|
|
230
|
+
filterOptions: {
|
|
231
|
+
removeDuplicates: true,
|
|
232
|
+
qualityThreshold: 0.7,
|
|
233
|
+
maxResults: 4,
|
|
234
|
+
},
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
const filtered = await wrapper.filterResults(results);
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## Usage Examples
|
|
241
|
+
|
|
242
|
+
### Complete Moderation Setup
|
|
243
|
+
|
|
244
|
+
```tsx
|
|
245
|
+
import { ModerationWrapper } from '@umituz/react-native-ai-generation-content';
|
|
246
|
+
|
|
247
|
+
const wrapper = new ModerationWrapper({
|
|
248
|
+
enabled: true,
|
|
249
|
+
autoEnhance: true,
|
|
250
|
+
rules: [
|
|
251
|
+
{
|
|
252
|
+
id: 'safety',
|
|
253
|
+
category: 'violence',
|
|
254
|
+
severity: 'high',
|
|
255
|
+
enabled: true,
|
|
256
|
+
action: 'block',
|
|
257
|
+
},
|
|
258
|
+
],
|
|
259
|
+
onViolation: (result) => {
|
|
260
|
+
Alert.alert('Content Warning', result.warning);
|
|
261
|
+
},
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
const generateWithModeration = wrapper.wrap({
|
|
265
|
+
type: 'text-to-image',
|
|
266
|
+
generate: async (input) => {
|
|
267
|
+
return await generateImage(input);
|
|
268
|
+
},
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
// Use wrapped generation
|
|
272
|
+
const result = await generateWithModeration({
|
|
273
|
+
prompt: userInput,
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
if (result.isSafe) {
|
|
277
|
+
setImage(result.output.imageUrl);
|
|
278
|
+
} else {
|
|
279
|
+
showWarning(result.violations);
|
|
280
|
+
}
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
### Multi-Language Support
|
|
284
|
+
|
|
285
|
+
```tsx
|
|
286
|
+
import { enhancePromptWithLanguage } from '@umituz/react-native-ai-generation-content';
|
|
287
|
+
|
|
288
|
+
// User enters prompt in Spanish
|
|
289
|
+
const userPrompt = 'Un hermoso atardecer';
|
|
290
|
+
|
|
291
|
+
// Enhance and translate to English for AI
|
|
292
|
+
const enhanced = enhancePromptWithLanguage({
|
|
293
|
+
prompt: userPrompt,
|
|
294
|
+
targetLanguage: 'en',
|
|
295
|
+
enhance: true,
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
// Use enhanced prompt for generation
|
|
299
|
+
const result = await generateImage({
|
|
300
|
+
prompt: enhanced,
|
|
301
|
+
});
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
## Best Practices
|
|
305
|
+
|
|
306
|
+
1. **Moderation**: Always enable moderation in production
|
|
307
|
+
2. **Language Enhancement**: Use for non-English prompts
|
|
308
|
+
3. **Synchronous**: Avoid synchronous generation in production
|
|
309
|
+
4. **Rule Configuration**: Customize rules based on your use case
|
|
310
|
+
5. **Violation Handling**: Provide clear feedback to users
|
|
311
|
+
|
|
312
|
+
## Error Handling
|
|
313
|
+
|
|
314
|
+
```tsx
|
|
315
|
+
try {
|
|
316
|
+
const result = await wrapped.generate({ prompt: '...' });
|
|
317
|
+
} catch (error) {
|
|
318
|
+
if (error.type === 'MODERATION_ERROR') {
|
|
319
|
+
// Content was flagged
|
|
320
|
+
showModerationError(error.violations);
|
|
321
|
+
} else if (error.type === 'TIMEOUT_ERROR') {
|
|
322
|
+
// Generation timed out
|
|
323
|
+
showTimeoutError();
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
## Related
|
|
329
|
+
|
|
330
|
+
- [Middleware](../middleware/) - Request/response middleware
|
|
331
|
+
- [Services](../services/) - AI generation services
|
|
332
|
+
- [Utils](../utils/) - Utility functions
|
|
333
|
+
|
|
334
|
+
## License
|
|
335
|
+
|
|
336
|
+
MIT
|