Posts

Showing posts from March, 2026

#1 Hands-on

 """ ============================================================   AI GUARDRAILS - Hands-On Lab for Undergrad Students ============================================================ Topics covered:   1. Input Validation & Sanitization   2. Output Filtering & Content Moderation   3. Rate Limiting   4. Prompt Injection Detection   5. Toxicity Detection (keyword-based)   6. PII (Personally Identifiable Information) Scrubbing   7. Response Length & Format Guardrails   8. Confidence Thresholding   9. Logging & Auditing   10. Putting It All Together — GuardedAI pipeline Run each section independently or use GuardedAI at the bottom. """ import re import time import logging import hashlib from datetime import datetime from collections import defaultdict from typing import Optional # ───────────────────────────────────────────── # SETUP — logging to file + console # ───────────────────────────────────────────── logging.ba...