Spaces:
Runtime error
Runtime error
cosmoruler
commited on
Commit
Β·
eb85a42
1
Parent(s):
c69ba8c
tried to put in agent
Browse files
README.md
CHANGED
@@ -9,17 +9,18 @@ app_file: app.py
|
|
9 |
pinned: false
|
10 |
---
|
11 |
|
12 |
-
#
|
13 |
|
14 |
-
An intelligent data analysis application
|
15 |
|
16 |
## Features
|
17 |
|
18 |
-
π€ **AI-Powered Analysis**: Uses SmoLagent
|
19 |
-
π **Interactive Visualizations**: Correlation heatmaps, distribution plots, and
|
20 |
-
π **
|
21 |
-
π **
|
22 |
-
π§ **Flexible
|
|
|
23 |
|
24 |
## Quick Start
|
25 |
|
@@ -29,147 +30,253 @@ An intelligent data analysis application that uses SmoLagent for AI-powered insi
|
|
29 |
pip install -r requirements.txt
|
30 |
```
|
31 |
|
32 |
-
2. **Configure Your Model** (
|
33 |
|
34 |
-
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
|
37 |
3. **Run the Application**
|
38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
```bash
|
40 |
python app.py
|
|
|
41 |
```
|
42 |
|
43 |
-
4. **
|
44 |
-
-
|
|
|
45 |
|
46 |
## Files Overview
|
47 |
|
48 |
-
|
49 |
-
|
50 |
-
-
|
51 |
-
-
|
52 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
|
54 |
-
|
|
|
|
|
55 |
|
56 |
-
###
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
|
58 |
```python
|
59 |
-
from smolagents
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
)
|
64 |
```
|
65 |
|
66 |
-
###
|
67 |
|
68 |
```python
|
69 |
-
from smolagents
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
)
|
74 |
```
|
75 |
|
76 |
-
###
|
77 |
|
78 |
```python
|
79 |
-
from smolagents
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
)
|
84 |
```
|
85 |
|
86 |
## Usage Examples
|
87 |
|
88 |
-
###
|
89 |
|
90 |
-
```
|
91 |
-
python upload.py
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
```
|
93 |
|
94 |
-
###
|
95 |
|
96 |
-
```
|
97 |
-
python
|
98 |
```
|
99 |
|
100 |
-
###
|
101 |
|
102 |
-
```
|
103 |
-
python
|
104 |
```
|
105 |
|
106 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
|
108 |
### 1. Data Overview Tab
|
109 |
|
110 |
-
- Dataset
|
111 |
-
- Column
|
112 |
-
- Missing
|
113 |
-
- Memory
|
114 |
|
115 |
-
### 2.
|
116 |
|
117 |
-
-
|
118 |
-
-
|
119 |
-
-
|
|
|
120 |
|
121 |
-
### 3. Visualizations
|
122 |
|
123 |
-
- **
|
124 |
-
- **
|
|
|
125 |
|
126 |
-
### 4. AI
|
127 |
|
128 |
-
-
|
129 |
-
-
|
130 |
-
-
|
131 |
-
-
|
132 |
|
133 |
-
## Example AI Queries
|
134 |
|
135 |
Ask SmoLagent questions like:
|
136 |
|
137 |
-
|
138 |
-
|
139 |
-
- "
|
140 |
-
- "
|
141 |
-
- "
|
142 |
-
- "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
143 |
|
144 |
## Data Requirements
|
145 |
|
146 |
-
- CSV format
|
147 |
-
-
|
148 |
-
-
|
|
|
|
|
|
|
149 |
|
150 |
## Troubleshooting
|
151 |
|
152 |
### Common Issues:
|
153 |
|
154 |
-
1. **
|
155 |
|
156 |
-
|
157 |
-
|
|
|
|
|
158 |
|
159 |
-
2. **
|
160 |
|
161 |
-
-
|
162 |
-
-
|
163 |
|
164 |
-
3. **
|
165 |
-
|
166 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
167 |
|
168 |
### Getting Help:
|
169 |
|
170 |
-
-
|
171 |
-
-
|
172 |
-
-
|
|
|
173 |
|
174 |
## Advanced Usage
|
175 |
|
@@ -195,18 +302,88 @@ def create_custom_plot(df):
|
|
195 |
|
196 |
## Dependencies
|
197 |
|
198 |
-
|
199 |
-
|
200 |
-
-
|
201 |
-
-
|
202 |
-
|
203 |
-
|
204 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
205 |
|
206 |
## License
|
207 |
|
208 |
-
This project is
|
|
|
|
|
209 |
|
210 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
211 |
|
212 |
-
|
|
|
9 |
pinned: false
|
10 |
---
|
11 |
|
12 |
+
# Singtel Use Case 1: OutSystems Log Analysis with SmoLagent AI
|
13 |
|
14 |
+
An intelligent data analysis application specifically designed for analyzing OutSystems application logs using SmoLagent AI framework. This project focuses on extracting insights from 6 months of OutSystems log data to identify patterns, errors, and optimization opportunities.
|
15 |
|
16 |
## Features
|
17 |
|
18 |
+
π€ **AI-Powered Log Analysis**: Uses SmoLagent CodeAgent with DuckDuckGo search for intelligent log analysis
|
19 |
+
π **Interactive Visualizations**: Correlation heatmaps, distribution plots, and error pattern analysis
|
20 |
+
π **OutSystems-Specific Analytics**: Log level analysis, error module tracking, and performance insights
|
21 |
+
π **Multiple Interfaces**: Command-line, interactive menu, and web-based Gradio interface
|
22 |
+
π§ **Flexible AI Models**: OpenAI, Ollama (local), and HuggingFace Transformers support
|
23 |
+
π¨ **Error Pattern Detection**: Automated identification of error trends and module issues
|
24 |
|
25 |
## Quick Start
|
26 |
|
|
|
30 |
pip install -r requirements.txt
|
31 |
```
|
32 |
|
33 |
+
2. **Configure Your AI Model** (Choose one option)
|
34 |
|
35 |
+
**Option A: Free Local AI (Ollama)**
|
36 |
+
|
37 |
+
```bash
|
38 |
+
# Install Ollama from https://ollama.ai/
|
39 |
+
ollama pull llama2
|
40 |
+
ollama serve
|
41 |
+
python setup_ollama.py # Test setup
|
42 |
+
```
|
43 |
+
|
44 |
+
**Option B: OpenAI API**
|
45 |
+
|
46 |
+
```bash
|
47 |
+
set OPENAI_API_KEY=your_api_key_here
|
48 |
+
```
|
49 |
+
|
50 |
+
**Option C: Use without AI (basic analysis only)**
|
51 |
+
|
52 |
+
```bash
|
53 |
+
# No setup needed - basic data analysis works without AI
|
54 |
+
```
|
55 |
|
56 |
3. **Run the Application**
|
57 |
|
58 |
+
**Main Interactive Analysis:**
|
59 |
+
|
60 |
+
```bash
|
61 |
+
python upload.py
|
62 |
+
# Choose mode 2 for enhanced AI features
|
63 |
+
```
|
64 |
+
|
65 |
+
**Quick Demo:**
|
66 |
+
|
67 |
+
```bash
|
68 |
+
python quick_ai_demo.py
|
69 |
+
```
|
70 |
+
|
71 |
+
**Web Interface:**
|
72 |
+
|
73 |
```bash
|
74 |
python app.py
|
75 |
+
# Open browser to displayed URL
|
76 |
```
|
77 |
|
78 |
+
4. **Load Your OutSystems Data**
|
79 |
+
- Update file path in `upload.py` or `config.py`
|
80 |
+
- Default: `outsystems_sample_logs_6months.csv`
|
81 |
|
82 |
## Files Overview
|
83 |
|
84 |
+
### Main Scripts
|
85 |
+
|
86 |
+
- **`upload.py`** - Main data analysis script with interactive menu and AI integration
|
87 |
+
- **`app.py`** - Gradio web interface for browser-based analysis
|
88 |
+
- **`fixed_upload.py`** - Streamlined working version with automatic model fallbacks
|
89 |
+
|
90 |
+
### Setup & Testing Scripts
|
91 |
+
|
92 |
+
- **`setup_ollama.py`** - Ollama local AI setup helper
|
93 |
+
- **`setup_free_ai.py`** - Free AI models configuration
|
94 |
+
- **`test_smolagent.py`** - SmoLagent functionality testing
|
95 |
+
- **`quick_ai_demo.py`** - Quick demo without large downloads
|
96 |
+
|
97 |
+
### Configuration
|
98 |
|
99 |
+
- **`config.py`** - Model and data source configuration
|
100 |
+
- **`requirements.txt`** - Python dependencies
|
101 |
+
- **`ENHANCEMENT_GUIDE.md`** - Enhancement documentation
|
102 |
|
103 |
+
### Analysis Examples
|
104 |
+
|
105 |
+
- **`analyze.py`** - Programmatic analysis examples
|
106 |
+
- **`demo_enhanced.py`** - Enhanced features demonstration
|
107 |
+
|
108 |
+
## Model Configuration Options
|
109 |
+
|
110 |
+
### 1. Ollama (Recommended - Free & Local)
|
111 |
|
112 |
```python
|
113 |
+
from smolagents import CodeAgent, DuckDuckGoSearchTool, OllamaModel
|
114 |
+
|
115 |
+
model = OllamaModel(model_id="llama2", base_url="http://localhost:11434")
|
116 |
+
agent = CodeAgent(tools=[DuckDuckGoSearchTool()], model=model)
|
|
|
117 |
```
|
118 |
|
119 |
+
### 2. OpenAI Models
|
120 |
|
121 |
```python
|
122 |
+
from smolagents import CodeAgent, DuckDuckGoSearchTool, OpenAIModel
|
123 |
+
|
124 |
+
model = OpenAIModel(model_id="gpt-3.5-turbo")
|
125 |
+
agent = CodeAgent(tools=[DuckDuckGoSearchTool()], model=model)
|
|
|
126 |
```
|
127 |
|
128 |
+
### 3. HuggingFace Transformers
|
129 |
|
130 |
```python
|
131 |
+
from smolagents import CodeAgent, DuckDuckGoSearchTool, TransformersModel
|
132 |
+
|
133 |
+
model = TransformersModel(model_id="microsoft/DialoGPT-small")
|
134 |
+
agent = CodeAgent(tools=[DuckDuckGoSearchTool()], model=model)
|
|
|
135 |
```
|
136 |
|
137 |
## Usage Examples
|
138 |
|
139 |
+
### 1. Interactive Analysis (Recommended)
|
140 |
|
141 |
+
```bash
|
142 |
+
python upload.py
|
143 |
+
# Choose mode 2 for enhanced AI features
|
144 |
+
# Navigate through interactive menu:
|
145 |
+
# 1. Load and explore data
|
146 |
+
# 2. Create visualizations
|
147 |
+
# 3. Analyze data quality
|
148 |
+
# 4. AI-powered analysis
|
149 |
```
|
150 |
|
151 |
+
### 2. Quick Demo
|
152 |
|
153 |
+
```bash
|
154 |
+
python quick_ai_demo.py # Basic analysis without heavy downloads
|
155 |
```
|
156 |
|
157 |
+
### 3. Web Interface
|
158 |
|
159 |
+
```bash
|
160 |
+
python app.py # Start Gradio web interface
|
161 |
```
|
162 |
|
163 |
+
### 4. Automated Setup Testing
|
164 |
+
|
165 |
+
```bash
|
166 |
+
python test_smolagent.py # Test SmoLagent setup
|
167 |
+
python setup_free_ai.py # Configure free AI models
|
168 |
+
```
|
169 |
+
|
170 |
+
## OutSystems Log Analysis Features
|
171 |
|
172 |
### 1. Data Overview Tab
|
173 |
|
174 |
+
- **Dataset Structure**: 5000+ log entries with 9 columns
|
175 |
+
- **Column Analysis**: Timestamp, LogLevel, Module, User, Message, RequestUrl, SessionId, ErrorId, StackTrace
|
176 |
+
- **Missing Value Detection**: Identifies incomplete error records (ErrorId/StackTrace gaps)
|
177 |
+
- **Memory Usage**: Optimized for large log files
|
178 |
|
179 |
+
### 2. Log-Specific Analytics
|
180 |
|
181 |
+
- **Error Rate Analysis**: Info vs Error log distribution
|
182 |
+
- **Module Error Tracking**: Top error-generating modules identification
|
183 |
+
- **Session Analysis**: User session patterns and error correlation
|
184 |
+
- **Timestamp Patterns**: Time-based error trends and peak periods
|
185 |
|
186 |
+
### 3. Visualizations
|
187 |
|
188 |
+
- **Error Distribution Plots**: Visual error patterns across modules
|
189 |
+
- **Correlation Analysis**: Relationships between log parameters
|
190 |
+
- **Time Series Analysis**: Error trends over 6-month period
|
191 |
|
192 |
+
### 4. AI-Powered OutSystems Insights
|
193 |
|
194 |
+
- **Error Pattern Recognition**: AI identifies recurring error types
|
195 |
+
- **Module Risk Assessment**: Predicts which modules need attention
|
196 |
+
- **Performance Optimization**: Suggests improvements based on log patterns
|
197 |
+
- **Anomaly Detection**: Unusual log patterns and potential issues
|
198 |
|
199 |
+
## Example AI Queries for OutSystems Logs
|
200 |
|
201 |
Ask SmoLagent questions like:
|
202 |
|
203 |
+
**Error Analysis:**
|
204 |
+
|
205 |
+
- "What are the most common error types in these OutSystems logs?"
|
206 |
+
- "Which modules generate the most errors?"
|
207 |
+
- "Find patterns in error messages"
|
208 |
+
- "Identify critical errors that need immediate attention"
|
209 |
+
|
210 |
+
**Performance Insights:**
|
211 |
+
|
212 |
+
- "Analyze user session patterns for performance issues"
|
213 |
+
- "Find modules with the highest error rates"
|
214 |
+
- "Detect unusual activity patterns"
|
215 |
+
- "Suggest modules that need code review"
|
216 |
+
|
217 |
+
**Trend Analysis:**
|
218 |
+
|
219 |
+
- "Show error trends over the 6-month period"
|
220 |
+
- "Find seasonal patterns in system usage"
|
221 |
+
- "Identify peak error periods"
|
222 |
+
- "Correlate errors with specific time periods"
|
223 |
+
|
224 |
+
**Data Quality:**
|
225 |
+
|
226 |
+
- "Check for incomplete error records"
|
227 |
+
- "Find missing StackTrace patterns"
|
228 |
+
- "Validate log data completeness"
|
229 |
+
- "Suggest data quality improvements"
|
230 |
|
231 |
## Data Requirements
|
232 |
|
233 |
+
- **Format**: CSV format with OutSystems log structure
|
234 |
+
- **Expected Columns**: Timestamp, LogLevel, Module, User, Message, RequestUrl, SessionId, ErrorId, StackTrace
|
235 |
+
- **Default File**: `outsystems_sample_logs_6months.csv` (6 months of sample data)
|
236 |
+
- **File Location**: Update path in `upload.py` line 11 or `config.py`
|
237 |
+
- **Size**: Optimized for datasets with 5000+ log entries
|
238 |
+
- **Encoding**: UTF-8 encoding recommended
|
239 |
|
240 |
## Troubleshooting
|
241 |
|
242 |
### Common Issues:
|
243 |
|
244 |
+
1. **"Module not found: smolagents"**
|
245 |
|
246 |
+
```bash
|
247 |
+
pip install 'smolagents[transformers]'
|
248 |
+
pip install duckduckgo-search>=3.8.0
|
249 |
+
```
|
250 |
|
251 |
+
2. **"CodeAgent requires model parameter"**
|
252 |
|
253 |
+
- Run `python fixed_upload.py` for automatic model fallbacks
|
254 |
+
- Or configure Ollama: `python setup_ollama.py`
|
255 |
|
256 |
+
3. **Model Download Taking Too Long**
|
257 |
+
|
258 |
+
```bash
|
259 |
+
python quick_ai_demo.py # Use without heavy downloads
|
260 |
+
```
|
261 |
+
|
262 |
+
4. **OutSystems CSV File Not Found**
|
263 |
+
|
264 |
+
- Update file path in `upload.py` line 11
|
265 |
+
- Ensure CSV file exists at specified location
|
266 |
+
- Check file permissions
|
267 |
+
|
268 |
+
5. **Ollama Connection Error**
|
269 |
+
```bash
|
270 |
+
ollama serve # Start Ollama server
|
271 |
+
ollama pull llama2 # Download model
|
272 |
+
```
|
273 |
|
274 |
### Getting Help:
|
275 |
|
276 |
+
- **Quick Test**: Run `python test_smolagent.py`
|
277 |
+
- **Setup Issues**: Run `python setup_free_ai.py`
|
278 |
+
- **Basic Analysis**: Use Mode 1 in `upload.py` (works without AI)
|
279 |
+
- **Check Logs**: Console output shows detailed error messages
|
280 |
|
281 |
## Advanced Usage
|
282 |
|
|
|
302 |
|
303 |
## Dependencies
|
304 |
|
305 |
+
**Core AI Framework:**
|
306 |
+
|
307 |
+
- `smolagents>=0.3.0` - AI agent framework with CodeAgent
|
308 |
+
- `duckduckgo-search>=3.8.0` - Web search capabilities
|
309 |
+
|
310 |
+
**Data Analysis Stack:**
|
311 |
+
|
312 |
+
- `pandas>=2.0.0` - Data manipulation and analysis
|
313 |
+
- `numpy>=1.24.0` - Numerical computing
|
314 |
+
- `scikit-learn>=1.3.0` - Machine learning tools
|
315 |
+
|
316 |
+
**Visualization:**
|
317 |
+
|
318 |
+
- `matplotlib>=3.7.0` - Basic plotting
|
319 |
+
- `seaborn>=0.12.0` - Statistical visualizations
|
320 |
+
- `plotly>=5.15.0` - Interactive visualizations
|
321 |
+
|
322 |
+
**AI Models:**
|
323 |
+
|
324 |
+
- `transformers>=4.30.0` - HuggingFace transformers
|
325 |
+
- `torch>=2.0.0` - PyTorch for model inference
|
326 |
+
- `huggingface_hub>=0.16.0` - Model hub access
|
327 |
+
|
328 |
+
**Web Interface:**
|
329 |
+
|
330 |
+
- `gradio>=5.37.0` - Web UI framework
|
331 |
+
- `Pillow>=10.0.0` - Image processing
|
332 |
+
|
333 |
+
**HTTP & Utilities:**
|
334 |
+
|
335 |
+
- `requests>=2.31.0` - HTTP requests
|
336 |
+
|
337 |
+
## Project Structure
|
338 |
+
|
339 |
+
```
|
340 |
+
Singtel_Use_Case1/
|
341 |
+
βββ π Main Scripts
|
342 |
+
β βββ upload.py # Primary interactive analysis tool
|
343 |
+
β βββ app.py # Gradio web interface
|
344 |
+
β βββ fixed_upload.py # Streamlined working version
|
345 |
+
β
|
346 |
+
βββ π Setup & Testing
|
347 |
+
β βββ setup_ollama.py # Ollama configuration helper
|
348 |
+
β βββ setup_free_ai.py # Free AI models setup
|
349 |
+
β βββ test_smolagent.py # SmoLagent testing
|
350 |
+
β βββ quick_ai_demo.py # Quick demo script
|
351 |
+
β
|
352 |
+
βββ π Configuration
|
353 |
+
β βββ config.py # Model and data configuration
|
354 |
+
β βββ requirements.txt # Python dependencies
|
355 |
+
β βββ ENHANCEMENT_GUIDE.md # Development guide
|
356 |
+
β
|
357 |
+
βββ π Analysis Examples
|
358 |
+
β βββ analyze.py # Programmatic analysis
|
359 |
+
β βββ demo_enhanced.py # Feature demonstrations
|
360 |
+
β
|
361 |
+
βββ π Data (Expected)
|
362 |
+
βββ outsystems_sample_logs_6months.csv
|
363 |
+
```
|
364 |
|
365 |
## License
|
366 |
|
367 |
+
This project is developed for Singtel Use Case 1 analysis and is available under the MIT License.
|
368 |
+
|
369 |
+
---
|
370 |
|
371 |
+
## Quick Commands Reference
|
372 |
+
|
373 |
+
```bash
|
374 |
+
# π Quick Start
|
375 |
+
python upload.py # Main interactive tool
|
376 |
+
python quick_ai_demo.py # Fast demo without downloads
|
377 |
+
python app.py # Web interface
|
378 |
+
|
379 |
+
# π§ Setup & Testing
|
380 |
+
python setup_ollama.py # Configure local AI
|
381 |
+
python test_smolagent.py # Test AI setup
|
382 |
+
python setup_free_ai.py # Free models setup
|
383 |
+
|
384 |
+
# π Analysis Options
|
385 |
+
# Mode 1: Basic data exploration (no AI required)
|
386 |
+
# Mode 2: Full AI-powered analysis with interactive menu
|
387 |
+
```
|
388 |
|
389 |
+
**For Singtel Use Case 1**: This tool specifically analyzes OutSystems log data to identify error patterns, module performance, and system optimization opportunities using AI-powered insights.
|