UNPKG

prompt-bouncer

Version:

A lightweight, customizable content moderation library for AI applications. Filters profanity, explicit content, and inappropriate prompts for text-to-image generation.

79 lines 1.88 kB
import { FilterConfig, ModerationResult } from "./types"; /** * AI Content Filter - Main class for content moderation */ export declare class AIContentFilter { private config; private bannedWords; private allowedWords; constructor(config?: FilterConfig); /** * Initialize the banned words list based on configuration */ private initializeBannedWords; /** * Check if a category should be included based on config */ private shouldIncludeCategory; /** * Normalize text for processing */ private normalizeText; /** * Extract words from text */ private extractWords; /** * Check if a word matches any banned word */ private isWordBanned; /** * Get category for a specific word */ private getCategoryForWord; /** * Get severity for categories */ private getSeverityForCategories; /** * Clean text by replacing banned words */ private cleanText; /** * Main moderation function */ moderate(text: string): ModerationResult; /** * Quick boolean check if content is safe */ isSafe(text: string): boolean; /** * Get only flagged words */ getFlaggedWords(text: string): string[]; /** * Get cleaned version of text */ clean(text: string): string; /** * Add custom words to banned list */ addBannedWords(words: string[]): void; /** * Remove words from banned list */ removeBannedWords(words: string[]): void; /** * Add words to allowed list */ addAllowedWords(words: string[]): void; /** * Get current configuration */ getConfig(): FilterConfig; /** * Update configuration */ updateConfig(newConfig: Partial<FilterConfig>): void; } //# sourceMappingURL=filter.d.ts.map