Spaces:
Runtime error
Runtime error
File size: 5,392 Bytes
c69ba8c db6dcad c69ba8c db6dcad c69ba8c db6dcad c69ba8c db6dcad c69ba8c db6dcad c69ba8c db6dcad c69ba8c db6dcad c69ba8c db6dcad c69ba8c db6dcad c69ba8c db6dcad c69ba8c db6dcad |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
# Enhanced Data Explorer Setup Guide
## π Your script has been enhanced with SmoLagent AI capabilities!
### What's New:
1. **AI-Powered Analysis**: Ask natural language questions about your data
2. **Enhanced Visualizations**: Automatic correlation heatmaps and distribution plots
3. **Data Quality Analysis**: Comprehensive data quality reporting
4. **Interactive Menu**: User-friendly menu system
5. **Preserved Original**: Your original function is still available
### How to Use:
#### Option 1: Original Function (unchanged)
```bash
python upload.py
# Choose option 1 when prompted
```
#### Option 2: Enhanced Interactive Mode β οΈ **IMPORTANT WORKFLOW**
```bash
python upload.py
# Choose option 2 when prompted
# THEN FOLLOW THIS EXACT SEQUENCE:
# 1. Choose option 1 (Load and explore data) β MUST DO THIS FIRST!
# 2. Wait for data to load completely
# 3. Choose option 4 (AI-powered analysis)
# 4. Type your question (e.g., "identify seasonal patterns")
```
#### Option 3: Demo Script
```bash
python demo_enhanced.py
```
### π¨ TROUBLESHOOTING: "AI Analysis Goes Back to Main Menu"
**Problem**: When you type "identify seasonal patterns", it returns to the main menu instead of processing.
**Root Cause**: Data not loaded first, or AI agent not properly configured.
**Solution Steps**:
1. **Always Load Data First**:
```
python upload.py
β Choose 2 (Enhanced mode)
β Choose 1 (Load data) β CRITICAL STEP!
β Wait for "DATA LOADED SUCCESSFULLY" message
β Choose 4 (AI analysis)
β Type your question
```
2. **Check AI Agent Status**:
- Look for "β
SmoLagent configured successfully" message
- If you see "β AI features not available", configure a model first
3. **Alternative if AI Fails**:
```bash
python fixed_upload.py # Has better error handling
python quick_ai_demo.py # Works without heavy downloads
```
### Setting Up AI Features:
#### For OpenAI (Recommended):
1. Get API key from: https://platform.openai.com/
2. Edit `upload.py`, uncomment lines in `setup_agent()` method:
```python
model = OpenAIServerModel(model_id="gpt-3.5-turbo", api_key="your-api-key-here")
self.agent = CodeAgent(tools=[PythonCodeTool(), DuckDuckGoSearchTool()], model=model)
```
#### For Ollama (Free, Local):
1. Install Ollama from: https://ollama.ai/
2. Run: `ollama pull llama2`
3. Start: `ollama serve`
4. Uncomment Ollama lines in `setup_agent()` method
#### For Hugging Face (Free, API):
1. Get token from: https://huggingface.co/settings/tokens
2. Set environment variable: `HF_TOKEN=your_token`
3. Uncomment HF lines in `setup_agent()` method
### Example AI Queries:
**For OutSystems Log Analysis** (once data is loaded and AI configured):
- "What are the main error patterns in this OutSystems data?"
- "Find modules with the highest error rates"
- "Analyze error trends over time"
- "Identify peak error periods"
- "Suggest data quality improvements"
- "Find correlations between modules and error types"
- "Detect unusual activity patterns"
- "Recommend preprocessing steps"
**Important**: Make sure to:
1. β
Load data first (option 1)
2. β
See "DATA LOADED SUCCESSFULLY" message
3. β
See "SmoLagent configured" message
4. β
Then use AI analysis (option 4)
### Features Available Without AI:
Even without AI configuration, you get:
- β
Data loading and exploration (original functionality)
- β
Statistical summaries and data overview
- β
Data visualization (histograms, correlation heatmaps)
- β
Data quality analysis and missing value detection
- β
Interactive menu system for data exploration
### Common Issues & Solutions:
#### 1. **"β No data loaded. Run load_data() first."**
**Fix**: Always choose option 1 (Load data) before option 4 (AI analysis)
#### 2. **"β AI features not available. Please configure a model first."**
**Fix**: Set up AI model using one of the methods below, or use `fixed_upload.py`
#### 3. **AI query returns to main menu**
**Fix**: Ensure data is loaded AND AI agent is configured successfully
#### 4. **Import errors (smolagents, duckduckgo-search)**
**Fix**: `pip install 'smolagents[transformers]' duckduckgo-search>=3.8.0`
#### 5. **Model download too slow**
**Fix**: Use `python quick_ai_demo.py` for lighter analysis
### Files Structure:
- `upload.py` - Your enhanced main script
- `demo_enhanced.py` - Demonstration script
- `app.py` - Web interface (Gradio)
- `config.py` - Configuration file
- `requirements.txt` - Dependencies
### Quick Start:
**CORRECT WORKFLOW** (to avoid menu issues):
1. **Run the script**: `python upload.py`
2. **Choose enhanced mode**: Select option 2
3. **Load data FIRST**: Select option 1 and wait for completion
4. **Verify setup**: Look for "β
SmoLagent configured" message
5. **Use AI analysis**: Select option 4 and ask your question
**Quick Test Commands**:
```bash
python test_smolagent.py # Test if SmoLagent is working
python fixed_upload.py # Alternative with better error handling
python quick_ai_demo.py # Quick demo without heavy downloads
```
π **Your original functionality is preserved - nothing is broken!**
### Performance Notes:
- **Data Loading**: ~2-5 seconds for 5000 rows
- **AI Setup**: ~10-30 seconds first time (model download)
- **AI Analysis**: ~5-15 seconds per query
- **File Size**: Works well with CSV files up to 100MB
|