openguardrails
Version:
An LLM-based context-aware AI guardrail capable of understanding conversation context for security, safety and data leakage detection.
45 lines • 2.53 kB
JavaScript
;
/**
* 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
* ```
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.ServerError = exports.NetworkError = exports.ValidationError = exports.RateLimitError = exports.AuthenticationError = exports.OpenGuardrailsError = exports.GuardrailResponseHelper = exports.OpenGuardrails = void 0;
var client_1 = require("./client");
Object.defineProperty(exports, "OpenGuardrails", { enumerable: true, get: function () { return client_1.OpenGuardrails; } });
Object.defineProperty(exports, "GuardrailResponseHelper", { enumerable: true, get: function () { return client_1.GuardrailResponseHelper; } });
var exceptions_1 = require("./exceptions");
Object.defineProperty(exports, "OpenGuardrailsError", { enumerable: true, get: function () { return exceptions_1.OpenGuardrailsError; } });
Object.defineProperty(exports, "AuthenticationError", { enumerable: true, get: function () { return exceptions_1.AuthenticationError; } });
Object.defineProperty(exports, "RateLimitError", { enumerable: true, get: function () { return exceptions_1.RateLimitError; } });
Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function () { return exceptions_1.ValidationError; } });
Object.defineProperty(exports, "NetworkError", { enumerable: true, get: function () { return exceptions_1.NetworkError; } });
Object.defineProperty(exports, "ServerError", { enumerable: true, get: function () { return exceptions_1.ServerError; } });
const client_2 = require("./client");
exports.default = client_2.OpenGuardrails;
//# sourceMappingURL=index.js.map