Spaces:
Sleeping
Sleeping
| # 🚀 Quick Start - API Monitoring Now Active! | |
| ## ⚠️ IMPORTANT: You Must Restart the App | |
| The API monitoring UI has been added to `app.py`, but **it won't appear until you restart the Gradio app**. | |
| ## 🎯 Three Ways to Restart: | |
| ### Option 1: Use the Restart Script (Recommended) | |
| ```bash | |
| cd /home/gpaasch/overgrowth | |
| ./RESTART_APP.sh | |
| ``` | |
| ### Option 2: Manual Restart | |
| ```bash | |
| # Stop any running instance | |
| pkill -f "python.*app.py" | |
| # Start fresh | |
| cd /home/gpaasch/overgrowth | |
| source venv/bin/activate | |
| nohup python app.py > app.log 2>&1 & | |
| # Check logs | |
| tail -f app.log | |
| ``` | |
| ### Option 3: HuggingFace Space | |
| If deployed to HuggingFace Spaces: | |
| 1. Go to your Space settings | |
| 2. Click "Restart this Space" | |
| 3. Wait for reboot | |
| ## 📊 What You'll See After Restart | |
| The **very first section** at the top of the UI will be: | |
| ``` | |
| 🔍 Live API Activity Monitor | |
| Real-time visibility into all API calls - LLM, GNS3, and more | |
| ┌─────────────────────────────┬──────────────────────────────────────────┐ | |
| │ 📊 Session Statistics │ 📡 Recent API Calls │ | |
| ├─────────────────────────────┼──────────────────────────────────────────┤ | |
| │ Session Duration: 0m 0s │ *No API calls yet. Start using the │ | |
| │ Total API Calls: 0 │ system to see activity here.* │ | |
| │ LLM Calls: 0 │ │ | |
| │ GNS3 Calls: 0 │ │ | |
| │ Total Tokens: 0 │ │ | |
| │ Total Cost: $0.0000 │ │ | |
| │ Errors: 0 │ │ | |
| │ │ │ | |
| │ [🔄 Refresh Stats] │ [🔄 Refresh Activity] │ | |
| └─────────────────────────────┴──────────────────────────────────────────┘ | |
| --- | |
| 🌿 Network Automation Pipeline | |
| [Rest of the UI continues below...] | |
| ``` | |
| ## 🎬 Demo Flow for Judges | |
| 1. **Page loads** → See API monitor with $0.00 cost | |
| 2. **Enter network description** → Click "🚀 Run Full Pipeline" | |
| 3. **Watch in real-time** as API calls appear: | |
| ``` | |
| ✅ 🤖 ANTHROPIC claude-3-haiku-20240307 | |
| 📝 1,247→892 tokens | 💰 $0.0043 | ⏱️ 2,314ms | |
| ✅ 🤖 ANTHROPIC claude-3-haiku-20240307 | |
| 📝 2,105→1,543 tokens | 💰 $0.0201 | ⏱️ 3,127ms | |
| ``` | |
| 4. **Pipeline completes** → Status shows: | |
| ``` | |
| 💰 API Usage This Session | |
| - Total Cost: $0.0823 | |
| - LLM Calls: 3 | GNS3 Calls: 5 | |
| - Tokens: 8,456 (4,123 in / 4,333 out) | |
| ``` | |
| 5. **Click "🔄 Refresh Stats"** → Dashboard updates instantly | |
| ## ✅ Verification Checklist | |
| After restarting, verify these features work: | |
| - [ ] "Live API Activity Monitor" section appears at top | |
| - [ ] Session Statistics shows $0.00 initially | |
| - [ ] Running pipeline populates API calls | |
| - [ ] Each call shows: provider, model, tokens, cost, timing | |
| - [ ] Total cost updates in real-time | |
| - [ ] Refresh buttons work | |
| - [ ] Pipeline status includes API usage summary | |
| ## 🐛 Troubleshooting | |
| ### "I don't see the API monitor" | |
| → You didn't restart the app. Run `./RESTART_APP.sh` | |
| ### "API calls show but no tokens/costs" | |
| → This happens with mock responses (no API keys configured) | |
| → Set `ANTHROPIC_API_KEY` or `OPENAI_API_KEY` in `.env` | |
| ### "App won't start" | |
| → Check logs: `cat app.log` | |
| → Verify virtual environment: `source venv/bin/activate` | |
| ### "Port 7860 in use" | |
| → Kill existing process: `pkill -f "python.*app.py"` | |
| ## 📝 Files Changed | |
| 1. **`agent/api_monitor.py`** - New monitoring system (343 lines) | |
| 2. **`agent/llm_client.py`** - Added tracking to all LLM calls | |
| 3. **`agent/local_mcp.py`** - Added tracking to GNS3 calls | |
| 4. **`app.py`** - Added monitoring UI at top of interface | |
| 5. **`API_MONITORING.md`** - Full documentation | |
| 6. **`RESTART_APP.sh`** - Convenient restart script | |
| ## 🎯 Quick Test | |
| ```bash | |
| cd /home/gpaasch/overgrowth | |
| source venv/bin/activate | |
| # Test the monitor | |
| python -c " | |
| from agent.api_monitor import monitor | |
| print(monitor.get_stats().format_dashboard()) | |
| print(monitor.format_activity_feed()) | |
| " | |
| # Should output dashboard and activity feed | |
| ``` | |
| ## 🚀 For Hackathon Submission | |
| Make sure to: | |
| 1. ✅ Restart the app before demo | |
| 2. ✅ Test with a simple network description | |
| 3. ✅ Show judges the real-time API tracking | |
| 4. ✅ Highlight the cost transparency | |
| 5. ✅ Mention this is enterprise-grade observability | |
| --- | |
| **The monitoring is fully implemented - just restart to see it! 🎉** | |