Gedendhar-5/Govagent-Compliance-Auditor

GitHub: Gedendhar-5/Govagent-Compliance-Auditor

一个基于 LangGraph 的多 Agent 系统,通过自动化红队测试、隐私扫描与法规语义比对,为 LLM 应用提供多框架合规审计并生成标准化报告。

Stars: 0 | Forks: 0

# 🛡️ GovAgent — AI 合规审计师 ### _用于 AI 治理与监管合规的自主多 Agent 系统_ [![Python](https://img.shields.io/badge/Python-3.11+-3776AB?style=for-the-badge&logo=python&logoColor=white)](https://python.org) [![LangGraph](https://img.shields.io/badge/LangGraph-Agentic_AI-1C3C3C?style=for-the-badge&logo=langchain&logoColor=white)](https://langchain-ai.github.io/langgraph/) [![Groq](https://img.shields.io/badge/Groq-LLaMA_3.3_70B-F55036?style=for-the-badge&logo=meta&logoColor=white)](https://groq.com) [![Streamlit](https://img.shields.io/badge/Streamlit-Dashboard-FF4B4B?style=for-the-badge&logo=streamlit&logoColor=white)](https://streamlit.io) [![FAISS](https://img.shields.io/badge/FAISS-Vector_Search-0467DF?style=for-the-badge&logo=meta&logoColor=white)](https://github.com/facebookresearch/faiss) [![Docker](https://img.shields.io/badge/Docker-Containerized-2496ED?style=for-the-badge&logo=docker&logoColor=white)](https://docker.com) [![License](https://img.shields.io/badge/License-MIT-green?style=for-the-badge)](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
(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 ``` ## 📊 输出结果示例 ### 仪表板概览 ![仪表板](https://raw.githubusercontent.com/Gedendhar-5/Govagent-Compliance-Auditor/main/screenshots/dashboard.png) --> ### 合规评分仪表 ![评分](https://static.pigsec.cn/wp-content/uploads/repos/2026/06/49849bd26a164952.png) --> ### Agent 分析标签页 ![标签页](https://static.pigsec.cn/wp-content/uploads/repos/2026/06/2ef99a1da2164955.png) --> ![标签页1](https://static.pigsec.cn/wp-content/uploads/repos/2026/06/203da594f9164959.png) ## 🛠️ 快速开始 ### 前置条件 - **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绕过, 请求拦截, 逆向工具