guardrail-plug-sdk 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Guardrail Plug SDK
|
|
2
|
+
|
|
3
|
+
A plug-and-play AI Auditing, Safety, and Hallucination Interception SDK. Wrap any LLM agent to intercept prompt injections, redact PII, trace reasoning, verify factual grounding against corporate knowledge bases, and block ungrounded responses in real time.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install guardrail-plug-sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
Initialize the SDK and route your chat prompts through the security gateway:
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { Guardrail } from 'guardrail-plug-sdk';
|
|
17
|
+
|
|
18
|
+
const guardrail = new Guardrail({
|
|
19
|
+
endpoint: 'http://localhost:5050', // Gateway server address
|
|
20
|
+
apiKey: 'gr_sec_your_api_key_here',
|
|
21
|
+
provider: 'openrouter', // 'openrouter' | 'openai' | 'gemini' | 'ollama' | 'mock'
|
|
22
|
+
model: 'google/gemini-2.5-flash',
|
|
23
|
+
applicationName: 'HR Compliance Assistant'
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
async function askAgent(userInput: string) {
|
|
27
|
+
const response = await guardrail.chat({
|
|
28
|
+
messages: [{ role: 'user', content: userInput }],
|
|
29
|
+
groundingSource: 'web' // 'kb' (Knowledge base files) or 'web' (Real-time web search)
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
if (response.decision === 'BLOCKED') {
|
|
33
|
+
console.warn(`Blocked by Policy: ${response.policyExplanation}`);
|
|
34
|
+
// Output safe fallback
|
|
35
|
+
return response.text;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
console.log(`Factual Trust Score: ${response.factualTrustScore}`); // Score from 0.0 to 1.0
|
|
39
|
+
return response.text;
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Features
|
|
44
|
+
|
|
45
|
+
- **Input Interception & Redaction**: Scans prompts for PII/PHI (emails, SSNs, credit cards) and prompt injections before hitting target LLMs.
|
|
46
|
+
- **Dynamic Factual Auditing**: Extracts claims and performs Natural Language Inference (NLI) audits against vector database documentation or live web citations.
|
|
47
|
+
- **Trust Scoring**: Generates a deterministic mathematical Trust Score indicating the percentage of grounding.
|
|
48
|
+
- **Real-Time Policy Enforcement**: Blocks or flags responses that exceed configured hallucination or safety thresholds.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "guardrail-plug-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "A plug-and-play AI Auditing & Hallucination Detection SDK. Intercepts LLM inputs/outputs, verifies factual grounding against your knowledge base, and blocks or flags unverified responses.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|