Spaces:
Runtime error
Runtime error
# 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 | |