| { | |
| "exportDate": "2024-01-15T10:00:00.000Z", | |
| "sessions": { | |
| "demo_session_math_001": { | |
| "id": "demo_session_math_001", | |
| "title": "Calculate compound interest for savings account", | |
| "problemText": "I want to calculate the compound interest on $1000 invested for 5 years at 6% annual interest rate, compounded quarterly. Show me the formula and calculate the result.", | |
| "image": null, | |
| "createdAt": "2024-01-15T09:00:00.000Z", | |
| "lastUsed": "2024-01-15T09:15:00.000Z", | |
| "status": "completed", | |
| "chatHistory": [ | |
| { | |
| "sender": "PIPS", | |
| "content": "I'll help you calculate compound interest. Let me break this down step by step and create a Python function to calculate it.", | |
| "iteration": "Iteration 1", | |
| "promptDetails": null, | |
| "timestamp": "2024-01-15T09:01:00.000Z" | |
| }, | |
| { | |
| "sender": "AI Assistant", | |
| "content": "I'll solve this compound interest problem step by step.\n\n**Compound Interest Formula:**\nA = P(1 + r/n)^(nt)\n\nWhere:\n- A = final amount\n- P = principal ($1000)\n- r = annual interest rate (0.06)\n- n = number of times compounded per year (4 for quarterly)\n- t = time in years (5)\n\nLet me calculate this:\n\n```python\ndef calculate_compound_interest(principal, rate, compounds_per_year, years):\n \"\"\"\n Calculate compound interest\n \"\"\"\n amount = principal * (1 + rate/compounds_per_year) ** (compounds_per_year * years)\n interest_earned = amount - principal\n return amount, interest_earned\n\n# Your values\nprincipal = 1000\nrate = 0.06\ncompounds_per_year = 4 # quarterly\nyears = 5\n\nfinal_amount, interest = calculate_compound_interest(principal, rate, compounds_per_year, years)\n\nprint(f\"Principal: ${principal:,.2f}\")\nprint(f\"Annual Interest Rate: {rate*100}%\")\nprint(f\"Compounding: {compounds_per_year} times per year (quarterly)\")\nprint(f\"Time Period: {years} years\")\nprint(f\"\\nFinal Amount: ${final_amount:,.2f}\")\nprint(f\"Interest Earned: ${interest:,.2f}\")\n```\n\n**Result:**\n- Final Amount: $1,346.86\n- Interest Earned: $346.86\n\nYour $1000 investment will grow to $1,346.86 after 5 years, earning $346.86 in compound interest.", | |
| "iteration": "Iteration 1", | |
| "promptDetails": null, | |
| "timestamp": "2024-01-15T09:02:00.000Z" | |
| } | |
| ] | |
| }, | |
| "demo_session_algorithm_002": { | |
| "id": "demo_session_algorithm_002", | |
| "title": "Implement binary search algorithm", | |
| "problemText": "I need to implement a binary search algorithm in Python. It should work on a sorted list and return the index of the target element, or -1 if not found.", | |
| "image": null, | |
| "createdAt": "2024-01-15T09:30:00.000Z", | |
| "lastUsed": "2024-01-15T09:45:00.000Z", | |
| "status": "completed", | |
| "chatHistory": [ | |
| { | |
| "sender": "PIPS", | |
| "content": "I'll implement a binary search algorithm for you with proper error handling and testing.", | |
| "iteration": "Iteration 1", | |
| "promptDetails": null, | |
| "timestamp": "2024-01-15T09:31:00.000Z" | |
| }, | |
| { | |
| "sender": "AI Assistant", | |
| "content": "I'll implement a binary search algorithm with both iterative and recursive approaches.\n\n```python\ndef binary_search_iterative(arr, target):\n \"\"\"\n Binary search using iterative approach\n \n Args:\n arr: Sorted list to search in\n target: Element to find\n \n Returns:\n Index of target if found, -1 otherwise\n \"\"\"\n left, right = 0, len(arr) - 1\n \n while left <= right:\n mid = left + (right - left) // 2\n \n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n left = mid + 1\n else:\n right = mid - 1\n \n return -1\n\ndef binary_search_recursive(arr, target, left=0, right=None):\n \"\"\"\n Binary search using recursive approach\n \"\"\"\n if right is None:\n right = len(arr) - 1\n \n if left > right:\n return -1\n \n mid = left + (right - left) // 2\n \n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n return binary_search_recursive(arr, target, mid + 1, right)\n else:\n return binary_search_recursive(arr, target, left, mid - 1)\n\n# Test the implementation\ntest_array = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]\n\nprint(\"Test Array:\", test_array)\nprint(\"\\nTesting Iterative Binary Search:\")\nfor target in [7, 15, 2, 20]:\n result = binary_search_iterative(test_array, target)\n print(f\"Search for {target}: {'Found at index ' + str(result) if result != -1 else 'Not found'}\")\n\nprint(\"\\nTesting Recursive Binary Search:\")\nfor target in [7, 15, 2, 20]:\n result = binary_search_recursive(test_array, target)\n print(f\"Search for {target}: {'Found at index ' + str(result) if result != -1 else 'Not found'}\")\n```\n\n**Output:**\n```\nTest Array: [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]\n\nTesting Iterative Binary Search:\nSearch for 7: Found at index 3\nSearch for 15: Found at index 7\nSearch for 2: Not found\nSearch for 20: Not found\n```\n\n**Time Complexity:** O(log n)\n**Space Complexity:** O(1) for iterative, O(log n) for recursive", | |
| "iteration": "Iteration 1", | |
| "promptDetails": null, | |
| "timestamp": "2024-01-15T09:32:00.000Z" | |
| } | |
| ] | |
| }, | |
| "demo_session_data_003": { | |
| "id": "demo_session_data_003", | |
| "title": "Analyze sales data and create visualization", | |
| "problemText": "I have sales data in a CSV format with columns: date, product, sales_amount, region. Create a Python script to load this data and generate visualizations showing sales trends by region and top-selling products.", | |
| "image": null, | |
| "createdAt": "2024-01-15T10:00:00.000Z", | |
| "lastUsed": "2024-01-15T10:20:00.000Z", | |
| "status": "completed", | |
| "chatHistory": [ | |
| { | |
| "sender": "PIPS", | |
| "content": "I'll create a comprehensive data analysis script with visualizations for your sales data.", | |
| "iteration": "Iteration 1", | |
| "promptDetails": null, | |
| "timestamp": "2024-01-15T10:01:00.000Z" | |
| }, | |
| { | |
| "sender": "AI Assistant", | |
| "content": "I'll create a comprehensive sales data analysis script with visualizations.\n\n```python\nimport pandas as pd\nimport matplotlib.pyplot as plt\nimport seaborn as sns\nfrom datetime import datetime\nimport numpy as np\n\n# Set style for better-looking plots\nplt.style.use('seaborn-v0_8')\nsns.set_palette(\"husl\")\n\ndef load_and_analyze_sales_data(csv_file):\n \"\"\"\n Load and analyze sales data from CSV file\n \"\"\"\n # Load the data\n try:\n df = pd.read_csv(csv_file)\n print(f\"Data loaded successfully. Shape: {df.shape}\")\n except FileNotFoundError:\n print(\"Creating sample data for demonstration...\")\n df = create_sample_data()\n \n # Convert date column to datetime\n df['date'] = pd.to_datetime(df['date'])\n \n # Basic data info\n print(\"\\nDataset Info:\")\n print(df.info())\n print(\"\\nFirst 5 rows:\")\n print(df.head())\n \n return df\n\ndef create_sample_data():\n \"\"\"\n Create sample sales data for demonstration\n \"\"\"\n np.random.seed(42)\n dates = pd.date_range('2023-01-01', '2023-12-31', freq='D')\n products = ['Laptop', 'Mouse', 'Keyboard', 'Monitor', 'Headphones']\n regions = ['North', 'South', 'East', 'West']\n \n data = []\n for date in dates:\n for _ in range(np.random.randint(5, 15)):\n data.append({\n 'date': date,\n 'product': np.random.choice(products),\n 'sales_amount': np.random.uniform(50, 2000),\n 'region': np.random.choice(regions)\n })\n \n return pd.DataFrame(data)\n\ndef analyze_sales_trends(df):\n \"\"\"\n Generate comprehensive sales analysis and visualizations\n \"\"\"\n # Create figure with subplots\n fig, axes = plt.subplots(2, 2, figsize=(15, 12))\n fig.suptitle('Sales Data Analysis Dashboard', fontsize=16, fontweight='bold')\n \n # 1. Sales trends by region over time\n df['month'] = df['date'].dt.to_period('M')\n monthly_sales = df.groupby(['month', 'region'])['sales_amount'].sum().reset_index()\n monthly_sales['month'] = monthly_sales['month'].astype(str)\n \n for region in df['region'].unique():\n region_data = monthly_sales[monthly_sales['region'] == region]\n axes[0, 0].plot(region_data['month'], region_data['sales_amount'], \n marker='o', label=region, linewidth=2)\n \n axes[0, 0].set_title('Monthly Sales Trends by Region')\n axes[0, 0].set_xlabel('Month')\n axes[0, 0].set_ylabel('Sales Amount ($)')\n axes[0, 0].legend()\n axes[0, 0].tick_params(axis='x', rotation=45)\n \n # 2. Top-selling products\n product_sales = df.groupby('product')['sales_amount'].sum().sort_values(ascending=False)\n \n axes[0, 1].bar(product_sales.index, product_sales.values, color='skyblue')\n axes[0, 1].set_title('Total Sales by Product')\n axes[0, 1].set_xlabel('Product')\n axes[0, 1].set_ylabel('Total Sales ($)')\n axes[0, 1].tick_params(axis='x', rotation=45)\n \n # 3. Sales distribution by region (pie chart)\n region_sales = df.groupby('region')['sales_amount'].sum()\n \n axes[1, 0].pie(region_sales.values, labels=region_sales.index, autopct='%1.1f%%')\n axes[1, 0].set_title('Sales Distribution by Region')\n \n # 4. Daily sales volume\n daily_sales = df.groupby('date')['sales_amount'].sum()\n \n axes[1, 1].plot(daily_sales.index, daily_sales.values, alpha=0.7, color='green')\n axes[1, 1].set_title('Daily Sales Volume')\n axes[1, 1].set_xlabel('Date')\n axes[1, 1].set_ylabel('Sales Amount ($)')\n \n plt.tight_layout()\n plt.show()\n \n # Print summary statistics\n print(\"\\n\" + \"=\"*50)\n print(\"SALES ANALYSIS SUMMARY\")\n print(\"=\"*50)\n \n print(f\"\\nTotal Sales: ${df['sales_amount'].sum():,.2f}\")\n print(f\"Average Daily Sales: ${df.groupby('date')['sales_amount'].sum().mean():,.2f}\")\n print(f\"Number of Transactions: {len(df):,}\")\n \n print(\"\\nTop 3 Products by Sales:\")\n for i, (product, sales) in enumerate(product_sales.head(3).items(), 1):\n print(f\"{i}. {product}: ${sales:,.2f}\")\n \n print(\"\\nSales by Region:\")\n for region, sales in region_sales.items():\n percentage = (sales / region_sales.sum()) * 100\n print(f\"{region}: ${sales:,.2f} ({percentage:.1f}%)\")\n\n# Main execution\nif __name__ == \"__main__\":\n # Load and analyze the data\n df = load_and_analyze_sales_data('sales_data.csv')\n \n # Generate analysis and visualizations\n analyze_sales_trends(df)\n \n print(\"\\nAnalysis complete! Check the generated visualizations.\")\n```\n\nThis script provides:\n1. **Data loading** with sample data generation if CSV not found\n2. **Four key visualizations**:\n - Monthly sales trends by region\n - Top-selling products bar chart\n - Regional sales distribution pie chart\n - Daily sales volume timeline\n3. **Summary statistics** including totals, averages, and rankings\n\n**Required libraries:** `pandas`, `matplotlib`, `seaborn`, `numpy`\n\nTo run: `pip install pandas matplotlib seaborn numpy` then execute the script.", | |
| "iteration": "Iteration 1", | |
| "promptDetails": null, | |
| "timestamp": "2024-01-15T10:02:00.000Z" | |
| } | |
| ] | |
| } | |
| } | |
| } |