Content
# Tool List
> Enterprise-level intelligent conversation and operation and maintenance assistant, supporting RAG knowledge base Q&A and AIOps intelligent diagnosis
[](https://www.python.org/)
[](https://fastapi.tiangolo.com/)
[](https://www.langchain.com/)
## ✨ Core Features
- 🤖 **Intelligent Conversation** - LangChain multi-turn conversation + streaming output
- 📚 **RAG Q&A** - Vector retrieval enhancement, supporting document upload, automatic vector index establishment, and automatic knowledge base update
- 🔧 **AIOps Diagnosis** - Plan-Execute-Replan automatic fault diagnosis and root cause analysis
- 🌐 **Web Interface** - Modern UI, supporting multiple conversation modes: quick Q&A/streaming conversation
- 🔌 **MCP Integration** - Log query and monitoring data tool access
## 🛠️ Tech Stack
- **Framework**: FastAPI + LangChain + LangGraph
- **LLM**: Alibaba Cloud DashScope (Tongyi Qianwen)
- **Vector Database**: Milvus
- **Tool Protocol**: MCP (Model Context Protocol)
## 🚀 Quick Start
### Environment Requirements
- Python 3.10+
- Alibaba Cloud DashScope API Key ([Get Address](https://dashscope.aliyun.com/))
### Installation and Launch
#### Linux/macOS Environment
```bash
# 1. Clone the project
git clone <repository_url>
cd ~/auto-oncall-system
# 2. Install dependencies (recommended to use uv)
# Method 1: Use uv (recommended, faster)
pip install uv
uv venv
source .venv/bin/activate
uv pip install -e .
# Method 2: Use pip
pip install -e .
# 3. Edit configuration file
# First use needs to edit .env file, fill in your DASHSCOPE_API_KEY
vim .env # or use other editors
# 4. One-click initialization (start Docker + service + document upload)
make init
# 5. One-click launch
make start
```
#### Windows Environment (PowerShell/CMD)
If Windows does not support the `make` command, you can manually execute the following steps to start the service:
```powershell
# 1. Clone the project
git clone <repository_url>
cd ~/auto-oncall-system
# 2. Create a virtual environment and install dependencies
# Method 1: Use uv (recommended, faster)
pip install uv
# Create a virtual environment
uv venv
# Activate the virtual environment
.venv\Scripts\activate
# Install all dependencies
uv pip install -e .
# Method 2: Use pip
python -m venv .venv
.venv\Scripts\activate
pip install -e .
# 3. Edit configuration file
# Open .env file with Notepad or other editors, fill in your DASHSCOPE_API_KEY
notepad .env
# 4. Start Docker Desktop
# Ensure Docker Desktop is installed and running
# 5. Start Milvus vector database (Docker Compose)
docker compose -f vector-database.yml up -d
# 6. Wait for Milvus to start (about 5-10 seconds)
timeout /t 10
# 7. Start MCP service
# Start CLS log query service (open a new PowerShell window)
python mcp_servers/cls_server.py
# Start Monitor monitoring service (open a new PowerShell window)
python mcp_servers/monitor_server.py
# 8. Start FastAPI main service (open a new PowerShell window)
# Note: Logs will be output to logs\app_YYYY-MM-DD.log
python -m uvicorn app.main:app --host 0.0.0.0 --port 9900
# 9. Upload documents to vector database (open a new PowerShell window)
# Wait for the service to start and then execute
timeout /t 5
python -c "import requests, os, time; [requests.post('http://localhost:9900/api/upload', files={'file': open(f'aiops-docs/{f}', 'rb')}) or time.sleep(1) for f in os.listdir('aiops-docs') if f.endswith('.md')]"
```
**Windows One-Click Launch Script** (recommended)
Use the launch script:
```powershell
# Launch all services
.\start-windows.bat
# Stop all services
.\stop-windows.bat
```
### Access Service
- **Web Interface**: http://localhost:9900
- **API Documentation**: http://localhost:9900/docs
## 📡 API Interface
### Core Interface
| Function | Method | Path | Description |
|------|------|------|------|
| Ordinary Conversation | POST | `/api/chat` | One-time return |
| Streaming Conversation | POST | `/api/chat_stream` | SSE streaming output |
| AIOps Diagnosis | POST | `/api/aiops` | Automatic fault diagnosis (streaming) |
| File Upload | POST | `/api/upload` | Upload and index documents |
| Health Check | GET | `/api/health` | Service status check |
### Example Usage
```bash
# Ordinary conversation
curl -X POST "http://localhost:9900/api/chat" \
-H "Content-Type: application/json" \
-d '{"Id":"session-123","Question":"Hello"}'
# Streaming conversation
curl -X POST "http://localhost:9900/api/chat_stream" \
-H "Content-Type: application/json" \
-d '{"Id":"session-123","Question":"Hello"}' \
--no-buffer
# AIOps diagnosis
curl -X POST "http://localhost:9900/api/aiops" \
-H "Content-Type: application/json" \
-d '{"session_id":"session-123"}' \
--no-buffer
```
## 📁 Project Structure
```
auto-oncall-system/
├── app/ # Application core
│ ├── __init__.py # Package initialization (automatic loading of log configuration)
│ ├── main.py # FastAPI application entry
│ ├── config.py # Configuration management (environment variables, MCP server configuration)
│ ├── api/ # API routing layer
│ │ ├── __init__.py
│ │ ├── chat.py # Conversation interface (RAG chat)
│ │ ├── aiops.py # AIOps interface (fault diagnosis)
│ │ ├── file.py # File management (document upload)
│ │ └── health.py # Health check (service status)
│ ├── services/ # Business service layer
│ │ ├── __init__.py
│ │ ├── rag_agent_service.py # RAG Agent (LangGraph state diagram)
│ │ ├── aiops_service.py # AIOps service (plan-execute-replan)
│ │ ├── vector_store_manager.py # Vector storage manager
│ │ ├── vector_embedding_service.py # Vector embedding service
│ │ ├── vector_index_service.py # Vector index service
│ │ ├── vector_search_service.py # Vector search service
│ │ └── document_splitter_service.py # Document splitter service
│ ├── agent/ # Agent module
│ │ ├── __init__.py
│ │ ├── mcp_client.py # MCP client (tool call)
│ │ └── aiops/ # AIOps core logic
│ │ ├── __init__.py
│ │ ├── planner.py # Planner
│ │ ├── executor.py # Executor
│ │ ├── replanner.py # Replanner
│ │ ├── state.py # State definition
│ │ └── utils.py # Tool functions
│ ├── models/ # Data model layer
│ │ ├── __init__.py
│ │ ├── aiops.py # AIOps model
│ │ ├── document.py # Document model
│ │ ├── request.py # Request model
│ │ └── response.py # Response model
│ ├── tools/ # Agent toolset
│ │ ├── __init__.py
│ │ ├── knowledge_tool.py # Knowledge base query tool
│ │ └── time_tool.py # Time tool
│ ├── core/ # Core components
│ │ ├── __init__.py
│ │ ├── llm_factory.py # LLM factory (model management)
│ │ └── milvus_client.py # Milvus client
│ └── utils/ # Tool classes
│ ├── __init__.py
│ └── logger.py # Log configuration (Loguru)
├── static/ # Web frontend (pure static)
│ ├── index.html # Main page
│ ├── app.js # Frontend logic
│ └── styles.css # Style sheet
├── mcp_servers/ # MCP servers
│ ├── cls_server.py # CLS log query service
│ ├── monitor_server.py # Monitoring data service
│ └── README.md # MCP service description
├── aiops-docs/ # Operation and maintenance knowledge base (Markdown documents)
├── logs/ # Log directory (Loguru automatic creation)
│ └── app_YYYY-MM-DD.log # Log file rotated by day
├── uploads/ # Temporary directory for uploaded files
├── volumes/ # Milvus data persistence directory
├── .env # Environment variable configuration (need to create manually)
├── Makefile # Project management commands (Linux/macOS)
├── start-windows.bat # Windows launch script
├── stop-windows.bat # Windows stop script
├── vector-database.yml # Milvus Docker Compose configuration
├── pyproject.toml # Project configuration (dependencies, metadata)
├── uv.lock # uv dependency lock file
├── pyrightconfig.json # Pyright type checking configuration
└── README.md # Project description
```
## ⚙️ Configuration Description
Configured through `.env` file:
```bash
# Alibaba Cloud LLM DashScope configuration (required)
# Key management: https://bailian.console.aliyun.com/cn-beijing/?spm=5176.29597918.J_SEsSjsNv72yRuRFS2VknO.2.61ac133ccTVQLw&tab=demohouse#/api-key
DASHSCOPE_API_KEY=your-api-key (configure your own key)
DASHSCOPE_API_BASE=https://dashscope.aliyuncs.com/compatible-mode/v1 # Default to Singapore site if not configured
DASHSCOPE_MODEL=qwen-max
# Milvus configuration
MILVUS_HOST=localhost
MILVUS_PORT=19530
# RAG configuration
RAG_TOP_K=3
CHUNK_MAX_SIZE=800
CHUNK_OVERLAP=100
```
## 🎯 AIOps Intelligent Operation and Maintenance
Based on **Plan-Execute-Replan** mode to achieve automatic fault diagnosis.
### Core Features
- ✅ Automatic diagnosis plan formulation (Planner)
- ✅ Intelligent tool calls (Executor)
- ✅ Dynamic step adjustment (Replanner)
- ✅ Streaming output of diagnosis process
- ✅ Generate structured report
### Quick Test
```bash
# Service has been started automatically through make init
# If you need to restart the service: make restart
# Access the Web interface, click "Intelligent Operation and Maintenance and Diagnosis Tool"
# Or use API
curl -X POST "http://localhost:9900/api/aiops" \
-H "Content-Type: application/json" \
-d '{"session_id":"test"}' \
--no-buffer
```
### Diagnosis Process
```
1. Planner formulates plan → Generate 4-6 diagnosis steps
2. Executor executes steps → Call MCP tools (log query, monitoring data)
3. Replanner evaluates results → Decide to continue/adjust/generate report
4. Output diagnosis report → Root cause analysis + operation and maintenance suggestions
```
## 📝 Development Guide
### Common Commands
```bash
# Project management
make init # One-click initialization (Docker + service + document)
make start # Launch all services
make stop # Stop all services
make restart # Restart all services
# Dependency management
make install-dev # Install development dependencies
make sync # Synchronize dependencies
# Docker management
make up # Launch Docker container
make down # Stop Docker container
# Code quality
make format # Format code
make lint # Code check
```
## 🐛 Frequently Asked Questions
### Windows Environment Issues
#### 1. `make` command not available
Windows does not support the `make` command, please use the provided batch script:
```powershell
# Launch service
.\start-windows.bat
# Stop service
.\stop-windows.bat
```
#### 2. PowerShell execution policy restriction
If you encounter "script cannot be loaded because script execution is disabled on this system" error:
```powershell
# Temporarily allow script execution (administrator privileges)
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process
# Or use CMD instead of PowerShell
cmd
.\start-windows.bat
```
#### 3. Port occupied (Windows)
```powershell
# View occupied port process
netstat -ano | findstr :9900
# End process (replace PID with actual process ID)
taskkill /F /PID <PID>
```
### General Issues
### API Key Error
```bash
# Check Environment Variables
cat .env | grep DASHSCOPE_API_KEY # Linux/macOS
type .env | findstr DASHSCOPE_API_KEY # Windows
```
### Milvus Connection Failure
```bash
# Ensure Docker service is available and running on your local machine (you can use Docker Desktop)
# Check Milvus status
docker ps | grep milvus
# Restart Milvus (using docker compose)
docker compose -f vector-database.yml restart
# Or restart a single service
docker compose -f vector-database.yml restart standalone
```
### Service Failure to Start
**Linux/macOS:**
```bash
# View service logs
tail -f logs/app_$(date +%Y-%m-%d).log # FastAPI main service (Loguru logs)
tail -f mcp_cls.log # CLS MCP service
tail -f mcp_monitor.log # Monitor MCP service
# Check port occupancy
lsof -i :9900 # FastAPI
lsof -i :8003 # CLS MCP
lsof -i :8004 # Monitor MCP
```
**Windows:**
```powershell
# View service logs (get today's date)
$today = Get-Date -Format "yyyy-MM-dd"
type logs\app_$today.log # FastAPI main service (Loguru logs)
type mcp_cls.log # CLS MCP service
type mcp_monitor.log # Monitor MCP service
# Or view the latest log file
Get-ChildItem logs\*.log | Sort-Object LastWriteTime -Descending | Select-Object -First 1 | Get-Content -Tail 50
# Check port occupancy
netstat -ano | findstr :9900 # FastAPI
netstat -ano | findstr :8003 # CLS MCP
netstat -ano | findstr :8004 # Monitor MCP
```
## 📚 Reference Resources
- [FastAPI Documentation](https://fastapi.tiangolo.com/)
- [LangChain Documentation](https://python.langchain.com/)
- [LangGraph Plan-Execute](https://langchain-ai.github.io/langgraph/tutorials/plan-and-execute/)
- [Alibaba Cloud DashScope](https://dashscope.aliyun.com/)
- [MCP Protocol](https://modelcontextprotocol.io/)
## 📄 License
MIT License
MCP Config
Below is the configuration for this MCP Server. You can copy it directly to Cursor or other MCP clients.
mcp.json
Connection Info
You Might Also Like
No recommendations available