Files
AIRegulation-Deployment/README.md
2026-04-23 09:58:47 +08:00

191 lines
4.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# AI合规智能中枢 — 调研版部署指南
面向车企与工厂的全链路合规智能平台Docker Compose 单机部署版本,用于验证三条业务闭环。
## 快速开始
### 前置要求
| 资源 | 最低 | 推荐 |
|------|------|------|
| CPU | 8核 | 16核+ |
| 内存 | 32 GB | 64 GB |
| 存储 | 200 GB SSD | 500 GB SSD |
| GPU | 无需 | 1× RTX 3090加速嵌入|
| OS | Ubuntu 22.04 LTS 或 Windows 11 + WSL2 | — |
### 1. 安装 Docker
**Ubuntu/Linux**
```bash
bash scripts/00_install_docker_ubuntu.sh
```
**WindowsPowerShell 管理员):**
```powershell
.\scripts\00_install_docker_windows.ps1
```
### 2. 配置环境变量
```bash
cp .env.example .env
# 编辑 .env至少填写
# - DEEPSEEK_API_KEY在 https://platform.deepseek.com 申请)
nano .env
```
### 3. 一键启动
```bash
# 拉取镜像(可选,加速首次启动)
bash scripts/02_pull_images.sh
# 分步启动(推荐,含健康等待)
bash scripts/06_start_all.sh
```
### 4. 验证部署
```bash
# 检查所有服务状态
bash scripts/check_health.sh
# 运行端到端冒烟测试
bash scripts/07_smoke_test.sh
```
---
## 服务访问地址
| 服务 | 地址 | 说明 |
|------|------|------|
| API 网关 | http://localhost | Nginx 入口,所有 API 请求入口 |
| 业务后端 | http://localhost:8000/docs | FastAPI Swagger UI |
| Neo4j 浏览器 | http://localhost:7474 | 知识图谱可视化 |
| Grafana | http://localhost:3000 | 监控面板(`--profile monitoring` 启动)|
| Milvus | localhost:19530 | 向量数据库 gRPC 端口 |
---
## 三条业务闭环
### 闭环①:法规入库 → 检索问答
```bash
# 上传法规PDF
curl -X POST http://localhost/api/kb/files/upload \
-F "file=@your_regulation.pdf" \
-F "workspace_id=auto-regulation"
# 查询任务状态
curl http://localhost/api/kb/tasks/{task_id}
# 检索问答
curl -X POST http://localhost/api/kb/qa \
-H "Content-Type: application/json" \
-d '{"query": "GB 18384 电动汽车碰撞安全要求", "top_k": 5}'
```
### 闭环②:文档上传 → 合规审查
```bash
# 上传供应商文件
curl -X POST http://localhost/api/compliance/upload \
-F "file=@supplier_document.pdf"
# 触发合规审查
curl -X POST http://localhost/api/compliance/check \
-H "Content-Type: application/json" \
-d '{"doc_id": "xxx", "regulation_domains": ["vehicle_safety", "data_security"]}'
# 获取审查报告
curl http://localhost/api/compliance/report/{id}
```
### 闭环③:法规监控 → 变更推送
```bash
# 配置监控源
curl -X POST http://localhost/api/regulation/sources \
-H "Content-Type: application/json" \
-d '{"url": "https://std.samr.gov.cn", "name": "国家标准全文公开"}'
# 查看变更记录
curl http://localhost/api/regulation/updates
```
---
## 目录结构
```
Depolyment/
├── README.md # 本文件
├── docker-compose.yml # 全服务编排
├── .env.example # 环境变量模板
├── scripts/ # 安装与运维脚本
├── services/
│ ├── embedding/ # BGE-M3 嵌入服务
│ ├── mcp-server/ # MinerU 文档解析服务
│ └── compliance-backend/ # 核心业务后端
├── config/ # Nginx、Prometheus 配置
├── init-sql/ # PostgreSQL 初始化 SQL
├── data/ # 运行时数据(上传文件、解析结果)
├── logs/ # 服务日志
└── models/ # AI 模型缓存BGE-M3、MinerU
```
---
## 常用操作
```bash
# 查看所有服务状态
docker compose ps
# 查看某个服务日志
docker compose logs -f compliance-backend
# 重启某个服务
docker compose restart embedding-service
# 停止所有服务(保留数据)
docker compose stop
# 完全重置(删除所有数据,慎用)
bash scripts/reset_all.sh
# 启动监控面板
docker compose --profile monitoring up -d grafana
```
---
## LLM 切换
默认使用 DeepSeek API如需切换到 Qwen阿里云
编辑 `.env`
```bash
LLM_PROVIDER=qwen
DASHSCOPE_API_KEY=your_key_here
QWEN_MODEL=qwen-plus
```
然后重启业务服务:
```bash
docker compose restart compliance-backend celery-worker
```
---
## 生产升级路径
调研验证通过后,升级要点:
1. **LLM**:从 API 切换到本地 vLLM + DeepSeek-V3需要 4×A100
2. **Milvus**:从 Standalone 升级到分布式集群(加独立 MinIO
3. **编排**:从 Docker Compose 迁移到 Kubernetes服务配置文件可复用
4. **安全**:启用完整 JWT/RBAC添加 TLS 证书