UNPKG

llm-guard

Version:

A TypeScript library for validating and securing LLM prompts

42 lines (39 loc) 987 B
interface GuardConfig { pii?: boolean; jailbreak?: boolean; profanity?: boolean; promptInjection?: boolean; relevance?: boolean; toxicity?: boolean; customRules?: Record<string, any>; relevanceOptions?: { minLength?: number; maxLength?: number; minWords?: number; maxWords?: number; }; } interface GuardResult { valid: boolean; score?: number; details?: { rule: string; message: string; matched?: string; }[]; } interface GuardResponse { id: string; input: string; results: GuardResult[]; } interface BatchGuardResponse { responses: GuardResponse[]; } declare class LLMGuard { private guards; constructor(config?: GuardConfig); validate(prompt: string): Promise<GuardResponse>; validateBatch(prompts: string[]): Promise<BatchGuardResponse>; } export { type BatchGuardResponse, type GuardConfig, type GuardResponse, type GuardResult, LLMGuard };