|
| 1 | +# AML Compliance Agent |
| 2 | + |
| 3 | +A complete **Anti-Money Laundering (AML) compliance** example for the OpenAI Agents SDK, demonstrating a multi-agent workflow for financial crime prevention. |
| 4 | + |
| 5 | +## 🎥 Demo Video & Screenshots |
| 6 | + |
| 7 | +### Demo Video (3 minutes) |
| 8 | +[Watch the full demo](your-video-link-here) |
| 9 | + |
| 10 | +### Screenshots |
| 11 | + |
| 12 | +#### 1. Model Loading |
| 13 | + |
| 14 | +*Loading Gemma 2B model locally* |
| 15 | + |
| 16 | +#### 2. Sanctions Screening |
| 17 | + |
| 18 | +*Step 1: Checking sanctions lists* |
| 19 | + |
| 20 | +#### 3. Risk Assessment |
| 21 | + |
| 22 | +*Step 2: Evaluating customer risk* |
| 23 | + |
| 24 | +#### 4. Transaction Monitoring |
| 25 | + |
| 26 | +*Step 3: Analyzing transactions* |
| 27 | + |
| 28 | +#### 5. Compliance Report |
| 29 | + |
| 30 | +*Step 4: Generating final report* |
| 31 | + |
| 32 | +#### 6. Complete (100% Offline) |
| 33 | + |
| 34 | +*All checks completed offline* |
| 35 | + |
| 36 | +## 🌟 Features |
| 37 | + |
| 38 | +- **Multi-Agent Workflow**: Screening → Risk Assessment → Transaction Monitoring → Reporting |
| 39 | +- **Structured Outputs**: Type-safe Pydantic models for all agent outputs |
| 40 | +- **Real-World Patterns**: Implements actual AML compliance workflows |
| 41 | +- **Guardrails**: Input/output validation for regulatory compliance |
| 42 | +- **Offline Mode**: Local Gemma model support for privacy |
| 43 | + |
| 44 | +## 📁 Architecture |
| 45 | + |
| 46 | +``` |
| 47 | +aml_compliance_agent/ |
| 48 | +├── agents/ |
| 49 | +│ ├── screening_agent.py # Sanctions/PEP screening |
| 50 | +│ ├── risk_assessment_agent.py # Customer risk rating |
| 51 | +│ ├── alert_agent.py # Suspicious activity detection |
| 52 | +│ └── report_agent.py # Compliance report generation |
| 53 | +├── tools/ |
| 54 | +│ ├── sanctions_checker.py # Mock sanctions list checking |
| 55 | +│ └── transaction_analyzer.py # Transaction pattern analysis |
| 56 | +├── manager.py # Orchestrates the workflow |
| 57 | +├── main.py # OpenAI API version |
| 58 | +└── main_gemma.py # Local Gemma version (offline) |
| 59 | +``` |
| 60 | + |
| 61 | +## 🚀 Quick Start |
| 62 | + |
| 63 | +### Option 1: OpenAI API (Cloud) |
| 64 | + |
| 65 | +```bash |
| 66 | +# Set your OpenAI API key |
| 67 | +export OPENAI_API_KEY=your_key |
| 68 | + |
| 69 | +# Run the demo |
| 70 | +python -m examples.aml_compliance_agent.main |
| 71 | +``` |
| 72 | + |
| 73 | +### Option 2: Local Gemma (Offline) |
| 74 | + |
| 75 | +```bash |
| 76 | +# Set HuggingFace token |
| 77 | +export HF_TOKEN=your_huggingface_token |
| 78 | + |
| 79 | +# Install dependencies |
| 80 | +pip install transformers torch accelerate bitsandbytes |
| 81 | + |
| 82 | +# Run offline version |
| 83 | +python -m examples.aml_compliance_agent.main_gemma |
| 84 | +``` |
| 85 | + |
| 86 | +## 📊 Demo Output |
| 87 | + |
| 88 | +``` |
| 89 | +============================================================ |
| 90 | +AML Compliance Check (Local Gemma) |
| 91 | +Customer: John Smith |
| 92 | +ID: CUST-001 |
| 93 | +============================================================ |
| 94 | +
|
| 95 | +[1/4] Running sanctions screening... |
| 96 | + Result: Risk Level: low |
| 97 | + Recommended Action: clear |
| 98 | + Details: No sanctions matches found... |
| 99 | +
|
| 100 | +[2/4] Performing risk assessment... |
| 101 | + Result: Overall Risk: low |
| 102 | + Review Frequency: annual |
| 103 | + Justification: Standard customer profile... |
| 104 | +
|
| 105 | +[3/4] Analyzing transactions... |
| 106 | + No alerts generated |
| 107 | +
|
| 108 | +[4/4] Generating compliance report... |
| 109 | + Report: Status: compliant |
| 110 | + Next Review: 2026-04-16 |
| 111 | + Summary: Customer cleared all checks... |
| 112 | +
|
| 113 | +============================================================ |
| 114 | +Compliance Check Complete (100% Offline) |
| 115 | +============================================================ |
| 116 | +``` |
| 117 | + |
| 118 | +## 🏗️ How It Works |
| 119 | + |
| 120 | +### 1. Sanctions Screening |
| 121 | +- Checks against OFAC, UN, EU sanctions lists |
| 122 | +- Identifies Politically Exposed Persons (PEP) |
| 123 | +- Searches for adverse media |
| 124 | + |
| 125 | +### 2. Risk Assessment |
| 126 | +- Evaluates geographic risk |
| 127 | +- Assesses business activity risk |
| 128 | +- Determines customer risk profile |
| 129 | +- Sets review frequency |
| 130 | + |
| 131 | +### 3. Transaction Monitoring |
| 132 | +- Detects structuring (smurfing) |
| 133 | +- Identifies rapid fund movement |
| 134 | +- Flags high-risk jurisdictions |
| 135 | +- Recognizes suspicious patterns |
| 136 | + |
| 137 | +### 4. Compliance Reporting |
| 138 | +- Generates structured reports |
| 139 | +- Documents findings |
| 140 | +- Recommends actions |
| 141 | +- Sets next review date |
| 142 | + |
| 143 | +## 💡 Use Cases |
| 144 | + |
| 145 | +- **Banks**: Customer onboarding compliance checks |
| 146 | +- **Fintechs**: Automated AML screening |
| 147 | +- **Regulators**: Audit and examination support |
| 148 | +- **Consultants**: Compliance program templates |
| 149 | + |
| 150 | +## 🔒 Privacy Mode |
| 151 | + |
| 152 | +The `main_gemma.py` version runs completely offline: |
| 153 | +- ✅ No data sent to cloud |
| 154 | +- ✅ Local Gemma 2B model |
| 155 | +- ✅ Works in air-gapped environments |
| 156 | +- ✅ No API costs |
| 157 | + |
| 158 | +## 🛠️ Extending |
| 159 | + |
| 160 | +### Add Real Sanctions API |
| 161 | +```python |
| 162 | +# Replace mock in sanctions_checker.py |
| 163 | +def check_sanctions_list(name: str) -> dict: |
| 164 | + # Integrate with real OFAC API |
| 165 | + response = requests.get(f"https://api.ofac.gov/search?name={name}") |
| 166 | + return response.json() |
| 167 | +``` |
| 168 | + |
| 169 | +### Add Database Storage |
| 170 | +```python |
| 171 | +# Store results in your compliance database |
| 172 | +from .database import save_compliance_report |
| 173 | +save_compliance_report(customer_id, report) |
| 174 | +``` |
| 175 | + |
| 176 | +## 📚 Learn More |
| 177 | + |
| 178 | +- [OpenAI Agents SDK Docs](https://github.com/openai/openai-agents-python) |
| 179 | +- [AML Compliance Basics](https://www.fincen.gov/resources/aml) |
| 180 | +- [Gemma Model](https://huggingface.co/google/gemma-2b-it) |
| 181 | + |
| 182 | +## 🤝 Contributing |
| 183 | + |
| 184 | +Contributions welcome! Areas for improvement: |
| 185 | +- Real sanctions API integration |
| 186 | +- Additional risk models |
| 187 | +- More transaction patterns |
| 188 | +- Multi-language support |
| 189 | + |
| 190 | +## 📝 License |
| 191 | + |
| 192 | +MIT License - See [LICENSE](../../LICENSE) for details |
| 193 | + |
| 194 | +--- |
| 195 | + |
| 196 | +**Built with ❤️ for the OpenAI Agents SDK** |
0 commit comments