sd031/ai_powered_incident_response_agent
GitHub: sd031/ai_powered_incident_response_agent
一个基于大语言模型的自治 SRE 智能体,能够自动接收告警、调查基础设施并生成结构化根因分析报告,无需人工介入。
Stars: 6 | Forks: 4
# AI 驱动的事件响应智能体






## 快速开始
### 选项 A — Anthropic API(推荐)
```
# 1. 克隆并进入项目
git clone https://github.com/sd031/ai_powered_incident_response_agent.git ai_powered_incident_response_agent
cd ai_powered_incident_response_agent
# 2. 创建 virtualenv 并安装依赖
python3 -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
# 3. 配置
cp .env.example .env
# 在 .env 中设置:
# LLM_BACKEND=anthropic
# ANTHROPIC_API_KEY=sk-ant-...
# 4. 启动服务器
python main.py
# → 监听于 http://localhost:8080
```
### 选项 B — 本地模型(Ollama,无需 API 密钥)
```
# 安装 Ollama:https://ollama.com
ollama pull qwen2.5:7b # ~4.7 GB, excellent tool calling
# 在 .env 中设置:
# LLM_BACKEND=ollama
# OLLAMA_MODEL=qwen2.5:7b
python main.py
```
### 选项 C — AWS Bedrock
```
# 在 .env 中设置:
# LLM_BACKEND=bedrock
# AWS_REGION=us-east-1
# BEDROCK_API_KEY=bk-us-... # 或改为使用 IAM credentials
python main.py
```
### 触发调查
```
curl -X POST http://localhost:8080/investigate \
-H 'Content-Type: application/json' \
-d '{
"title": "checkout-service: high 5xx error rate",
"severity": "high",
"service": "checkout",
"description": "Error rate jumped from 0.1% to 15% at 14:32 UTC",
"labels": {"namespace": "production", "env": "prod"}
}'
```
响应是一个结构完整的 `IncidentReport` JSON,包含排序后的假设、时间线和推荐操作。交互式 API 文档位于 `http://localhost:8080/docs`。
## 后端选择
在 `.env` 中设置 `LLM_BACKEND`:
| `LLM_BACKEND` | 所需认证 | 亮点 |
|---|---|---|
| `anthropic` | `ANTHROPIC_API_KEY` | 最佳质量;自适应思维 + 提示词缓存;流式传输 |
| `bedrock` | `BEDROCK_API_KEY` **或** IAM | AWS 原生;无需 Anthropic 账户;支持 AWS 上的任何 Claude 模型 |
| `ollama` | 无 | 免费;完全本地化;数据不会离开本机 |
| `vllm` | 无 | GPU 加速的本地推理 |
| `lmstudio` | 无 | 基于 GUI 的本地推理 |
| `llamacpp` | 无 | 基于 GGUF 文件的 CPU/GPU 推理 |
## 完整文档
[learnxops.com — AI 驱动的事件响应智能体](https://www.learnxops.com/project-ai-powered-incident-response-agent/)
# ai_powered_incident_response_agent
标签:AIOps, AI运维, AI风险缓解, Anthropic, AV绕过, AWS Bedrock, CIS基准, Claude, CVE检测, DLL 劫持, FastAPI, IT运维, LLM评估, Ollama, OpsGenie, PagerDuty, Python, Socks5代理, SRE, 云原生运维, 偏差过滤, 告警降噪, 大语言模型, 故障排查, 无后门, 智能告警, 根因分析, 自动化报告, 自动化运维, 逆向工具