https://github.com/pheonix-19/opsai
OpsAI (Operational AI) is an intelligent IT support automation platform that uses AI to automatically categorize tickets, suggest solutions, and route requests to the right teams. Built with advanced NLP and machine learning technologies, it integrates with Jira, Slack, and Freshdesk to streamline operational workflows and improve response times.
https://github.com/pheonix-19/opsai
docker fastapi freshdesk grafana helpdesk-automation huggingface lora machine-learning nlp peft prometheus sentence-transformers slack-bot transformers
Last synced: about 2 months ago
JSON representation
OpsAI (Operational AI) is an intelligent IT support automation platform that uses AI to automatically categorize tickets, suggest solutions, and route requests to the right teams. Built with advanced NLP and machine learning technologies, it integrates with Jira, Slack, and Freshdesk to streamline operational workflows and improve response times.
- Host: GitHub
- URL: https://github.com/pheonix-19/opsai
- Owner: pheonix-19
- Created: 2025-07-23T16:48:23.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2025-08-13T19:02:41.000Z (2 months ago)
- Last Synced: 2025-08-13T20:51:28.843Z (2 months ago)
- Topics: docker, fastapi, freshdesk, grafana, helpdesk-automation, huggingface, lora, machine-learning, nlp, peft, prometheus, sentence-transformers, slack-bot, transformers
- Language: Python
- Homepage:
- Size: 2.43 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ๐ค OpsAI: Intelligent IT Support Automation
[](https://github.com/pheonix-19/OpsAI)
[](https://github.com/pheonix-19/OpsAI/fork)
[](https://opensource.org/licenses/MIT)
[](https://www.python.org/downloads/)
[](https://www.docker.com/)
[](https://fastapi.tiangolo.com/)> **Transform your IT helpdesk with AI-powered ticket triage and resolution suggestions**
OpsAI is an advanced AI system that revolutionizes IT support operations by automatically categorizing tickets, suggesting solutions, and routing requests to the right teams. Using cutting-edge vector embeddings and fine-tuned language models, it learns from historical data to provide instant, contextual support recommendations.
## ๏ฟฝ **Live Screenshots**
**๐ฅ๏ธ Grafana Dashboard in Action:**

*Real-time monitoring dashboard showing API metrics, request rates, and system health***๐ Prometheus Metrics Collection:**

*Prometheus collecting and displaying OpsAI application metrics***โ๏ธ Prometheus Configuration & Targets:**

*Prometheus monitoring targets and service discovery configuration*## ๏ฟฝ๐ **Table of Contents**
- [๐ธ Live Screenshots](#-live-screenshots)
- [๐๏ธ System Architecture](#๏ธ-system-architecture--components)
- [๐ฏ What Problem Does OpsAI Solve?](#-what-problem-does-opsai-solve)
- [โจ Core Features](#-core-features)
- [๐ Quick Demo](#-quick-demo)
- [๐ Prerequisites](#-prerequisites)
- [โก Installation & Setup](#-installation--setup)
- [๐ฎ API Endpoints Reference](#-api-endpoints-reference)
- [๐ Monitoring & Observability](#-monitoring--observability)
- [๐ Project Structure](#-project-structure)
- [๐ Security & Secrets Management](#-security--secrets-management)
- [๐ณ Docker & Deployment](#-docker--deployment)
- [๐ Enterprise Integrations](#-enterprise-integrations)
- [๐งช Testing & Development](#-testing--development)
- [๐จ Troubleshooting](#-troubleshooting)
- [๐ Quick Start Guide](#-quick-start-guide)
- [๐ Additional Resources](#-additional-resources)
- [๐ค Contributing](#-contributing)
- [๐ License & Support](#-license--support)Intelligent IT Support Automation> **Transform your IT helpdesk with AI-powered ticket triage and resolution suggestions**
OpsAI is an ad## ๐ **Security & Secrets Management**anced AI system that revolutionizes IT support operations by automatically categorizing tickets, suggesting solutions, and routing requests to the right teams. Using cutting-edge vector embeddings and fine-tuned language models, it learns from historical data to provide instant, contextual support recommendations.
## ๐๏ธ **System Architecture & Components**
```
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐ค OpsAI System Architecture โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ๐ค Users ๐ง IT Teams ๐ Stakeholders
โ โ โ
โผ โผ โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐ Integration Layer โ
โโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ ๐ Jira โ ๐ฌ Slack Bot โ ๐ซ Freshdesk โ ๐ Custom APIs โ
โ Webhooks โ Real-time โ Ticket Sync โ REST Endpoints โ
โ Automation โ Notifications โ Customer Mgmt โ External Systems โ
โโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ โ
โโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโ
โผ โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐ FastAPI Server (Port 8000) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ ๐ Endpoints: /classify | /resolve | /feedback | /metrics | /docs โ
โ โ โ โ โ โ โ
โ โผ โผ โผ โผ โผ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐ง AI/ML Processing Core โ
โโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโค
โ ๐ Vector Search โ ๐ค Language Model โ ๐ฏ Classification โ ๐ Learning โ
โ โ โ โ โ
โ ๐ Embeddings: โ ๐งฌ Model: โ ๐ท๏ธ Labels: โ ๐ Training: โ
โ โข sentence-trans โ โข GPT-Neo-125M โ โข auth, network โ โข LoRA โ
โ โข all-MiniLM-L6-v2 โ โข LoRA Fine-tuned โ โข performance, mail โ โข Adaptation โ
โ โข Vector Similarity โ โข Context-aware โ โข Team Routing โ โข Feedback โ
โ โ โ โ โ
โ ๐๏ธ FAISS Index: โ ๐ญ Generation: โ ๐ฏ Mapping: โ ๐ Updates: โ
โ โข Fast Search โ โข Solution Suggest โ โข IT Helpdesk โ โข Continuous โ
โ โข Metadata Store โ โข Context Tickets โ โข Engineering โ โข Improvementโ
โโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐พ Data Storage Layer โ
โโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโค
โ ๐ Raw Data โ โ๏ธ Processed โ ๐๏ธ Vector Index โ ๐ Models โ
โ โ โ โ โ
โ ๐ tickets.csv โ ๐ Normalized: โ ๐ FAISS Database: โ ๐งฌ Weights: โ
โ ๐ tickets.json โ โข ticket_0.json โ โข ticket_index โ โข LoRA โ
โ ๐ Historical Data โ โข ticket_1.json โ โข ticket_meta.pkl โ โข Adapters โ
โ ๐ Continuous Feed โ โข Clean Format โ โข Fast Retrieval โ โข Fine-tuned โ
โ โ โข Standardized โ โข Similarity Search โ โข Checkpoint โ
โโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐ Monitoring & Observability โ
โโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโค
โ ๐ Prometheus โ ๐ Grafana โ ๐จ Alerting โ ๐ Logging โ
โ (Port 9090) โ (Port 3000) โ โ โ
โ โ โ โ โ
โ ๐ Metrics: โ ๐ Dashboards: โ ๐จ Alerts: โ ๐๏ธ Logs: โ
โ โข Request Count โ โข Performance โ โข High Error Rate โ โข API Calls โ
โ โข Response Time โ โข Error Rates โ โข Slow Response โ โข Model Inf. โ
โ โข AI Performance โ โข Business KPIs โ โข System Down โ โข Debug Info โ
โ โข System Health โ โข Real-time Charts โ โข Auto-notification โ โข Audit Trailโ
โโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐ณ Infrastructure Layer โ
โโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโค
โ ๐ณ Docker Setup โ ๐ Python Env โ ๐ฅ Hardware โ โ๏ธ CI/CD โ
โ โ โ โ โ
โ ๐ Services: โ ๐ฆ Dependencies: โ ๐ป Requirements: โ ๐ Pipeline: โ
โ โข API Container โ โข transformers โ โข Python 3.11+ โ โข GitHub โ
โ โข Prometheus โ โข fastapi โ โข 8GB+ RAM โ โข Actions โ
โ โข Grafana โ โข torch โ โข CUDA GPU (opt) โ โข Testing โ
โ โข Auto-scaling โ โข faiss-cpu โ โข 4GB Disk โ โข Deploy โ
โโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐ Data Flow Direction โ
โ โ
โ Tickets โ Integration โ API โ AI Processing โ Data Storage โ Monitoring โ
โ โ โ โ โ
โ Feedback โโโ Solutions โโโ Intelligence โโโ Training โโโ Analytics โโโ Metrics โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
```## ๐ฏ **What Problem Does OpsAI Solve?**
### **Before OpsAI (Traditional IT Support):**
```
User reports issue โ Manual ticket review โ Search past solutions โ Assign to team โ Resolution
โฑ๏ธ Hours/Days ๐ฐ High cost ๐ Time-intensive ๐ฅ Manual routing
```### **With OpsAI (AI-Powered Support):**
```
User reports issue โ AI instant analysis โ Auto-suggested solution โ Smart team routing โ Fast resolution
โก Seconds ๐ฐ Cost efficient ๐ง AI-powered ๐ฏ Accurate routing
```## โจ **Core Features**
| Feature | Description | Business Impact |
|---------|-------------|-----------------|
| ๐ฏ **Smart Classification** | AI categorizes tickets by type (auth, network, performance) | Automatic team routing |
| ๐ง **Resolution Suggestions** | Generates solutions based on similar past cases | Faster problem solving |
| ๐ **Semantic Search** | Finds relevant tickets using AI understanding, not just keywords | Better context matching |
| ๐ **Real-time Monitoring** | Prometheus metrics + Grafana dashboards | System health visibility |
| ๐ **Enterprise Integration** | Connects with Jira, Slack, Freshdesk | Seamless workflow integration |
| ๐ **Continuous Learning** | LoRA fine-tuning adapts to your organization | Improving accuracy over time |## ๐ **Quick Demo**
### **Example 1: Ticket Classification**
```bash
curl -X POST "http://localhost:8000/classify" \
-H "Content-Type: application/json" \
-d '{"text": "Cannot access email, getting authentication errors"}'
```
**Response:**
```json
{
"tags": ["auth", "mail", "user"],
"teams": ["IT Helpdesk"]
}
```### **Example 2: AI Resolution Suggestion**
```bash
curl -X POST "http://localhost:8000/resolve" \
-H "Content-Type: application/json" \
-d '{"text": "Database connection timeout in production"}'
```
**Response:**
```json
{
"suggestion": "Check database connection pool settings and increase timeout values...",
"context_tickets": [{"title": "Similar DB issue", "resolution": "..."}]
}
```## ๐ **Prerequisites**
- **Python 3.11+** (tested with 3.12.3)
- **8GB+ RAM** (for AI model inference)
- **Docker & Docker Compose** (for full stack deployment)
- **CUDA-compatible GPU** (optional, for faster inference)
- **4GB disk space** (for models and vector index)## โก **Installation & Setup**
### **Method 1: Local Development (Recommended for Testing)**
1. **Clone and Setup Environment:**
```bash
git clone https://github.com/pheonix-19/OpsAI.git
cd OpsAI# Create virtual environment
python3 -m venv env
source env/bin/activate # Linux/macOS
# env\Scripts\activate # Windows# Install dependencies
pip install -r requirements.txt
pip install -e .
```2. **Process Sample Data and Build AI Index:**
```bash
# Process the included sample tickets
PYTHONPATH=. python -m src.ingestion.ingest data/raw data/processed# Build vector embeddings index for semantic search
PYTHONPATH=. python -m src.embeddings.build_index --input-dir data/processed --output-dir data/index
```3. **Start the API Server:**
```bash
PYTHONPATH=. uvicorn src.api.main:app --host 0.0.0.0 --port 8000 --reload
```4. **Access the System:**
- **API Documentation**: http://localhost:8000/docs
- **Metrics Endpoint**: http://localhost:8000/metrics### **Method 2: Full Production Stack (Docker)**
```bash
# Start complete monitoring stack
docker-compose up --build# Access services:
# - OpsAI API: http://localhost:8000
# - Prometheus: http://localhost:9090
# - Grafana: http://localhost:3000 (admin/admin)
```## ๐ฎ **API Endpoints Reference**
| Endpoint | Method | Purpose | Example Use Case |
|----------|--------|---------|------------------|
| `/` | GET | Health check | Service monitoring |
| `/classify` | POST | Categorize tickets | Auto-route to teams |
| `/resolve` | POST | Get AI suggestions | Provide solutions |
| `/feedback` | POST | Submit user ratings | Improve AI accuracy |
| `/metrics` | GET | Prometheus metrics | System monitoring |### **Detailed API Usage:**
#### **๐ฏ Classify Tickets**
```bash
curl -X POST "http://localhost:8000/classify" \
-H "Content-Type: application/json" \
-d '{
"text": "Server not responding to ping requests",
"top_k": 3
}'
```#### **๐ง Get AI Resolutions**
```bash
curl -X POST "http://localhost:8000/resolve" \
-H "Content-Type: application/json" \
-d '{
"text": "Application crashes when uploading large files",
"top_k": 5
}'
```#### **๐ Submit Feedback**
```bash
curl -X POST "http://localhost:8000/feedback" \
-H "Content-Type: application/json" \
-d '{
"ticket": {"title": "Login issue", "description": "Cannot access system"},
"suggestion": "Reset password and clear browser cache",
"rating": 5,
"comment": "Perfect solution, worked immediately!"
}'
```## ๐ **Monitoring & Observability**
### **๐ Prometheus Metrics**
OpsAI automatically tracks comprehensive performance metrics:```bash
# View current metrics
curl http://localhost:8000/metrics | grep opsai# Example metrics output:
opsai_requests_total{endpoint="/classify",method="POST"} 5.0
opsai_request_latency_seconds_sum{endpoint="/resolve"} 2.28
```**Key Metrics Tracked:**
- **Request Volume**: API calls per endpoint per second
- **Response Times**: Latency percentiles (50th, 90th, 99th)
- **Error Rates**: Failed requests and status codes
- **AI Performance**: Model inference times
- **Business KPIs**: Total tickets processed### **๐ Grafana Dashboards** โ **CONFIGURED & WORKING**
**โ Active Dashboards:**
1. **OpsAI Monitoring Dashboard** - Real-time API metrics
2. **Prometheus 2.0 Stats** - System performance monitoring
3. **Prometheus Stats** - Infrastructure metrics**๐ Access:** http://localhost:3000 (admin/admin)
**Dashboard Features:**
- ๐ **Total API Requests**: Live request tracking
- โฑ๏ธ **Request Rate**: Real-time requests per minute
- ๐จ **HTTP Status Codes**: Success vs Error monitoring
- ๐ **Endpoint Breakdown**: Usage analytics by endpoint
- ๐ฅง **Visual Analytics**: Interactive charts and tables### **๏ฟฝ Live Screenshots**
**๐ฅ๏ธ Grafana Dashboard in Action:**

*Real-time monitoring dashboard showing API metrics, request rates, and system health***๐ Prometheus Metrics Collection:**

*Prometheus collecting and displaying OpsAI application metrics***โ๏ธ Prometheus Configuration & Targets:**

*Prometheus monitoring targets and service discovery configuration*### **๏ฟฝ๐ Prometheus Query Examples**
Essential queries for monitoring (see `PROMETHEUS_QUERIES.md` for complete reference):```promql
# Basic metrics
sum(opsai_requests_total) by (endpoint) # Total requests by endpoint
rate(opsai_requests_total[5m]) # Request rate per second# Performance monitoring
avg(opsai_request_latency_seconds) by (endpoint) # Average response time
histogram_quantile(0.95, rate(opsai_request_latency_seconds_bucket[5m])) # 95th percentile
```## ๐ **Project Structure**
```
opsai/
โโโ src/ # Core application code
โ โโโ api/ # FastAPI endpoints
โ โโโ embeddings/ # Vector search & FAISS
โ โโโ ingestion/ # Data processing
โ โโโ integrations/ # External APIs (Jira, Slack)
โ โโโ model_training/ # AI model fine-tuning
โ โโโ monitoring/ # Prometheus metrics
โโโ data/ # Training data & indexes
โโโ models/ # LoRA adapters & weights
โโโ tests/ # Test suite
โโโ infra/ # Docker & monitoring configs
```## ๏ฟฝ **Security & Secrets Management**
### **๐จ Important: Managing Secrets in Public Repositories**
โ ๏ธ **NEVER commit actual secrets to your repository!** This guide shows you how to securely manage environment variables and API keys for both local development and CI/CD.
#### **๐ Required vs Optional Credentials**
| **Credential** | **Required For** | **Default Behavior** |
|---------------|------------------|---------------------|
| `DATABASE_URL` | Database connection | โ Defaults to local SQLite |
| `OPENAI_API_KEY` | OpenAI features | โ ๏ธ Optional - features disabled if missing |
| `HUGGINGFACE_API_TOKEN` | Model downloads | โ ๏ธ Optional - uses cached/local models |
| `JIRA_API_TOKEN` | JIRA integration | โ ๏ธ Only if using JIRA |
| `SLACK_BOT_TOKEN` | Slack bot | โ ๏ธ Only if using Slack |
| `FRESHDESK_API_KEY` | Freshdesk integration | โ ๏ธ Only if using Freshdesk |
| `DOCKERHUB_USER/TOKEN` | CI/CD deployment | โ ๏ธ Only for Docker Hub publishing |#### **๐ก๏ธ Local Development Setup**
1. **Copy environment template:**
```bash
cp .env.example .env
```2. **Edit `.env` with your actual values (NEVER commit this file):**
```bash
# Required only if using specific integrations
JIRA_URL="https://your-company.atlassian.net"
JIRA_USER="your-email@company.com"
JIRA_API_TOKEN="your_new_jira_token_here"SLACK_BOT_TOKEN="xoxb-your-slack-bot-token-here"
SLACK_APP_TOKEN="xapp-your-slack-app-token-here"# Optional - for enhanced AI features
OPENAI_API_KEY="sk-your-openai-key-here"
HUGGINGFACE_API_TOKEN="hf_your-token-here"
```3. **The `.env` file is automatically ignored by git** (included in `.gitignore`)
#### **๐ GitHub Secrets for CI/CD**
For GitHub Actions to work with your secrets:
1. **Go to GitHub Repository Settings**
2. **Navigate to:** Settings โ Secrets and variables โ Actions
3. **Add these secrets** (only the ones you need):```
# Docker deployment (required for CI/CD)
DOCKERHUB_USER=your_dockerhub_username
DOCKERHUB_TOKEN=your_dockerhub_access_token# Integration secrets (optional)
JIRA_API_TOKEN=your_jira_token
SLACK_BOT_TOKEN=your_slack_token
FRESHDESK_API_KEY=your_freshdesk_key
```#### **โ Security Best Practices Implemented**
- โ **No secrets in source code** - All credentials from environment variables
- โ **Secure config validation** - `src/config.py` handles missing secrets gracefully
- โ **Environment isolation** - Production vs development detection
- โ **CI/CD ready** - GitHub Actions configured with proper secret injection
- โ **Optional integrations** - Core functionality works without external APIs#### **๐ง Security Configuration Files**
**Key files for security:**
- `.env.example` - Template with placeholder values (safe to commit)
- `src/config.py` - Secure configuration management
- `.gitignore` - Ensures `.env` files are never committed
- `SECURITY.md` - Complete security guidelines### **๐จ Token Security Checklist**
- [ ] All real tokens removed from version control
- [ ] `.env` file exists locally with actual values
- [ ] GitHub secrets configured for CI/CD
- [ ] Old/exposed tokens revoked and regenerated
- [ ] Team members trained on security practices## ๐ณ **Docker & Deployment**
### **๐ ๏ธ Fixed Docker Build Issues**
**Common Docker problems and solutions implemented:**
#### **โ Problem: Package Version Conflicts**
```
ERROR: Could not find a version that satisfies the requirement tokenizers==0.21.2
ERROR: No matching distribution found for SQLAlchemy==2.0.23
```#### **โ Solution: Flexible Version Ranges**
Updated `requirements.txt` to use compatible version ranges instead of pinned versions:```python
# Before (problematic)
tokenizers==0.21.2
SQLAlchemy==2.0.23# After (working)
tokenizers>=0.13.0,<1.0.0
SQLAlchemy>=1.4.0,<3.0.0
```#### **โ Problem: Network Timeouts During Build**
```
pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool: Read timed out
```#### **โ Solution: Enhanced Dockerfile**
```dockerfile
# Install with increased timeout and retries
RUN pip install --no-cache-dir \
--timeout 1000 \
--retries 5 \
--default-timeout=1000 \
-r requirements.txt
```### **๐ Deployment Options**
#### **Option 1: Quick Development Setup**
```bash
# Minimal setup for development
cp requirements-minimal.txt requirements.txt
docker-compose up --build
```#### **Option 2: Full Production Stack**
```bash
# Complete setup with all features
docker-compose up --build
```#### **Option 3: Retry Script (Handles Network Issues)**
```bash
# Automated retry with fallback to minimal setup
./docker-build.sh
```### **๐ฆ Docker Services Overview**
| **Service** | **Port** | **Purpose** | **Health Check** |
|-------------|----------|-------------|------------------|
| `opsai-api` | 8000 | Main application | `curl localhost:8000/` |
| `prometheus` | 9090 | Metrics collection | `curl localhost:9090/-/healthy` |
| `grafana` | 3000 | Monitoring dashboards | `curl localhost:3000/api/health` |### **๐ง Docker Troubleshooting**
**Check service status:**
```bash
docker-compose ps
docker-compose logs api
```**Restart specific service:**
```bash
docker-compose restart api
docker-compose restart prometheus
```**Clean rebuild:**
```bash
docker-compose down
docker system prune -f
docker-compose up --build --no-cache
```## ๐ **Monitoring & Metrics - Complete Setup Guide**
### **๐ฏ Prometheus Configuration**
**โ Working Prometheus Setup:**
```yaml
# infra/prometheus/prometheus.yml
global:
scrape_interval: 15sscrape_configs:
- job_name: 'prometheus' # Self-monitoring
static_configs:
- targets: ['localhost:9090']
- job_name: 'opsai_api' # Application monitoring
static_configs:
- targets: ['api:8000']
```### **๐ Grafana Dashboard Setup**
**โ Auto-configured Grafana features:**
1. **Data Source**: Prometheus auto-configured at `http://prometheus:9090`
2. **Dashboards**: Pre-built OpsAI monitoring dashboard
3. **Provisioning**: Automatic setup via configuration files**Access:** http://localhost:3000 (admin/admin)
### **๐ Available Metrics & Queries**
#### **๐ OpsAI Application Metrics**
**โ Confirmed Working Queries:**
```promql
# Instant metrics (always show data)
opsai_requests_total # Total API requests
process_resident_memory_bytes{job="opsai_api"} # Memory usage
time() - process_start_time_seconds{job="opsai_api"} # Uptime
up{job="opsai_api"} # Service availability
python_gc_objects_collected_total{job="opsai_api"} # Python metrics# Aggregated metrics
sum by (endpoint) (opsai_requests_total) # Requests by endpoint
sum by (http_status) (opsai_requests_total) # Requests by status code
```#### **๐ Rate-based Metrics (Need Traffic)**
```promql
# Generate traffic first: ./generate-traffic.sh
rate(opsai_requests_total[5m]) # Request rate
rate(process_cpu_seconds_total{job="opsai_api"}[5m]) * 100 # CPU usage
histogram_quantile(0.95, rate(opsai_request_latency_seconds_bucket[5m])) # 95th percentile latency
```### **๐ Testing Metrics**
**Generate test traffic:**
```bash
# Continuous traffic generation
./generate-traffic.sh# Or manual testing
for i in {1..20}; do
curl -s http://localhost:8000/ > /dev/null
curl -s http://localhost:8000/docs > /dev/null
sleep 1
done
```**Verify metrics in Prometheus:**
```bash
# Check if metrics are being collected
curl -s "http://localhost:9090/api/v1/query?query=opsai_requests_total" | jq '.data.result | length'# Test specific queries
curl -s "http://localhost:9090/api/v1/query?query=up{job=\"opsai_api\"}"
```### **๐ Grafana Dashboard Features**
**Working dashboard panels:**
- ๐ **Total API Requests**: Real-time request count
- โฑ๏ธ **Request Rate**: Requests per minute over time
- ๐ฅง **HTTP Status Codes**: Success vs error breakdown
- ๐ **Request Latency**: Response time percentiles
- ๐พ **Memory Usage**: RAM consumption tracking
- โฐ **Service Uptime**: Time since last restart### **๐จ Monitoring Troubleshooting**
**If Grafana shows "No Data":**
1. **Check Prometheus targets:**
```bash
curl -s http://localhost:9090/api/v1/targets | jq '.data.activeTargets[] | {job: .labels.job, health: .health}'
```2. **Verify data source in Grafana:**
- URL should be: `http://prometheus:9090`
- Click "Save & Test" - should show green "Data source is working"3. **Test simple queries in Grafana:**
- Start with: `opsai_requests_total`
- Set time range to "Last 15 minutes"
- Enable auto-refresh (5s)4. **Generate traffic if needed:**
```bash
./generate-traffic.sh
```### **๐ Custom Dashboard Creation**
**Manual dashboard setup:**
1. Go to Grafana โ "+" โ Dashboard โ Add new panel
2. Enter query: `opsai_requests_total`
3. Set visualization type (Time series, Stat, etc.)
4. Configure time range and refresh interval
5. Save dashboard### **๐ง Monitoring Best Practices**
- โ **Start simple**: Use instant metrics first (`opsai_requests_total`)
- โ **Generate traffic**: Use `./generate-traffic.sh` for rate metrics
- โ **Check time ranges**: Use "Last 15 minutes" for recent data
- โ **Verify targets**: Ensure Prometheus is scraping successfully
- โ **Test queries**: Use Prometheus UI to validate queries before Grafana## ๐ **Step-by-Step Setup Walkthrough**
### **๐ Complete Setup from Scratch**
#### **1. Repository Setup**
```bash
git clone https://github.com/pheonix-19/OpsAI.git
cd OpsAI
```#### **2. Security Configuration**
```bash
# Copy environment template
cp .env.example .env# Edit .env with your actual credentials (optional)
nano .env# Verify .env is in .gitignore
grep -q "^\.env$" .gitignore && echo "โ .env properly ignored"
```#### **3. Docker Build (with retry logic)**
```bash
# Method 1: Automated retry script
chmod +x docker-build.sh
./docker-build.sh# Method 2: Manual build
docker-compose up --build# Method 3: Minimal build (if having issues)
cp requirements-minimal.txt requirements.txt
docker-compose up --build
```#### **4. Verify Services**
```bash
# Check all services are running
docker-compose ps# Test API
curl http://localhost:8000/# Test metrics endpoint
curl http://localhost:8000/metrics | head -10# Check Prometheus targets
curl -s http://localhost:9090/api/v1/targets | jq '.data.activeTargets[].health'
```#### **5. Setup Monitoring**
```bash
# Generate test traffic
./generate-traffic.sh &# Open Grafana (admin/admin)
open http://localhost:3000# Open Prometheus
open http://localhost:9090
```#### **6. Test AI Features**
```bash
# Test classification
curl -X POST "http://localhost:8000/classify" \
-H "Content-Type: application/json" \
-d '{"text": "Cannot login to email account"}'# Test resolution suggestions
curl -X POST "http://localhost:8000/resolve" \
-H "Content-Type: application/json" \
-d '{"text": "Database connection timeout error"}'
```### **๐ง CI/CD Setup**
#### **GitHub Actions Configuration**
Your repository includes automated CI/CD with these workflows:
**`.github/workflows/ci.yml`** - Tests and builds on every push:
```yaml
# Automatically runs:
- Python linting with flake8
- Test suite with pytest
- Docker image build
- Deployment to Docker Hub (if secrets configured)
```**`.github/workflows/retrain.yml`** - Scheduled model retraining:
```yaml
# Runs weekly to:
- Retrain AI models with new data
- Update LoRA adapters
- Upload new model artifacts
```#### **Required GitHub Secrets for CI/CD**
**Minimal setup (for basic CI/CD):**
```
DOCKERHUB_USER=your_dockerhub_username
DOCKERHUB_TOKEN=your_dockerhub_access_token
```**Full setup (for all integrations):**
```
JIRA_API_TOKEN=your_jira_token
SLACK_BOT_TOKEN=your_slack_token
FRESHDESK_API_KEY=your_freshdesk_key
```### **๐ Configuration Files Reference**
| **File** | **Purpose** | **When to Edit** |
|----------|-------------|------------------|
| `.env.example` | Template for environment variables | Never (contains placeholders) |
| `.env` | Your actual secrets (not in git) | Add your real credentials |
| `src/config.py` | Configuration management | Customize app settings |
| `requirements.txt` | Python dependencies | Add new packages |
| `docker-compose.yml` | Service orchestration | Modify ports/volumes |
| `infra/prometheus/prometheus.yml` | Metrics collection | Add monitoring targets |### **๐ฏ Quick Validation Checklist**
- [ ] Services start: `docker-compose ps` shows all running
- [ ] API responds: `curl http://localhost:8000/` returns JSON
- [ ] Metrics work: `curl http://localhost:8000/metrics` shows data
- [ ] Prometheus scraping: Targets page shows "UP" status
- [ ] Grafana connected: Data source test succeeds
- [ ] Dashboards show data: Generate traffic and verify graphs
- [ ] AI features work: Classification and resolution endpoints respond
- [ ] Security configured: No real secrets in git, `.env` properly ignoredThis comprehensive setup ensures your OpsAI deployment is secure, monitored, and production-ready! ๐
## ๐ **Enterprise Integrations**
### **๐ Jira Integration**
```bash
# Environment variables for Jira
JIRA_URL=https://your-domain.atlassian.net
JIRA_USER=your-email@company.com
JIRA_API_TOKEN=your-api-token# Auto-process tickets from Jira webhooks
# POST /jira/webhook - Receives ticket updates
```### **๐ฌ Slack Bot Integration**
```bash
# Slack bot configuration
SLACK_BOT_TOKEN=xoxb-your-bot-token
SLACK_APP_TOKEN=xapp-your-app-token# Start the Slack bot
python src/integrations/slack_bot.py
```## ๐งช **Testing & Development**
### **Run Test Suite:**
```bash
# Run all tests
pytest# Run specific modules
pytest tests/test_api.py # API endpoint tests
pytest tests/test_embeddings.py # Vector search tests
pytest tests/test_ingestion.py # Data processing tests
```### **Development Workflow:**
```bash
# Hot reload during development
uvicorn src.api.main:app --reload --port 8000# Process new training data
python src/ingestion/ingest.py --input data/raw/new_tickets.csv# Rebuild search index
python src/embeddings/build_index.py --input-dir data/processed --output-dir data/index
```## ๐จ **Troubleshooting**
### **Common Issues & Solutions**
**๐ง Device Mismatch Error:**
```
RuntimeError: Expected all tensors to be on the same device
```
**Solution:** โ Fixed in latest version - tensors automatically moved to correct device**๐ง Import Errors:**
```
ImportError: attempted relative import with no known parent package
```
**Solution:** Use `PYTHONPATH=. python -m src.module.script`**๐ง Port Already in Use:**
```
OSError: [Errno 98] Address already in use
```
**Solution:** Use different port: `--port 8001` or kill existing process### **Debugging Commands**
```bash
# Check API health
curl http://localhost:8000/# View current metrics
curl http://localhost:8000/metrics | grep opsai# Check Docker services
docker-compose ps
```## ๐ **Quick Start Guide**
**1. Test Basic Classification:**
```bash
curl -X POST "http://localhost:8000/classify" \
-H "Content-Type: application/json" \
-d '{"text": "Password reset needed for user account"}'
```**2. Get AI-Powered Solutions:**
```bash
curl -X POST "http://localhost:8000/resolve" \
-H "Content-Type: application/json" \
-d '{"text": "Email server connection timeout"}'
```**3. Provide Feedback for Learning:**
```bash
curl -X POST "http://localhost:8000/feedback" \
-H "Content-Type: application/json" \
-d '{
"ticket": {"title": "Login issue"},
"suggestion": "Reset password",
"rating": 5,
"comment": "Perfect solution!"
}'
```## ๐ **Additional Resources**
### **๐ Useful Links**
- **๐ API Documentation**: http://localhost:8000/docs (when running)
- **๐ Monitoring**: http://localhost:3000 (Grafana dashboards)
- **๐ Metrics**: http://localhost:9090 (Prometheus)
- **๐ Query Reference**: See `PROMETHEUS_QUERIES.md` for complete monitoring guide
- **๐ Issues**: https://github.com/pheonix-19/OpsAI/issues
- **๐ฌ Discussions**: https://github.com/pheonix-19/OpsAI/discussions### **๐ Technical Stack**
- **Vector Embeddings**: `sentence-transformers/all-MiniLM-L6-v2`
- **Language Model**: `EleutherAI/gpt-neo-125M` with LoRA fine-tuning
- **Search Index**: FAISS (Facebook AI Similarity Search)
- **Monitoring**: Prometheus + Grafana stack
- **API Framework**: FastAPI with automatic OpenAPI docs## ๐ค **Contributing**
We welcome contributions! Here's how to get started:
### **๐ ๏ธ Development Setup**
```bash
# Fork the repository
git clone https://github.com/your-username/OpsAI.git
cd OpsAI# Create feature branch
git checkout -b feature/amazing-improvement# Make changes and test
pytest
pre-commit run --all-files# Submit pull request
git push origin feature/amazing-improvement
```### **๐ฏ Contribution Areas**
- ๐ **Bug Fixes**: Fix issues and improve stability
- โจ **New Features**: Add integrations, UI improvements, ML enhancements
- ๐ **Documentation**: Improve guides, examples, and API docs
- ๐งช **Testing**: Add test coverage and performance benchmarks## ๐ **License & Support**
### **๐ License**
This project is licensed under the **MIT License** - see the [LICENSE](LICENSE) file for details.### **๐ Getting Help**
**For Questions:**
1. ๐ Check this README and API documentation first
2. ๐ Search existing [GitHub issues](https://github.com/pheonix-19/OpsAI/issues)
3. ๐ฌ Start a [GitHub discussion](https://github.com/pheonix-19/OpsAI/discussions)
4. ๐ Create a new issue with detailed information**For Bugs:**
Include in your issue:
- Python version and OS
- Complete error message and stack trace
- Steps to reproduce the problem
- Expected vs actual behavior### **๐ Acknowledgments**
- **Hugging Face**: For transformer models and libraries
- **FastAPI**: For the excellent web framework
- **Prometheus & Grafana**: For monitoring and observability
- **FAISS**: For efficient vector similarity search
- **OpenAI/EleutherAI**: For foundation language models---
## ๐ **Ready to Transform Your IT Support?**
OpsAI is production-ready and has been tested with real-world IT scenarios. Start with the sample data, then gradually add your organization's historical tickets to improve accuracy.
**Get started in 5 minutes:**
```bash
git clone https://github.com/pheonix-19/OpsAI.git
cd OpsAI
python3 -m venv env
source env/bin/activate
pip install -r requirements.txt
pip install -e .
PYTHONPATH=. uvicorn src.api.main:app --reload
```