UNPKG

llmverify

Version:

AI Output Verification Toolkit — Local-first LLM safety, hallucination detection, PII redaction, prompt injection defense, and runtime monitoring. Zero telemetry. OWASP LLM Top 10 aligned.

164 lines (163 loc) 4.64 kB
/** * llmverify Core Module * * Pre-configured verification pipelines for different use cases. * Run all engines with a single command using preset configurations. * * @module core * @author KingCaliber Labs * @license MIT */ import { ClassificationResult } from '../engines/classification'; import { VerifyResult, Finding } from '../types/results'; import { Config } from '../types/config'; /** * Preset configuration modes for different environments */ export type PresetMode = 'dev' | 'prod' | 'strict' | 'fast' | 'ci'; export declare const PRESETS: Record<PresetMode, Partial<Config>>; /** * Result from running all engines */ export interface CoreRunResult { /** Overall verification result */ verification: VerifyResult; /** Classification result (intent, hallucination, etc.) */ classification: ClassificationResult | null; /** Input safety check result */ inputSafety: { safe: boolean; injectionFindings: Finding[]; riskScore: number; } | null; /** PII detection result */ piiCheck: { hasPII: boolean; findings: Finding[]; redacted: string; piiCount: number; } | null; /** Harmful content check result */ harmfulCheck: { hasHarmful: boolean; findings: Finding[]; } | null; /** Execution metadata */ meta: { preset: PresetMode; enginesRun: string[]; totalLatencyMs: number; timestamp: string; }; } /** * Options for core run */ export interface CoreRunOptions { /** Content to verify (AI output) */ content: string; /** Original prompt (optional, for classification) */ prompt?: string; /** User input to check (optional, for input safety) */ userInput?: string; /** Preset mode */ preset?: PresetMode; /** Custom config (overrides preset) */ config?: Partial<Config>; /** Run engines in parallel */ parallel?: boolean; } /** * Run all verification engines with a single command * * This is the master function that developers can use to run * comprehensive verification with preset configurations. * * @example * ```typescript * import { run } from 'llmverify/core'; * * // Quick dev mode * const result = await run({ content: aiOutput, preset: 'dev' }); * * // Production mode with input check * const result = await run({ * content: aiOutput, * userInput: userMessage, * preset: 'prod' * }); * * // Strict mode with classification * const result = await run({ * content: aiOutput, * prompt: originalPrompt, * preset: 'strict' * }); * ``` */ export declare function run(options: CoreRunOptions): Promise<CoreRunResult>; /** * Quick verification with dev preset */ export declare function devVerify(content: string, prompt?: string): Promise<CoreRunResult>; /** * Quick verification with prod preset */ export declare function prodVerify(content: string): Promise<CoreRunResult>; /** * Quick verification with strict preset */ export declare function strictVerify(content: string, prompt?: string): Promise<CoreRunResult>; /** * Quick verification with fast preset */ export declare function fastVerify(content: string): Promise<CoreRunResult>; /** * Quick verification for CI/CD */ export declare function ciVerify(content: string): Promise<CoreRunResult>; /** * Pipeline step definition */ export interface PipelineStep { name: string; enabled: boolean; run: (content: string, context: any) => Promise<any>; } /** * Build a custom verification pipeline * * @example * ```typescript * const pipeline = createPipeline() * .addStep('pii', async (content) => checkPII(content)) * .addStep('injection', async (content) => checkPromptInjection(content)) * .build(); * * const results = await pipeline.run(content); * ``` */ export declare function createPipeline(): { addStep(name: string, run: (content: string, context: any) => Promise<any>): /*elided*/ any; disableStep(name: string): /*elided*/ any; enableStep(name: string): /*elided*/ any; build(): { run(content: string, context?: any): Promise<Record<string, any>>; getSteps(): { name: string; enabled: boolean; }[]; }; }; export { PRESETS as presets }; declare const _default: { run: typeof run; devVerify: typeof devVerify; prodVerify: typeof prodVerify; strictVerify: typeof strictVerify; fastVerify: typeof fastVerify; ciVerify: typeof ciVerify; createPipeline: typeof createPipeline; PRESETS: Record<PresetMode, Partial<Config>>; }; export default _default;