Skip to content

Commit 41d3a7d

Browse files
committed
Add AML Compliance Agent example - Multi-agent workflow for AML compliance - Screening, risk assessment, transaction monitoring, reporting - Structured outputs with Pydantic models - Demo with 2 example customers (normal and high-risk) - Includes local Gemma version for offline/privacy use - Complete documentation and screenshot guide Related to financial compliance use cases.
1 parent 5086b24 commit 41d3a7d

18 files changed

+1955
-15
lines changed
Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
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+
![Loading](screenshot-01-start.png)
14+
*Loading Gemma 2B model locally*
15+
16+
#### 2. Sanctions Screening
17+
![Screening](screenshot-02-screening.png)
18+
*Step 1: Checking sanctions lists*
19+
20+
#### 3. Risk Assessment
21+
![Risk](screenshot-03-risk.png)
22+
*Step 2: Evaluating customer risk*
23+
24+
#### 4. Transaction Monitoring
25+
![Monitoring](screenshot-04-monitoring.png)
26+
*Step 3: Analyzing transactions*
27+
28+
#### 5. Compliance Report
29+
![Report](screenshot-05-report.png)
30+
*Step 4: Generating final report*
31+
32+
#### 6. Complete (100% Offline)
33+
![Complete](screenshot-06-complete.png)
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**
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
# 截图指南
2+
3+
## 📸 需要截图的场景
4+
5+
### 1. 启动画面
6+
```
7+
============================================================
8+
AML Compliance Agent - Local Gemma 2B (Offline)
9+
============================================================
10+
11+
Loading Gemma 2B model...
12+
Model loaded!
13+
```
14+
15+
**截图要点**:显示模型加载成功的信息
16+
17+
---
18+
19+
### 2. 制裁筛查步骤
20+
```
21+
[1/4] Running sanctions screening...
22+
Result: Risk Level: low
23+
Recommended Action: clear
24+
Details: No sanctions matches found...
25+
```
26+
27+
**截图要点**:显示步骤1完成,风险等级为low
28+
29+
---
30+
31+
### 3. 风险评估步骤
32+
```
33+
[2/4] Performing risk assessment...
34+
Result: Overall Risk: low
35+
Review Frequency: annual
36+
Justification: Standard customer profile...
37+
```
38+
39+
**截图要点**:显示步骤2完成,整体风险为low
40+
41+
---
42+
43+
### 4. 交易分析步骤
44+
```
45+
[3/4] Analyzing transactions...
46+
No alerts generated
47+
```
48+
49+
**截图要点**:显示步骤3完成,无预警
50+
51+
---
52+
53+
### 5. 报告生成步骤
54+
```
55+
[4/4] Generating compliance report...
56+
Report: Status: compliant
57+
Next Review: 2026-04-16
58+
Summary: Customer cleared all checks...
59+
```
60+
61+
**截图要点**:显示步骤4完成,状态为compliant
62+
63+
---
64+
65+
### 6. 完成画面
66+
```
67+
============================================================
68+
Compliance Check Complete (100% Offline)
69+
============================================================
70+
71+
Key Features:
72+
✓ 100% offline - no data leaves your machine
73+
✓ Local Gemma 2B model
74+
✓ Complete AML workflow
75+
✓ Privacy-preserving compliance checks
76+
```
77+
78+
**截图要点**:显示"100% Offline"完成信息
79+
80+
---
81+
82+
## 🎬 视频录制指南
83+
84+
### 录制步骤
85+
86+
1. **打开终端**
87+
```bash
88+
cd projects/openai-agents
89+
```
90+
91+
2. **开始录制** (Windows: Win + Alt + R)
92+
93+
3. **运行命令**
94+
```bash
95+
python -m examples.aml_compliance_agent.main_gemma
96+
```
97+
98+
4. **解说要点** (3-4分钟)
99+
- "这是一个完全离线的AML合规Agent"
100+
- "使用本地Gemma 2B模型,数据不出机器"
101+
- "演示4步合规流程:筛查→评估→监控→报告"
102+
- "适合银行、金融科技公司的隐私场景"
103+
104+
5. **结束录制** (Win + Alt + R)
105+
106+
### 视频保存位置
107+
```
108+
C:\Users\jie13\Videos\Captures\
109+
```
110+
111+
---
112+
113+
## 📋 截图命名
114+
115+
| 截图 | 文件名 |
116+
|------|--------|
117+
| 启动 | `screenshot-01-start.png` |
118+
| 筛查 | `screenshot-02-screening.png` |
119+
| 评估 | `screenshot-03-risk.png` |
120+
| 监控 | `screenshot-04-monitoring.png` |
121+
| 报告 | `screenshot-05-report.png` |
122+
| 完成 | `screenshot-06-complete.png` |
123+
124+
---
125+
126+
## 🎯 提交用途
127+
128+
- **GitHub PR**: 添加到 PR 描述中
129+
- **README**: 嵌入到文档中
130+
- **Devpost**: Gemma 4 Good 比赛提交
131+
132+
---
133+
134+
**提示**: 如果终端输出太快,可以在代码中添加 `time.sleep(1)` 暂停
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
"""
2+
AML Compliance Agent Example for OpenAI Agents SDK
3+
4+
This example demonstrates a multi-agent workflow for Anti-Money Laundering (AML)
5+
compliance, including customer screening, risk assessment, and suspicious activity
6+
monitoring.
7+
8+
Run with: python -m examples.aml_compliance_agent.main
9+
"""
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"""AML Compliance Agents"""
2+
3+
from .screening_agent import screening_agent
4+
from .risk_assessment_agent import risk_assessment_agent
5+
from .alert_agent import alert_agent
6+
from .report_agent import report_agent
7+
8+
__all__ = [
9+
"screening_agent",
10+
"risk_assessment_agent",
11+
"alert_agent",
12+
"report_agent",
13+
]

0 commit comments

Comments
 (0)