openredaction 1.0.9 → 1.0.10
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 +0 -55
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -36,61 +36,6 @@ import { useOpenRedaction, usePIIDetector } from 'openredaction/react';
|
|
|
36
36
|
|
|
37
37
|
`react` is an optional peer dependency; only install it if you use the React entry.
|
|
38
38
|
|
|
39
|
-
## Optional AI Assist
|
|
40
|
-
|
|
41
|
-
OpenRedaction supports an optional AI-assisted detection mode that enhances regex-based detection by calling a hosted AI endpoint. This feature is **OFF by default** and requires explicit configuration.
|
|
42
|
-
|
|
43
|
-
### Configuration
|
|
44
|
-
|
|
45
|
-
```typescript
|
|
46
|
-
import { OpenRedaction } from 'openredaction';
|
|
47
|
-
|
|
48
|
-
const detector = new OpenRedaction({
|
|
49
|
-
// ... other options ...
|
|
50
|
-
ai: {
|
|
51
|
-
enabled: true,
|
|
52
|
-
endpoint: 'https://your-api.example.com' // Optional: defaults to OPENREDACTION_AI_ENDPOINT env var
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
const result = await detector.detect('Contact John Doe at john@example.com');
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
### How It Works
|
|
60
|
-
|
|
61
|
-
1. **Regex Detection First**: The library always runs regex detection first (existing behavior)
|
|
62
|
-
2. **AI Enhancement**: If `ai.enabled === true` and an endpoint is configured, the library calls the `/ai-detect` endpoint
|
|
63
|
-
3. **Smart Merging**: AI entities are merged with regex detections, with regex taking precedence on conflicts
|
|
64
|
-
4. **Graceful Fallback**: If the AI endpoint fails or is unavailable, the library silently falls back to regex-only detection
|
|
65
|
-
|
|
66
|
-
### Environment Variables
|
|
67
|
-
|
|
68
|
-
In Node.js environments, you can set the endpoint via environment variable:
|
|
69
|
-
|
|
70
|
-
```bash
|
|
71
|
-
export OPENREDACTION_AI_ENDPOINT=https://your-api.example.com
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
### Important Notes
|
|
75
|
-
|
|
76
|
-
- **AI is optional**: The library works exactly as before when `ai.enabled` is `false` or omitted
|
|
77
|
-
- **Regex is primary**: AI only adds additional entities; regex detections always take precedence
|
|
78
|
-
- **No breaking changes**: When AI is disabled, detection is still regex-only; `detect()` always returns a `Promise`
|
|
79
|
-
- **Browser support**: In browsers, you must provide an explicit `ai.endpoint` (env vars not available)
|
|
80
|
-
- **Network dependency**: AI mode requires network access to the endpoint
|
|
81
|
-
|
|
82
|
-
### For Sensitive Workloads
|
|
83
|
-
|
|
84
|
-
For maximum security and privacy, keep AI disabled and rely purely on regex detection:
|
|
85
|
-
|
|
86
|
-
```typescript
|
|
87
|
-
const detector = new OpenRedaction({
|
|
88
|
-
// AI not configured = pure regex detection
|
|
89
|
-
includeNames: true,
|
|
90
|
-
includeEmails: true
|
|
91
|
-
});
|
|
92
|
-
```
|
|
93
|
-
|
|
94
39
|
## Documentation
|
|
95
40
|
|
|
96
41
|
- Site & playground: [openredaction.com](https://openredaction.com)
|