How sonic-12/llm-guard works
LLM-Guard is a reverse proxy that protects a locally served language model. A client request is authenticated and authorized, checked by deterministic and semantic prompt defenses, redacted, hardened, and forwarded to the model; the response is validated and sensitive values are restored. Audit telemetry is a separate reporting branch. The README documents the overall flow and capabilities; several proxy-to-service connections are documented rather than visible in sampled call sites.
Main entry points: engine.go Prompt rules · dlp.go DLP service client · proxy.go Proxy server · outputguard.go Output validation
Components 22
Proxy enforcement
- Proxy server
LLM-guard/proxy/internal/proxy/proxy.go - Authentication and RBAC
LLM-guard/proxy/internal/rbac/rbac.go - Prompt hardening
LLM-guard/proxy/internal/hardening/hardening.go - Output validation
LLM-guard/proxy/internal/outputguard/outputguard.go
Prompt detection
- Prompt rules
LLM-guard/proxy/internal/rules/engine.go - Unicode normalization
LLM-guard/proxy/internal/rules/normalize.go - Jailbreak service client
LLM-guard/proxy/internal/threatdetect/client.go - Firewall inspection API
LLM-guard/services/firewall/app.py - Jailbreak classifier
LLM-guard/services/firewall/classifier.py - Classifier training
LLM-guard/services/firewall/train.py - Training data
LLM-guard/services/firewall/data_loader.py - Text preprocessing
LLM-guard/services/firewall/preprocess.py
Data protection
- DLP service client
LLM-guard/proxy/internal/dlp/dlp.go - DLP redact and restore API
LLM-guard/dlp-service/app.py - PII analyzer
LLM-guard/dlp-service/analyzer.py - API key recognizers
LLM-guard/dlp-service/recognizers.py
Audit and analytics
- Audit telemetry
LLM-guard/proxy/internal/telemetry/telemetry.go - Analytics API and store
LLM-guard/sidecar/analytics/app.py - Security dashboard
LLM-guard/sidecar/analytics/dashboard.html
Other components
- Client
- Language model
- Client response
Connections 22
- Client → Proxy server: sends request
README.md - Proxy server → Authentication and RBAC: authorizes
README.md - Authentication and RBAC → Prompt rules: permits request
README.md - Prompt rules → Unicode normalization: normalizes prompt
LLM-guard/proxy/internal/rules/engine.go - Prompt rules → Jailbreak service client: inspects prompt
LLM-guard/proxy/internal/rules/engine.go - Jailbreak service client → Firewall inspection API: requests inspection
README.md - Firewall inspection API → Jailbreak classifier: scores prompt
LLM-guard/services/firewall/app.py - Jailbreak classifier → Classifier training: loads model from
LLM-guard/services/firewall/classifier.py - Classifier training → Training data: loads examples
LLM-guard/services/firewall/train.py - Classifier training → Text preprocessing: uses preprocessing
LLM-guard/services/firewall/train.py - Prompt rules → DLP service client: passes prompt
README.md - DLP service client → DLP redact and restore API: redacts and restores
README.md - DLP redact and restore API → PII analyzer: analyzes text
LLM-guard/dlp-service/app.py - PII analyzer → API key recognizers: registers recognizer
LLM-guard/dlp-service/analyzer.py - DLP service client → Prompt hardening: returns masked prompt
README.md - Prompt hardening → Language model: forwards prompt
README.md - Language model → Output validation: returns output
README.md - Output validation → DLP service client: requests restoration
README.md - Output validation → Client response: returns validated output
README.md - Proxy server → Audit telemetry: reports decisions
README.md - Audit telemetry → Analytics API and store: forwards audit events
README.md - Analytics API and store → Security dashboard: serves dashboard
LLM-guard/sidecar/analytics/app.py