monodeep88/ai-langgraph-workflow-incident-response-workflow
GitHub: monodeep88/ai-langgraph-workflow-incident-response-workflow
基于 LangGraph 状态机和 RAG 的全栈事件响应工作流系统,通过多 Agent 协作实现事件管理、文档检索与带来源引用的智能问答。
Stars: 0 | Forks: 0
# 事件响应工作流
```
## 项目 Overview
Incident Response Workflow is a complete full-stack AI project for **LangGraph workflow** at **Intermediate** difficulty. It includes a FastAPI backend, a React frontend, sample documents, vector search with ChromaDB support, source citations, timeline logs, structured run storage, Docker files, and tests.
Incident Response is a critical process for organizations to respond to and manage incidents, minimizing their impact and ensuring business continuity.
Difficulty controls project complexity, architecture depth, AI model selection, and how advanced the generated codebase is.
- Architecture depth: FastAPI + React, ChromaDB vector search, better API structure, basic error handling
- Selected architecture: Incident Response Workflow
- Template path: templates/langgraph-workflow/incident-response-workflow
- Generated stack: FastAPI, React, ChromaDB-ready vector store, SQLAlchemy run logs
- README style: practical local setup with API and UI examples
## Tech Stack
- Backend: Python, FastAPI, Pydantic, SQLAlchemy
- AI/RAG: LangChain-ready prompt layer, ChromaDB vector storage, local deterministic fallback model
- Workflow: LangGraph state-machine style flow
- Frontend: React and Vite
- Database: SQLite by default, PostgreSQL through Docker Compose
- Testing: pytest
- Difficulty: Intermediate
## 生成方法
This project was generated with a template-based architecture engine. AI is used only for the blueprint, domain customization, sample data, prompts, and documentation. The codebase is produced from tested FastAPI/React/Docker templates rather than raw LLM source output.
## 文件夹结构
```text
ai-langgraph-workflow-incident-response-workflow/
backend/
app/
main.py
config.py
db.py
schemas.py
data/sample_docs/
services/
text.py
vector_store.py
llm.py
tools.py
pipeline.py
tests/
test_project_contract.py
requirements.txt
Dockerfile
frontend/
src/
App.jsx
main.jsx
styles.css
package.json
Dockerfile
docker-compose.yml
.env.example
README.md
```
## Environment Variables
```env
OPENAI_API_KEY=
OPENAI_MODEL=gpt-4o-mini
DATABASE_URL=sqlite:///./app.db
ALLOWED_ORIGINS=http://localhost:5173,http://localhost:3000
VITE_API_URL=http://localhost:8000
```
The app runs without an OpenAI key by using a deterministic local answer model. Add `OPENAI_API_KEY` to use LangChain with OpenAI.
## 安装
```bash
cd backend
python -m venv .venv
.venv\Scripts\activate
pip install -r requirements.txt
```
```bash
cd ../frontend
npm install
```
## 运行 Backend
```bash
cd backend
uvicorn app.main:app --reload --port 8000
```
## 运行 Frontend
```bash
cd frontend
npm run dev
```
## 使用 Docker 运行
```bash
docker compose up --build
```
## 示例 API 请求
```bash
curl -X POST http://localhost:8000/api/ask ^
-H "Content-Type: application/json" ^
-d "{\"question\": \"What is the refund policy?\"}"
```
## 示例用户问题
```text
What should I do if a customer asks for a refund without an order id?
```
## 预期输出
The API returns:
- `answer`: a grounded answer generated from retrieved context
- `sources`: cited document chunks with similarity scores
- `steps`: planner, retriever, reasoning, tool-call, and final-answer timeline logs
- `project_type`: `LangGraph workflow`
## RAG/Agent 流程工作原理
LangGraph state machine with plan, retrieve, reason, tool, and final nodes.
## Project Planner Agent 工作流程
User -> React Dashboard -> FastAPI -> Project Planner Agent -> Specialist Agents -> Generated Project -> Auto Testing -> GitHub Repository Creation -> Push Code -> Return GitHub URL
- **Architecture Agent**: Define app boundaries, data flow, runtime stack, and integration points. Outputs: Use a message broker (e.g., RabbitMQ) for communication between services.; Implement a database (e.g., PostgreSQL) for storing incident data.; Use a caching layer (e.g., Redis) for improving performance..
```
- **Backend Agent**:设计 FastAPI 模块、服务契约、验证和错误处理。输出:incident_management:处理事件的创建、分配和跟踪。;communication:管理与利益相关者的沟通,包括电子邮件和 SMS 通知。;reporting:生成有关事件状态、影响和解决情况的报告。。
- **Frontend Agent**:设计 React 界面、状态流、控件和用户反馈状态。输出:incident_dashboard:显示事件状态、分配和跟踪信息。;communication_panel:允许团队成员与利益相关者沟通。;reporting_tool:提供有关事件状态、影响和解决情况的报告。。
- **Database Agent**:设计持久化模型、样本数据、索引和审计记录。输出:运行历史;源文档元数据;生成的工作流审计记录。
- **Testing Agent**:定义契约测试、冒烟测试和生成的项目验证。输出:结合使用单元测试、集成测试和端到端测试,以确保工作流正常运行。。
- **DevOps Agent**:定义环境变量、Docker 工作流和仓库打包。输出:Docker 就绪的项目;环境样本文件;GitHub 仓库上传。
- **Reviewer Agent**:审查生成计划的完整性、安全性和作品集质量。输出:incident_creation:创建新事件并将其分配给团队成员。;incident_assignment:将事件分配给团队成员并通知利益相关者。;incident_tracking:跟踪事件状态并相应地更新利益相关者。。
AI 定制领域工作流
- incident_creation:创建新事件并将其分配给团队成员。
- incident_assignment:将事件分配给团队成员并通知利益相关者。
- incident_tracking:跟踪事件状态并相应地更新利益相关者。
业务规则
- 事件必须在创建后 30 分钟内分配给团队成员。
- 团队成员必须每 2 小时更新一次事件状态。
- 必须在 1 小时内将事件更新通知利益相关者。
1. 后端从 `backend/app/data/sample_docs` 加载样本文档。
2. 文档被分块。
3. 块被嵌入并存储在 ChromaDB 中(如果可用),并提供本地回退以供开发使用。
4. 用户问题将与相关块进行匹配。
5. 运行特定于 Agent 的步骤:planner、retriever、tool call、reasoning、reviewer 或 graph nodes。
6. 返回最终答案以及来源引用和时间线。
测试
cd backend
pytest
推送到 GitHub 前的验证门
SaaS 会在创建并推送 GitHub 仓库之前验证生成的项目:
- `pytest`
- `npm install`
- `npm run build`
- `docker compose config`
- `docker compose build`
标签:AV绕过, ChromaDB, FastAPI, LangGraph, RAG, React, Syscalls, 安全规则引擎, 测试用例, 请求拦截, 逆向工具