UNPKG

openguardrails

Version:

An LLM-based context-aware AI guardrail capable of understanding conversation context for security, safety and data leakage detection.

35 lines 1.45 kB
/** * OpenGuardrails Node.js Client * * Context-aware AI Guardrails based on LLM, which can understand the conversation context for security detection. * * This package provides a Node.js client library for interacting with the OpenGuardrails API. * * @example * Basic usage: * * ```typescript * import { OpenGuardrails } from 'openguardrails'; * * // Use the cloud API * const client = new OpenGuardrails({ apiKey: "your-api-key" }); * * // Detect the prompt * const result = await client.checkPrompt("User question"); * * // Detect the conversation context (user + assistant answer) * const messages = [ * { role: "user", content: "User question" }, * { role: "assistant", content: "Assistant answer" } * ]; * const result = await client.checkConversation(messages); * console.log(result.overall_risk_level); // Output: no_risk/high_risk/medium_risk/low_risk * console.log(result.suggest_action); // Output: pass/replace/reject * ``` */ export { OpenGuardrails, GuardrailResponseHelper } from './client'; export { OpenGuardrailsConfig, Message, GuardrailRequest, GuardrailResponse, GuardrailResult, ComplianceResult, SecurityResult, DataSecurityResult } from './types'; export { OpenGuardrailsError, AuthenticationError, RateLimitError, ValidationError, NetworkError, ServerError } from './exceptions'; import { OpenGuardrails } from './client'; export default OpenGuardrails; //# sourceMappingURL=index.d.ts.map