1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
//! # Hanzo Guard
//!
//! LLM I/O sanitization and safety layer - the "condom" for AI.
//!
//! Hanzo Guard sits between your application and LLM providers, sanitizing
//! all inputs and outputs to prevent:
//!
//! - **PII Leakage**: Detects and redacts personal identifiable information
//! - **Prompt Injection**: Detects jailbreak and manipulation attempts
//! - **Unsafe Content**: Filters harmful content via Zen Guard models
//! - **Rate Abuse**: Prevents excessive API usage
//! - **Audit Violations**: Logs all requests for compliance
//!
//! ## Quick Start
//!
//! ```rust
//! use hanzo_guard::{Guard, GuardConfig, SanitizeResult};
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let guard = Guard::new(GuardConfig::default());
//!
//! // Sanitize input before sending to LLM
//! let input = "My SSN is 123-45-6789, can you help me?";
//! let result = guard.sanitize_input(input).await?;
//!
//! match result {
//! SanitizeResult::Clean(text) => {
//! // Safe to send to LLM
//! println!("Clean: {}", text);
//! }
//! SanitizeResult::Redacted { text, redactions } => {
//! // PII was redacted
//! println!("Redacted: {} ({} items)", text, redactions.len());
//! }
//! SanitizeResult::Blocked { reason, category } => {
//! // Content blocked
//! println!("Blocked: {} ({:?})", reason, category);
//! }
//! }
//!
//! Ok(())
//! }
//! ```
//!
//! ## Architecture
//!
//! ```text
//! ┌─────────────┐ ┌──────────────┐ ┌─────────────┐
//! │ Application │ ──► │ Hanzo Guard │ ──► │ LLM Provider│
//! └─────────────┘ │ │ └─────────────┘
//! │ ┌──────────┐ │
//! │ │ PII │ │
//! │ │ Detector │ │
//! │ └──────────┘ │
//! │ ┌──────────┐ │
//! │ │ Injection│ │
//! │ │ Detector │ │
//! │ └──────────┘ │
//! │ ┌──────────┐ │
//! │ │ Content │ │
//! │ │ Filter │ │
//! │ └──────────┘ │
//! │ ┌──────────┐ │
//! │ │ Rate │ │
//! │ │ Limiter │ │
//! │ └──────────┘ │
//! │ ┌──────────┐ │
//! │ │ Audit │ │
//! │ │ Logger │ │
//! │ └──────────┘ │
//! └──────────────┘
//! ```
pub use GuardConfig;
pub use ;
pub use Guard;
pub use *;
/// Prelude for convenient imports