@umituz/react-native-ai-generation-content 1.17.229 → 1.17.231
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 +431 -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 +394 -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/components/result/ResultStoryCard.tsx +1 -6
- 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/types/result-config.types.ts +3 -3
- package/src/presentation/layouts/types/.npmignore.tmp +0 -0
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
# Content Moderation Domain
|
|
2
|
+
|
|
3
|
+
Content moderation and filtering system for AI-generated content.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The Content Moderation domain provides comprehensive content moderation capabilities for AI-generated content. It helps ensure that generated content meets safety guidelines and community standards.
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- **Text Moderation**: Filter inappropriate text content
|
|
12
|
+
- **Image Moderation**: Detect and filter inappropriate images
|
|
13
|
+
- **Video Moderation**: Moderate video content
|
|
14
|
+
- **Voice Moderation**: Filter audio content
|
|
15
|
+
- **Configurable Rules**: Customize moderation rules and policies
|
|
16
|
+
- **Policy Violation Detection**: Detect and report policy violations
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
This domain is part of `@umituz/react-native-ai-generation-content`.
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install @umituz/react-native-ai-generation-content
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Basic Usage
|
|
27
|
+
|
|
28
|
+
### Using Moderation Wrapper
|
|
29
|
+
|
|
30
|
+
```tsx
|
|
31
|
+
import { ModerationWrapper } from '@umituz/react-native-ai-generation-content';
|
|
32
|
+
|
|
33
|
+
// Wrap generation with moderation
|
|
34
|
+
const wrapper = new ModerationWrapper({
|
|
35
|
+
enabled: true,
|
|
36
|
+
onViolation: (result) => {
|
|
37
|
+
Alert.alert('Content Warning', result.warning);
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// Generate with moderation
|
|
42
|
+
const result = await wrapper.execute({
|
|
43
|
+
type: 'text-to-image',
|
|
44
|
+
input: { prompt: 'Your prompt here' },
|
|
45
|
+
generate: async (input) => {
|
|
46
|
+
return await generateImage(input);
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
if (result.isModerated) {
|
|
51
|
+
console.log('Content was flagged:', result.violations);
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Direct Moderation
|
|
56
|
+
|
|
57
|
+
```tsx
|
|
58
|
+
import { moderateText, moderateImage } from '@umituz/react-native-ai-generation-content';
|
|
59
|
+
|
|
60
|
+
// Moderate text
|
|
61
|
+
const textResult = await moderateText({
|
|
62
|
+
text: 'Some text to moderate',
|
|
63
|
+
rules: ['profanity', 'hate-speech', 'violence'],
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
if (textResult.isSafe) {
|
|
67
|
+
console.log('Text is safe');
|
|
68
|
+
} else {
|
|
69
|
+
console.log('Violations:', textResult.violations);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Moderate image
|
|
73
|
+
const imageResult = await moderateImage({
|
|
74
|
+
imageBase64: 'base64...',
|
|
75
|
+
rules: ['nudity', 'violence', 'gore'],
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
if (imageResult.isSafe) {
|
|
79
|
+
console.log('Image is safe');
|
|
80
|
+
} else {
|
|
81
|
+
console.log('Violations:', imageResult.violations);
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Configuration Options
|
|
86
|
+
|
|
87
|
+
### Moderation Config
|
|
88
|
+
|
|
89
|
+
```tsx
|
|
90
|
+
interface ModerationConfig {
|
|
91
|
+
enabled: boolean; // Enable/disable moderation
|
|
92
|
+
rules?: ModerationRule[]; // Custom moderation rules
|
|
93
|
+
threshold?: number; // Confidence threshold (0-1)
|
|
94
|
+
onViolation?: (result: ModerationResult) => void; // Violation callback
|
|
95
|
+
allowOverride?: boolean; // Allow users to override warnings
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Moderation Rules
|
|
100
|
+
|
|
101
|
+
```tsx
|
|
102
|
+
interface ModerationRule {
|
|
103
|
+
id: string;
|
|
104
|
+
category: 'profanity' | 'hate-speech' | 'violence' | 'sexual' | 'self-harm' | 'other';
|
|
105
|
+
severity: 'low' | 'medium' | 'high';
|
|
106
|
+
enabled: boolean;
|
|
107
|
+
action: 'flag' | 'block' | 'warn';
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Moderation Types
|
|
112
|
+
|
|
113
|
+
### Text Moderation
|
|
114
|
+
|
|
115
|
+
```tsx
|
|
116
|
+
import { moderateText } from '@umituz/react-native-ai-generation-content';
|
|
117
|
+
|
|
118
|
+
const result = await moderateText({
|
|
119
|
+
text: 'Your text content',
|
|
120
|
+
rules: ['profanity', 'hate-speech', 'harassment'],
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
// Result
|
|
124
|
+
interface TextModerationResult {
|
|
125
|
+
isSafe: boolean;
|
|
126
|
+
confidence: number;
|
|
127
|
+
violations: {
|
|
128
|
+
category: string;
|
|
129
|
+
severity: 'low' | 'medium' | 'high';
|
|
130
|
+
confidence: number;
|
|
131
|
+
position?: { start: number; end: number };
|
|
132
|
+
}[];
|
|
133
|
+
filteredText?: string; // Text with violations removed
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Image Moderation
|
|
138
|
+
|
|
139
|
+
```tsx
|
|
140
|
+
import { moderateImage } from '@umituz/react-native-ai-generation-content';
|
|
141
|
+
|
|
142
|
+
const result = await moderateImage({
|
|
143
|
+
imageBase64: 'base64...',
|
|
144
|
+
rules: ['nudity', 'violence', 'gore', 'racy'],
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
// Result
|
|
148
|
+
interface ImageModerationResult {
|
|
149
|
+
isSafe: boolean;
|
|
150
|
+
confidence: number;
|
|
151
|
+
violations: {
|
|
152
|
+
category: string;
|
|
153
|
+
severity: 'low' | 'medium' | 'high';
|
|
154
|
+
confidence: number;
|
|
155
|
+
boundingBox?: { x: number; y: number; width: number; height: number };
|
|
156
|
+
}[];
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Video Moderation
|
|
161
|
+
|
|
162
|
+
```tsx
|
|
163
|
+
import { moderateVideo } from '@umituz/react-native-ai-generation-content';
|
|
164
|
+
|
|
165
|
+
const result = await moderateVideo({
|
|
166
|
+
videoUrl: 'https://...',
|
|
167
|
+
rules: ['nudity', 'violence', 'gore'],
|
|
168
|
+
frameInterval: 5, // Check every 5th frame
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
// Result
|
|
172
|
+
interface VideoModerationResult {
|
|
173
|
+
isSafe: boolean;
|
|
174
|
+
confidence: number;
|
|
175
|
+
violations: {
|
|
176
|
+
category: string;
|
|
177
|
+
severity: 'low' | 'medium' | 'high';
|
|
178
|
+
timestamp: number; // Time in seconds
|
|
179
|
+
confidence: number;
|
|
180
|
+
}[];
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Voice Moderation
|
|
185
|
+
|
|
186
|
+
```tsx
|
|
187
|
+
import { moderateVoice } from '@umituz/react-native-ai-generation-content';
|
|
188
|
+
|
|
189
|
+
const result = await moderateVoice({
|
|
190
|
+
audioUrl: 'https://...',
|
|
191
|
+
rules: ['profanity', 'hate-speech', 'violence'],
|
|
192
|
+
language: 'en',
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
// Result
|
|
196
|
+
interface VoiceModerationResult {
|
|
197
|
+
isSafe: boolean;
|
|
198
|
+
confidence: number;
|
|
199
|
+
transcript?: string; // Transcribed text
|
|
200
|
+
violations: {
|
|
201
|
+
category: string;
|
|
202
|
+
severity: 'low' | 'medium' | 'high';
|
|
203
|
+
timestamp: number;
|
|
204
|
+
confidence: number;
|
|
205
|
+
text?: string; // Transcribed text segment
|
|
206
|
+
}[];
|
|
207
|
+
}
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
## Using with AI Features
|
|
211
|
+
|
|
212
|
+
### Wrap Generation with Moderation
|
|
213
|
+
|
|
214
|
+
```tsx
|
|
215
|
+
import { generationWrapper, ModerationWrapper } from '@umituz/react-native-ai-generation-content';
|
|
216
|
+
|
|
217
|
+
// Setup moderation
|
|
218
|
+
const moderation = new ModerationWrapper({
|
|
219
|
+
enabled: true,
|
|
220
|
+
rules: [
|
|
221
|
+
{ id: 'no-nudity', category: 'sexual', severity: 'high', enabled: true, action: 'block' },
|
|
222
|
+
{ id: 'no-violence', category: 'violence', severity: 'medium', enabled: true, action: 'warn' },
|
|
223
|
+
],
|
|
224
|
+
onViolation: (result) => {
|
|
225
|
+
Alert.alert('Content Flagged', result.warning);
|
|
226
|
+
},
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
// Wrap generation
|
|
230
|
+
const wrappedGenerate = moderation.wrap({
|
|
231
|
+
type: 'text-to-image',
|
|
232
|
+
generate: async (input) => {
|
|
233
|
+
return await generationWrapper.executeImageFeature({
|
|
234
|
+
featureType: 'text-to-image',
|
|
235
|
+
inputData: input,
|
|
236
|
+
});
|
|
237
|
+
},
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
// Use wrapped generation
|
|
241
|
+
const result = await wrappedGenerate({
|
|
242
|
+
prompt: 'Your prompt here',
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
if (result.isModerated) {
|
|
246
|
+
// Content was flagged
|
|
247
|
+
console.log('Violations:', result.violations);
|
|
248
|
+
} else {
|
|
249
|
+
// Content is safe
|
|
250
|
+
console.log('Generated image:', result.imageUrl);
|
|
251
|
+
}
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
### Custom Moderation Rules
|
|
255
|
+
|
|
256
|
+
```tsx
|
|
257
|
+
import { ModerationWrapper } from '@umituz/react-native-ai-generation-content';
|
|
258
|
+
|
|
259
|
+
const customRules = [
|
|
260
|
+
{
|
|
261
|
+
id: 'custom-1',
|
|
262
|
+
category: 'other' as const,
|
|
263
|
+
severity: 'medium' as const,
|
|
264
|
+
enabled: true,
|
|
265
|
+
action: 'warn' as const,
|
|
266
|
+
check: async (content: string) => {
|
|
267
|
+
// Custom check logic
|
|
268
|
+
return {
|
|
269
|
+
isViolation: content.includes('forbidden-word'),
|
|
270
|
+
confidence: 1.0,
|
|
271
|
+
};
|
|
272
|
+
},
|
|
273
|
+
},
|
|
274
|
+
];
|
|
275
|
+
|
|
276
|
+
const moderation = new ModerationWrapper({
|
|
277
|
+
enabled: true,
|
|
278
|
+
rules: customRules,
|
|
279
|
+
});
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
## Component Integration
|
|
283
|
+
|
|
284
|
+
### ModerationSummary Component
|
|
285
|
+
|
|
286
|
+
```tsx
|
|
287
|
+
import { ModerationSummary } from '@umituz/react-native-ai-generation-content';
|
|
288
|
+
|
|
289
|
+
<ModerationSummary
|
|
290
|
+
violations={moderationResult.violations}
|
|
291
|
+
onDismiss={() => console.log('Dismissed')}
|
|
292
|
+
onOverride={() => console.log('Overridden')}
|
|
293
|
+
/>
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
### Show Warning Helper
|
|
297
|
+
|
|
298
|
+
```tsx
|
|
299
|
+
import { showContentModerationWarning } from '@umituz/react-native-ai-generation-content';
|
|
300
|
+
|
|
301
|
+
const result = await moderateText({ text: '...' });
|
|
302
|
+
|
|
303
|
+
if (!result.isSafe) {
|
|
304
|
+
showContentModerationWarning({
|
|
305
|
+
violations: result.violations,
|
|
306
|
+
onConfirm: () => {
|
|
307
|
+
// User acknowledged and wants to proceed
|
|
308
|
+
},
|
|
309
|
+
onCancel: () => {
|
|
310
|
+
// User cancelled
|
|
311
|
+
},
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
## Best Practices
|
|
317
|
+
|
|
318
|
+
1. **Enable Early**: Enable moderation from the start of development
|
|
319
|
+
2. **Custom Rules**: Customize rules based on your use case
|
|
320
|
+
3. **Thresholds**: Adjust confidence thresholds based on your needs
|
|
321
|
+
4. **User Feedback**: Allow users to provide feedback on moderation
|
|
322
|
+
5. **Transparency**: Be transparent about moderation with users
|
|
323
|
+
|
|
324
|
+
## Configuration Examples
|
|
325
|
+
|
|
326
|
+
### Strict Moderation
|
|
327
|
+
|
|
328
|
+
```tsx
|
|
329
|
+
const strictConfig: ModerationConfig = {
|
|
330
|
+
enabled: true,
|
|
331
|
+
threshold: 0.3, // Lower threshold = more strict
|
|
332
|
+
rules: [
|
|
333
|
+
{ id: 'profanity', category: 'profanity', severity: 'low', enabled: true, action: 'block' },
|
|
334
|
+
{ id: 'hate-speech', category: 'hate-speech', severity: 'high', enabled: true, action: 'block' },
|
|
335
|
+
{ id: 'violence', category: 'violence', severity: 'low', enabled: true, action: 'block' },
|
|
336
|
+
{ id: 'sexual', category: 'sexual', severity: 'low', enabled: true, action: 'block' },
|
|
337
|
+
],
|
|
338
|
+
};
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
### Lenient Moderation
|
|
342
|
+
|
|
343
|
+
```tsx
|
|
344
|
+
const lenientConfig: ModerationConfig = {
|
|
345
|
+
enabled: true,
|
|
346
|
+
threshold: 0.8, // Higher threshold = more lenient
|
|
347
|
+
allowOverride: true,
|
|
348
|
+
rules: [
|
|
349
|
+
{ id: 'hate-speech', category: 'hate-speech', severity: 'high', enabled: true, action: 'block' },
|
|
350
|
+
{ id: 'sexual', category: 'sexual', severity: 'high', enabled: true, action: 'warn' },
|
|
351
|
+
],
|
|
352
|
+
};
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
## Related Features
|
|
356
|
+
|
|
357
|
+
- [Prompts](../prompts) - AI prompt management
|
|
358
|
+
- [Creations](../creations) - Manage AI-generated creations
|
|
359
|
+
- [Face Detection](../face-detection) - Face detection API
|
|
360
|
+
|
|
361
|
+
## License
|
|
362
|
+
|
|
363
|
+
MIT
|