Spaces:
Runtime error
Runtime error
#!/usr/bin/env python3 | |
""" | |
Quick AI Demo - Working SmoLagent without large model downloads | |
""" | |
import pandas as pd | |
from smolagents import CodeAgent, DuckDuckGoSearchTool | |
import warnings | |
warnings.filterwarnings('ignore') | |
def quick_demo(): | |
"""Quick demo that works immediately""" | |
print("π QUICK AI DEMO - No Downloads Required") | |
print("=" * 50) | |
# Load the data first | |
csv_file_path = "C:/Users/Cosmo/Desktop/NTU Peak Singtel/outsystems_sample_logs_6months.csv" | |
try: | |
print("π Loading CSV data...") | |
df = pd.read_csv(csv_file_path) | |
print(f"β Data loaded: {df.shape[0]} rows, {df.shape[1]} columns") | |
print(f"π Columns: {list(df.columns)}") | |
# Show basic analysis without AI first | |
print("\nπ BASIC DATA ANALYSIS:") | |
print("-" * 30) | |
# Error analysis | |
error_df = df[df['LogLevel'] == 'Error'] | |
info_df = df[df['LogLevel'] == 'Info'] | |
print(f"π¨ Total Error entries: {len(error_df)}") | |
print(f"βΉοΈ Total Info entries: {len(info_df)}") | |
print(f"π Error rate: {len(error_df)/len(df)*100:.1f}%") | |
# Top modules with errors | |
if not error_df.empty: | |
top_error_modules = error_df['Module'].value_counts().head(3) | |
print(f"\nπ Top 3 modules with errors:") | |
for module, count in top_error_modules.items(): | |
print(f" β’ {module}: {count} errors") | |
# Check for missing data | |
missing_data = df.isnull().sum() | |
print(f"\nβ Missing data summary:") | |
for col, missing_count in missing_data.items(): | |
if missing_count > 0: | |
print(f" β’ {col}: {missing_count} missing ({missing_count/len(df)*100:.1f}%)") | |
print("\n" + "=" * 50) | |
print("β BASIC ANALYSIS COMPLETE!") | |
print("π‘ This shows your data is loading correctly.") | |
print("π€ AI features will work once model downloads complete.") | |
print("=" * 50) | |
return df | |
except Exception as e: | |
print(f"β Error loading data: {e}") | |
return None | |
def test_simple_agent(): | |
"""Test if we can create an agent without heavy models""" | |
print("\nπ§ͺ Testing Simple Agent Creation...") | |
try: | |
# Just test the tools without a model first | |
search_tool = DuckDuckGoSearchTool() | |
print("β DuckDuckGo search tool created successfully") | |
# Try to create agent (might fail without model, but we can catch it) | |
try: | |
agent = CodeAgent(tools=[search_tool]) | |
print("β Agent created (basic setup)") | |
except Exception as e: | |
print(f"βΉοΈ Agent needs model: {e}") | |
print("π‘ This is expected - agent will work once model is ready") | |
except Exception as e: | |
print(f"β Tool creation failed: {e}") | |
if __name__ == "__main__": | |
# Run the quick demo | |
df = quick_demo() | |
# Test agent creation | |
test_simple_agent() | |
if df is not None: | |
print(f"\nπ SUCCESS! Your data analysis setup is working!") | |
print(f"π Dataset ready: {df.shape[0]} OutSystems log entries") | |
print(f"π€ AI features will be available once model download completes") | |