Singtel_Use_Case1 / quick_ai_demo.py
cosmoruler
problems fixed
c69ba8c
#!/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")