UNPKG

ai-sdk-guardrails

Version:

Input and output guardrails middleware for Vercel AI SDK.

37 lines (34 loc) 1.72 kB
import { a as InputGuardrailContext, I as InputGuardrail } from '../types-B9h_0Gyl.cjs'; import 'ai'; declare function extractTextContent(context: InputGuardrailContext): { prompt: string; messages: Array<{ content?: unknown; }>; system: string; }; declare function extractMetadata(context: InputGuardrailContext): { model?: unknown; temperature?: number; maxOutputTokens?: number; }; declare const lengthLimit: (maxLength: number) => InputGuardrail; declare const blockedWords: (words: string[]) => InputGuardrail; declare const contentLengthLimit: (maxLength: number) => InputGuardrail; declare const blockedKeywords: (keywords: string[]) => InputGuardrail; declare const rateLimiting: (maxRequestsPerMinute: number) => InputGuardrail; declare const profanityFilter: (customWords?: string[]) => InputGuardrail; declare const customValidation: (name: string, description: string, validator: (input: { prompt?: string; messages?: unknown[]; system?: string; model?: unknown; temperature?: number; maxOutputTokens?: number; }) => boolean, message: string) => InputGuardrail; declare const promptInjectionDetector: () => InputGuardrail; declare const piiDetector: () => InputGuardrail; declare const toxicityDetector: (threshold?: number) => InputGuardrail; declare const mathHomeworkDetector: () => InputGuardrail; declare const codeGenerationLimiter: (allowedLanguages?: string[]) => InputGuardrail; export { blockedKeywords, blockedWords, codeGenerationLimiter, contentLengthLimit, customValidation, extractMetadata, extractTextContent, lengthLimit, mathHomeworkDetector, piiDetector, profanityFilter, promptInjectionDetector, rateLimiting, toxicityDetector };