Gedendhar-5/Govagent-Compliance-Auditor
GitHub: Gedendhar-5/Govagent-Compliance-Auditor
一个基于 LangGraph 的多 Agent 系统,通过自动化红队测试、隐私扫描与法规语义比对,为 LLM 应用提供多框架合规审计并生成标准化报告。
Stars: 0 | Forks: 0
# 🛡️ GovAgent — AI 合规审计师
### _用于 AI 治理与监管合规的自主多 Agent 系统_
[](https://python.org)
[](https://langchain-ai.github.io/langgraph/)
[](https://groq.com)
[](https://streamlit.io)
[](https://github.com/facebookresearch/faiss)
[](https://docker.com)
[](LICENSE)
**GovAgent** 是一个生产级、多 Agent 合规审计框架,用于根据全球监管标准(包括 **EU AI Act**、**NIST AI RMF**、**GDPR** 和 **ISO 42001**)评估 AI/LLM 应用。它通过由 **LangGraph** 编排的专用 AI Agent 协同集群来完成这一过程。 [🚀 在线演示](https://govagent-compliance-auditor-thbzxom9qqlkoqvjina6rm.streamlit.app/) · [📖 架构设计](#-system-architecture) · [🧠 Agent](#-agent-pipeline) · [📊 输出结果](#-sample-output) · [🛠️ 设置指南](#️-getting-started)
## ✨ 为什么选择 GovAgent?
| 问题 | GovAgent 解决方案 |
|:---|:---|
| 人工合规审查缓慢且成本高昂 | ⚡ 不到 60 秒即可完成全自动审计 |
| 审计人员容易忽略跨法规的冲突 | 🔗 基于 RAG 的法规交叉引用 |
| 缺乏标准化的 AI 审计报告 | 📄 生成官方的 **AI Compliance Passport** (PDF) |
| 安全测试往往被滞后考虑 | 🔴 内置对抗性红队测试与越狱模拟 |
| 偏见检测很少被量化 | 📊 自动化毒性与公平性评分 |
## 🏗️ 系统架构
```
graph TB
subgraph UI["🖥️ Streamlit Dashboard"]
A["User Input**GovAgent** 是一个生产级、多 Agent 合规审计框架,用于根据全球监管标准(包括 **EU AI Act**、**NIST AI RMF**、**GDPR** 和 **ISO 42001**)评估 AI/LLM 应用。它通过由 **LangGraph** 编排的专用 AI Agent 协同集群来完成这一过程。 [🚀 在线演示](https://govagent-compliance-auditor-thbzxom9qqlkoqvjina6rm.streamlit.app/) · [📖 架构设计](#-system-architecture) · [🧠 Agent](#-agent-pipeline) · [📊 输出结果](#-sample-output) · [🛠️ 设置指南](#️-getting-started)
(Model Name + Description)"] B["Real-Time Progress Tracker"] C["Results Dashboard + PDF Export"] end subgraph Engine["⚙️ LangGraph Orchestration Engine"] D["init_audit
UUID Generation + State Init"] subgraph Parallel["🔀 Parallel Fan-Out (Concurrent Execution)"] E["🏛️ Legal Auditor"] F["🔴 Red-Team Agent"] G["🔒 Privacy Sentinel"] H["⚖️ Bias Analyzer"] end I["👔 Chief Compliance Officer
Fan-In Aggregation"] end subgraph Knowledge["📚 Knowledge Layer"] J["FAISS Vector Store
Regulatory Embeddings"] K["Regulation Corpus
EU AI Act • NIST • GDPR • ISO 42001"] end subgraph Infra["🏭 Infrastructure"] L["Groq Cloud
LLaMA 3.3 70B"] M["PDF Generator
AI Compliance Passport"] end A --> D D --> E & F & G & H E --> I F --> I G --> I H --> I I --> C E -.->|RAG Query| J J -.->|Embeddings| K E & F & G & H -.->|LLM Calls| L I --> M B -.->|Stream Events| Engine style UI fill:#1a1a2e,stroke:#e94560,color:#fff style Engine fill:#16213e,stroke:#0f3460,color:#fff style Parallel fill:#0f3460,stroke:#533483,color:#fff style Knowledge fill:#1a1a2e,stroke:#e94560,color:#fff style Infra fill:#16213e,stroke:#0f3460,color:#fff ``` ## 🧠 Agent Pipeline 核心引擎采用 **fan-out / fan-in** 架构 —— 四个专家 Agent **并发**运行,然后由首席合规官将所有发现**聚合**为统一的裁定结果。 ``` graph LR START(("▶ START")) --> INIT["🔧 init_audit"] INIT --> LEG["🏛️ Legal Auditor
────────────
• EU AI Act compliance
• NIST AI RMF mapping
• ISO 42001 alignment
• RAG-powered analysis"] INIT --> RED["🔴 Red-Team Agent
────────────
• Jailbreak simulation
• Prompt injection tests
• Safety bypass attempts
• Multi-round attacks"] INIT --> PRI["🔒 Privacy Sentinel
────────────
• PII detection scan
• API key/secret leaks
• GDPR Article mapping
• Data flow analysis"] INIT --> BIA["⚖️ Bias Analyzer
────────────
• Toxicity scoring
• Demographic fairness
• Stereotype detection
• Harm assessment"] LEG --> CCO["👔 Chief Compliance
Officer
────────────
• Weighted scoring
• Risk classification
• Executive summary
• Certification decision"] RED --> CCO PRI --> CCO BIA --> CCO CCO --> DONE(("✅ END")) style START fill:#00d2ff,stroke:#333,color:#000 style DONE fill:#00d2ff,stroke:#333,color:#000 style INIT fill:#533483,stroke:#e94560,color:#fff style LEG fill:#0f3460,stroke:#e94560,color:#fff style RED fill:#e94560,stroke:#fff,color:#fff style PRI fill:#0f3460,stroke:#e94560,color:#fff style BIA fill:#0f3460,stroke:#e94560,color:#fff style CCO fill:#533483,stroke:#e94560,color:#fff ``` ### 评分方法 | Agent | 权重 | 评估内容 | |:---|:---:|:---| | 🏛️ **法律审计师** | 30% | 监管框架合规性 (EU AI Act, NIST, ISO 42001) | | 🔴 **红队 Agent** | 25% | 对抗鲁棒性与越狱抵抗力 | | 🔒 **隐私哨兵** | 25% | PII 泄露、数据外泄、GDPR 对齐情况 | | ⚖️ **偏见分析器** | 20% | 毒性水平、公平性指标、刻板印象检测 | ## 🧰 技术栈
| 层级 | 技术 | 用途 |
|:---|:---|:---|
| **编排** | LangGraph (StateGraph) | 具有 fan-out/fan-in 拓扑结构的多 Agent DAG |
| **LLM 骨干** | Groq Cloud + LLaMA 3.3 70B | 为所有 Agent 的推理提供超快推理速度 |
| **RAG Pipeline** | FAISS + Sentence Transformers | 对法规语料库进行语义搜索 |
| **法规语料库** | EU AI Act, NIST AI RMF, GDPR, ISO 42001 | 包含 40 多项嵌入的监管条款 |
| **状态管理** | TypedDict + Annotated Reducers | 类型安全的并发状态合并 |
| **前端** | Streamlit | 带有进度流式传输的实时仪表板 |
| **PDF 生成** | FPDF2 | 导出官方的 AI Compliance Passport |
| **容器化** | Docker + Docker Compose | 一键部署 |
| **语言** | Python 3.11+ | 端到端实现 |
## 📁 项目结构
```
govagent-compliance-auditor/
│
├── 📂 app/
│ └── main.py # Streamlit dashboard (810 lines)
│
├── 📂 src/
│ ├── state.py # AuditState TypedDict schema
│ ├── graph.py # LangGraph workflow topology
│ ├── llm.py # Centralized LLM factory
│ ├── pdf_passport.py # PDF Compliance Passport generator
│ │
│ ├── 📂 agents/
│ │ ├── legal_auditor.py # 🏛️ Legal Compliance Agent
│ │ ├── red_teamer.py # 🔴 Red-Team Security Agent
│ │ ├── privacy_sentinel.py # 🔒 Privacy Sentinel Agent
│ │ ├── bias_analyzer.py # ⚖️ Bias & Fairness Analyzer
│ │ └── compliance_officer.py # 👔 Chief Compliance Officer
│ │
│ └── 📂 mcp/
│ ├── vector_store.py # FAISS index builder & query engine
│ ├── regulations.py # Regulatory corpus (EU AI Act, NIST, etc.)
│ ├── mcp_server.py # MCP protocol server
│ └── tools.py # MCP tool definitions
│
├── 📂 tests/
│ └── mock_target.py # Mock LLM for testing
│
├── 📂 data/ # Auto-generated FAISS index (gitignored)
│
├── Dockerfile # Container build definition
├── docker-compose.yml # Service orchestration
├── requirements.txt # Python dependencies
├── run_phase1_test.py # End-to-end test runner
├── .env # API keys (gitignored — see setup)
└── .gitignore # Security exclusions
```
## 📊 输出结果示例
### 仪表板概览

-->
### 合规评分仪表

-->
### Agent 分析标签页

-->

## 🛠️ 快速开始
### 前置条件
- **Python 3.11+**
- **Groq API Key** → [在 console.groq.com 免费获取](https://console.groq.com/keys)
### 1. 克隆代码库
```
git clone https://github.com/YOUR_USERNAME/govagent-compliance-auditor.git
cd govagent-compliance-auditor
```
### 2. 安装依赖项
```
pip install -r requirements.txt
```
### 3. 配置环境
在根目录下创建一个 `.env` 文件:
```
GROQ_API_KEY=your-groq-api-key-here
GROQ_MODEL=llama-3.3-70b-versatile
```
### 4. 启动仪表板
```
streamlit run app/main.py
```
FAISS 法规索引会在首次启动时自动构建。打开 **http://localhost:8501** 运行你的首次审计!🚀
## 🐳 Docker 部署
```
# 构建并启动
docker compose up --build -d
# 查看日志
docker compose logs -f
# 停止
docker compose down
```
仪表板可通过 **http://localhost:8501** 访问
## ☁️ 部署到 Streamlit Cloud
1. 将此代码库推送到 GitHub
2. 访问 [share.streamlit.io](https://share.streamlit.io)
3. 连接你的 GitHub 代码库
4. 设置 **Main file path** → `app/main.py`
5. 在 **Settings → Secrets** 中添加你的 `GROQ_API_KEY`
6. 点击 **Deploy** 🚀
## 🧪 运行测试
```
python run_phase1_test.py
```
运行完整的端到端审计 pipeline,包含 12 项断言检查,涵盖图执行、Agent 输出、评分和 passport 生成。
## 🔮 路线图
- [ ] 📡 真实 LLM endpoint 测试(实时 API 探测)
- [ ] 🔌 用于自定义监管框架的插件系统
- [ ] 📈 历史审计趋势分析
- [ ] 🌐 多语言法规支持
- [ ] 🤖 自动修复建议引擎
- [ ] 📋 SOC 2 和 HIPAA 合规模块
## 🏛️ 合规覆盖范围
| 法规 | 地区 | 状态 |
|:---|:---|:---:|
| EU AI Act (2024) | 🇪🇺 欧盟 | ✅ 已实现 |
| NIST AI RMF | 🇺🇸 美国 | ✅ 已实现 |
| GDPR | 🇪🇺 欧盟 | ✅ 已实现 |
| ISO/IEC 42001 | 🌍 国际 | ✅ 已实现 |
## 📄 许可证
本项目基于 **MIT License** 授权 —— 有关详细信息,请参阅 [LICENSE](LICENSE) 文件。标签:AI治理, Kubernetes, LangGraph, RAG, 人工智能, 多智能体, 数据隐私, 用户模式Hook绕过, 请求拦截, 逆向工具