import { F as FilterConfig } from '../types-B9c_ik4k.js'; export { C as CheckProfanityResult, L as Language } from '../types-B9c_ik4k.js'; /** * Vercel AI SDK Integration for glin-profanity * * Provides ready-to-use tools for the Vercel AI SDK. * Compatible with Next.js, Remix, SvelteKit, and other frameworks. * * @example * ```typescript * import { generateText } from 'ai'; * import { openai } from '@ai-sdk/openai'; * import { profanityTools } from 'glin-profanity/ai/vercel'; * * const { text, toolCalls } = await generateText({ * model: openai('gpt-4o'), * prompt: 'Check if "Hello world" contains profanity', * tools: profanityTools, * }); * ``` * * @packageDocumentation * @module glin-profanity/ai/vercel */ /** * Vercel AI SDK tool definition */ interface VercelAITool { description: string; inputSchema: unknown; execute: (input: TInput) => Promise; } /** * Tool input types */ interface CheckProfanityInput { text: string; languages?: string[]; detectLeetspeak?: boolean; normalizeUnicode?: boolean; } interface CensorTextInput { text: string; replacement?: string; languages?: string[]; } interface BatchCheckInput { texts: string[]; languages?: string[]; detectLeetspeak?: boolean; } interface AnalyzeContextInput { text: string; languages?: string[]; contextWindow?: number; confidenceThreshold?: number; } /** * Tool output types */ interface CheckProfanityOutput { containsProfanity: boolean; profaneWords: string[]; severityMap?: Record; wordCount: number; } interface CensorTextOutput { originalText: string; censoredText: string; profaneWordsFound: string[]; wasModified: boolean; } interface BatchCheckOutput { totalTexts: number; flaggedCount: number; cleanCount: number; results: Array<{ index: number; text: string; containsProfanity: boolean; profaneWords: string[]; }>; } interface AnalyzeContextOutput { containsProfanity: boolean; profaneWords: string[]; contextScore?: number; matches?: unknown[]; reason?: string; } interface SupportedLanguagesOutput { languages: string[]; count: number; } /** * Creates a profanity check tool for Vercel AI SDK * * @example * ```typescript * import { generateText, tool } from 'ai'; * import { createCheckProfanityTool } from 'glin-profanity/ai/vercel'; * * const { text } = await generateText({ * model: openai('gpt-4o'), * prompt: 'Check this text for profanity: "Hello world"', * tools: { * checkProfanity: createCheckProfanityTool(), * }, * }); * ``` */ declare function createCheckProfanityTool(): VercelAITool; /** * Creates a censor text tool for Vercel AI SDK */ declare function createCensorTextTool(): VercelAITool; /** * Creates a batch check tool for Vercel AI SDK */ declare function createBatchCheckTool(): VercelAITool; /** * Creates a context analysis tool for Vercel AI SDK */ declare function createContextAnalysisTool(): VercelAITool; /** * Creates a supported languages tool for Vercel AI SDK */ declare function createSupportedLanguagesTool(): VercelAITool, SupportedLanguagesOutput>; /** * Pre-built profanity tools for Vercel AI SDK * * @example * ```typescript * import { generateText } from 'ai'; * import { openai } from '@ai-sdk/openai'; * import { profanityTools } from 'glin-profanity/ai/vercel'; * * const { text, toolCalls } = await generateText({ * model: openai('gpt-4o'), * prompt: 'Check if "Hello world" contains profanity', * tools: profanityTools, * }); * ``` */ declare const profanityTools: { checkProfanity: VercelAITool; censorText: VercelAITool; batchCheckProfanity: VercelAITool; analyzeContext: VercelAITool; getSupportedLanguages: VercelAITool, SupportedLanguagesOutput>; }; /** * Creates all profanity tools with custom configuration * * @returns Object containing all Vercel AI SDK-compatible tools */ declare function createAllProfanityTools(): { checkProfanity: VercelAITool; censorText: VercelAITool; batchCheckProfanity: VercelAITool; analyzeContext: VercelAITool; getSupportedLanguages: VercelAITool, SupportedLanguagesOutput>; }; /** * Middleware for Next.js API routes to automatically check request bodies * * @example * ```typescript * // app/api/chat/route.ts * import { profanityMiddleware } from 'glin-profanity/ai/vercel'; * * export async function POST(req: Request) { * const body = await req.json(); * * // Check for profanity in user message * const check = profanityMiddleware.checkMessage(body.message); * if (check.blocked) { * return Response.json({ error: check.reason }, { status: 400 }); * } * * // Continue with AI processing... * } * ``` */ declare const profanityMiddleware: { /** * Check a message for profanity */ checkMessage(message: string, config?: Partial): { blocked: boolean; reason: string; profaneWords: string[]; censoredMessage: string; }; /** * Censor a message (replace profanity with asterisks) */ censorMessage(message: string, replacement?: string, config?: Partial): { original: string; censored: string; wasModified: boolean; profaneWords: string[]; }; /** * Check array of messages (useful for chat history) */ checkMessages(messages: Array<{ role: string; content: string; }>, config?: Partial): { hasIssues: boolean; flaggedMessages: { index: number; role: string; containsProfanity: boolean; profaneWords: string[]; }[]; totalMessages: number; }; }; export { type AnalyzeContextInput, type AnalyzeContextOutput, type BatchCheckInput, type BatchCheckOutput, type CensorTextInput, type CensorTextOutput, type CheckProfanityInput, type CheckProfanityOutput, FilterConfig, type SupportedLanguagesOutput, type VercelAITool, createAllProfanityTools, createBatchCheckTool, createCensorTextTool, createCheckProfanityTool, createContextAnalysisTool, createSupportedLanguagesTool, profanityMiddleware, profanityTools };