Spaces:
Runtime error
A newer version of the Gradio SDK is available:
5.44.0
Enhanced Data Explorer Setup Guide
π Your script has been enhanced with SmoLagent AI capabilities!
What's New:
- AI-Powered Analysis: Ask natural language questions about your data
- Enhanced Visualizations: Automatic correlation heatmaps and distribution plots
- Data Quality Analysis: Comprehensive data quality reporting
- Interactive Menu: User-friendly menu system
- Preserved Original: Your original function is still available
How to Use:
Option 1: Original Function (unchanged)
python upload.py
# Choose option 1 when prompted
Option 2: Enhanced Interactive Mode β οΈ IMPORTANT WORKFLOW
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
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:
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
Check AI Agent Status:
- Look for "β SmoLagent configured successfully" message
- If you see "β AI features not available", configure a model first
Alternative if AI Fails:
python fixed_upload.py # Has better error handling python quick_ai_demo.py # Works without heavy downloads
Setting Up AI Features:
For OpenAI (Recommended):
- Get API key from: https://platform.openai.com/
- Edit
upload.py
, uncomment lines insetup_agent()
method: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):
- Install Ollama from: https://ollama.ai/
- Run:
ollama pull llama2
- Start:
ollama serve
- Uncomment Ollama lines in
setup_agent()
method
For Hugging Face (Free, API):
- Get token from: https://huggingface.co/settings/tokens
- Set environment variable:
HF_TOKEN=your_token
- 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:
- β Load data first (option 1)
- β See "DATA LOADED SUCCESSFULLY" message
- β See "SmoLagent configured" message
- β 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 scriptdemo_enhanced.py
- Demonstration scriptapp.py
- Web interface (Gradio)config.py
- Configuration filerequirements.txt
- Dependencies
Quick Start:
CORRECT WORKFLOW (to avoid menu issues):
- Run the script:
python upload.py
- Choose enhanced mode: Select option 2
- Load data FIRST: Select option 1 and wait for completion
- Verify setup: Look for "β SmoLagent configured" message
- Use AI analysis: Select option 4 and ask your question
Quick Test Commands:
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