@umituz/react-native-ai-content-moderation
v1.2.0
Published
Content moderation service for AI applications - text, image, video, and voice content validation
Maintainers
Readme
@umituz/react-native-ai-content-moderation
Content moderation service for AI applications. Supports text, image, video, and voice content validation.
Installation
npm install @umituz/react-native-ai-content-moderationUsage
Basic Usage
import {
contentModerationService,
ContentPolicyViolationError,
} from "@umituz/react-native-ai-content-moderation";
// Moderate text content
const result = await contentModerationService.moderate({
contentType: "text",
content: "Your text content here",
});
if (!result.isAllowed) {
throw new ContentPolicyViolationError(result.violations);
}Configuration
import { contentModerationService } from "@umituz/react-native-ai-content-moderation";
contentModerationService.configure({
validationLimits: {
maxTextLength: 5000,
maxVoiceTextLength: 3000,
maxUriLength: 1024,
},
suggestionMessages: {
explicit_content: "Please remove explicit content",
violence: "Please remove violent content",
},
});Custom Rules
import { rulesRegistry } from "@umituz/react-native-ai-content-moderation";
rulesRegistry.addRule({
id: "custom-001",
name: "Custom Rule",
description: "My custom moderation rule",
contentTypes: ["text"],
severity: "high",
violationType: "spam",
patterns: ["\\bspam\\b"],
enabled: true,
});Sync Moderation
const { isAllowed, violations } = contentModerationService.moderateSync(
"content",
"text"
);API
contentModerationService
moderate(context)- Async moderationisContentAllowed(content, type)- Check if content is allowedmoderateSync(content, type)- Sync moderationconfigure(config)- Configure the service
rulesRegistry
getRules()- Get all rulesgetRulesByContentType(type)- Get rules by content typeaddRule(rule)- Add a custom ruleremoveRule(id)- Remove a ruleenableRule(id)/disableRule(id)- Toggle ruleresetToDefaults()- Reset to default rules
ContentPolicyViolationError
getUserMessage()- Get user-friendly messagegetViolationTypes()- Get violation typeshasViolationType(type)- Check for specific violationgetSeverityLevel()- Get highest severity
License
MIT
