Spaces:
Running
Running
Download index.html from adithya0112/dea: direct link, hf CLI and curl.
- Browser
- Download file 36.2 kB
-
https://huggingface.co/spaces/adithya0112/dea/resolve/main/index.html
- Command line
-
hf download hf://spaces/adithya0112/dea/index.html
-
curl -L -o index.html https://huggingface.co/spaces/adithya0112/dea/resolve/main/index.html
36.2 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>EDA Chatbot - Natural Language Data Exploration</title> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> | |
| <style> | |
| .dark { | |
| color-scheme: dark; | |
| } | |
| .dark body { | |
| background-color: #1a202c; | |
| color: #e2e8f0; | |
| } | |
| .dark .bg-white { | |
| background-color: #1e293b; | |
| } | |
| .dark .text-gray-700 { | |
| color: #e2e8f0; | |
| } | |
| .dark .text-gray-600 { | |
| color: #cbd5e0; | |
| } | |
| .dark .border-gray-200 { | |
| border-color: #334155; | |
| } | |
| .dark .bg-gray-100 { | |
| background-color: #0f172a; | |
| } | |
| .dark .bg-indigo-50 { | |
| background-color: #1e1b4b; | |
| } | |
| .dark .text-indigo-800 { | |
| color: #a5b4fc; | |
| } | |
| .dark .bg-gray-200 { | |
| background-color: #334155; | |
| } | |
| .dark .text-gray-700 { | |
| color: #e2e8f0; | |
| } | |
| .dark .hover\:bg-gray-300:hover { | |
| background-color: #475569; | |
| } | |
| .chat-container { | |
| height: calc(100vh - 180px); | |
| } | |
| .message-animation { | |
| animation: fadeIn 0.3s ease-in-out; | |
| } | |
| @keyframes fadeIn { | |
| from { opacity: 0; transform: translateY(10px); } | |
| to { opacity: 1; transform: translateY(0); } | |
| } | |
| .typing-indicator::after { | |
| content: "..."; | |
| animation: typing 1.5s infinite; | |
| } | |
| @keyframes typing { | |
| 0% { content: "."; } | |
| 33% { content: ".."; } | |
| 66% { content: "..."; } | |
| } | |
| </style> | |
| </head> | |
| <body class="bg-gray-100 font-sans"> | |
| <div class="container mx-auto max-w-6xl px-4 py-6"> | |
| <!-- Header --> | |
| <header class="mb-8"> | |
| <div class="flex flex-col md:flex-row justify-between items-center"> | |
| <div> | |
| <h1 class="text-3xl font-bold text-indigo-700">EDA Chatbot</h1> | |
| <p class="text-gray-600">Natural Language Data Exploration with AI</p> | |
| </div> | |
| <div class="mt-4 md:mt-0 flex space-x-4 items-center"> | |
| <button id="dark-mode-toggle" class="p-2 rounded-full hover:bg-gray-200 dark:hover:bg-gray-700 transition"> | |
| <i class="fas fa-moon"></i> | |
| </button> | |
| <button id="color-picker-btn" class="p-2 rounded-full hover:bg-gray-200 dark:hover:bg-gray-700 transition"> | |
| <i class="fas fa-palette"></i> | |
| </button> | |
| <button id="upload-btn" class="bg-white text-indigo-600 px-4 py-2 rounded-lg border border-indigo-300 hover:bg-indigo-50 transition flex items-center dark:bg-gray-800 dark:border-gray-600 dark:text-indigo-400 dark:hover:bg-gray-700"> | |
| <i class="fas fa-upload mr-2"></i> Upload Dataset | |
| </button> | |
| <button id="sample-btn" class="bg-indigo-600 text-white px-4 py-2 rounded-lg hover:bg-indigo-700 transition flex items-center dark:bg-indigo-700 dark:hover:bg-indigo-800"> | |
| <i class="fas fa-database mr-2"></i> Sample Data | |
| </button> | |
| </div> | |
| </div> | |
| </header> | |
| <!-- Main Content --> | |
| <div class="bg-white rounded-xl shadow-lg overflow-hidden"> | |
| <!-- Chat Area --> | |
| <div id="chat-container" class="chat-container p-4 overflow-y-auto space-y-4"> | |
| <!-- Welcome Message --> | |
| <div class="message-animation flex"> | |
| <div class="w-10 h-10 rounded-full bg-indigo-100 flex items-center justify-center mr-3 flex-shrink-0"> | |
| <i class="fas fa-robot text-indigo-600"></i> | |
| </div> | |
| <div class="bg-indigo-50 rounded-xl p-4 max-w-[80%]"> | |
| <p class="font-medium text-indigo-800">Hello! I'm your EDA Assistant</p> | |
| <p class="text-gray-700 mt-1">I can help you explore and understand your datasets using natural language. You can:</p> | |
| <ul class="list-disc pl-5 mt-2 text-gray-700 space-y-1"> | |
| <li>Upload a CSV or Excel file</li> | |
| <li>Ask questions about your data</li> | |
| <li>Request visualizations and statistical insights</li> | |
| <li>Get help with data cleaning suggestions</li> | |
| </ul> | |
| <p class="text-gray-700 mt-2">What would you like to explore today?</p> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Input Area --> | |
| <div class="border-t border-gray-200 p-4 bg-gray-50"> | |
| <form id="chat-form" class="flex space-x-2"> | |
| <input | |
| id="message-input" | |
| type="text" | |
| placeholder="Ask about your data (e.g., 'Show me the distribution of ages')" | |
| class="flex-1 px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent" | |
| autocomplete="off" | |
| > | |
| <button type="submit" class="bg-indigo-600 text-white px-5 py-3 rounded-lg hover:bg-indigo-700 transition flex items-center"> | |
| <i class="fas fa-paper-plane"></i> | |
| </button> | |
| </form> | |
| <div class="mt-3 flex flex-wrap gap-2"> | |
| <button class="suggestion-btn bg-gray-200 text-gray-700 px-3 py-1 rounded-full text-sm hover:bg-gray-300 transition">Show me summary statistics</button> | |
| <button class="suggestion-btn bg-gray-200 text-gray-700 px-3 py-1 rounded-full text-sm hover:bg-gray-300 transition">Are there any missing values?</button> | |
| <button class="suggestion-btn bg-gray-200 text-gray-700 px-3 py-1 rounded-full text-sm hover:bg-gray-300 transition">Plot a histogram of ages</button> | |
| <button class="suggestion-btn bg-gray-200 text-gray-700 px-3 py-1 rounded-full text-sm hover:bg-gray-300 transition">Find correlations</button> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Data Info Panel (hidden by default) --> | |
| <div id="data-panel" class="hidden mt-6 bg-white rounded-xl shadow-lg p-6"> | |
| <div class="flex justify-between items-center mb-4"> | |
| <h2 class="text-xl font-semibold text-gray-800">Dataset Information</h2> | |
| <button id="close-panel" class="text-gray-500 hover:text-gray-700"> | |
| <i class="fas fa-times"></i> | |
| </button> | |
| </div> | |
| <div id="data-info-content"> | |
| <div class="text-center py-10 text-gray-500 dark:text-gray-400"> | |
| <i class="fas fa-database text-4xl mb-3"></i> | |
| <p>No dataset loaded. Upload a file to begin analysis.</p> | |
| </div> | |
| </div> | |
| <div id="visualization-buttons" class="hidden mt-6 grid grid-cols-2 gap-3"> | |
| <button class="viz-btn bg-indigo-600 text-white px-4 py-3 rounded-lg hover:bg-indigo-700 transition flex items-center justify-center dark:bg-indigo-700 dark:hover:bg-indigo-800"> | |
| <i class="fas fa-chart-bar mr-2"></i> Histogram | |
| </button> | |
| <button class="viz-btn bg-indigo-600 text-white px-4 py-3 rounded-lg hover:bg-indigo-700 transition flex items-center justify-center dark:bg-indigo-700 dark:hover:bg-indigo-800"> | |
| <i class="fas fa-chart-line mr-2"></i> Line Chart | |
| </button> | |
| <button class="viz-btn bg-indigo-600 text-white px-4 py-3 rounded-lg hover:bg-indigo-700 transition flex items-center justify-center dark:bg-indigo-700 dark:hover:bg-indigo-800"> | |
| <i class="fas fa-chart-pie mr-2"></i> Pie Chart | |
| </button> | |
| <button class="viz-btn bg-indigo-600 text-white px-4 py-3 rounded-lg hover:bg-indigo-700 transition flex items-center justify-center dark:bg-indigo-700 dark:hover:bg-indigo-800"> | |
| <i class="fas fa-project-diagram mr-2"></i> Scatter Plot | |
| </button> | |
| <button class="viz-btn bg-indigo-600 text-white px-4 py-3 rounded-lg hover:bg-indigo-700 transition flex items-center justify-center dark:bg-indigo-700 dark:hover:bg-indigo-800"> | |
| <i class="fas fa-table mr-2"></i> Heatmap | |
| </button> | |
| <button class="viz-btn bg-indigo-600 text-white px-4 py-3 rounded-lg hover:bg-indigo-700 transition flex items-center justify-center dark:bg-indigo-700 dark:hover:bg-indigo-800"> | |
| <i class="fas fa-boxes mr-2"></i> Box Plot | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Color Picker Modal --> | |
| <div id="color-picker-modal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center hidden z-50"> | |
| <div class="bg-white rounded-xl p-6 w-full max-w-xs dark:bg-gray-800"> | |
| <div class="flex justify-between items-center mb-4"> | |
| <h3 class="text-lg font-semibold dark:text-white">Choose Theme Color</h3> | |
| <button id="close-color-modal" class="text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200"> | |
| <i class="fas fa-times"></i> | |
| </button> | |
| </div> | |
| <div class="grid grid-cols-5 gap-3"> | |
| <button class="color-option h-10 w-10 rounded-full bg-indigo-600 hover:opacity-80 transition" data-color="indigo"></button> | |
| <button class="color-option h-10 w-10 rounded-full bg-blue-600 hover:opacity-80 transition" data-color="blue"></button> | |
| <button class="color-option h-10 w-10 rounded-full bg-green-600 hover:opacity-80 transition" data-color="green"></button> | |
| <button class="color-option h-10 w-10 rounded-full bg-red-600 hover:opacity-80 transition" data-color="red"></button> | |
| <button class="color-option h-10 w-10 rounded-full bg-purple-600 hover:opacity-80 transition" data-color="purple"></button> | |
| <button class="color-option h-10 w-10 rounded-full bg-pink-600 hover:opacity-80 transition" data-color="pink"></button> | |
| <button class="color-option h-10 w-10 rounded-full bg-yellow-600 hover:opacity-80 transition" data-color="yellow"></button> | |
| <button class="color-option h-10 w-10 rounded-full bg-teal-600 hover:opacity-80 transition" data-color="teal"></button> | |
| <button class="color-option h-10 w-10 rounded-full bg-orange-600 hover:opacity-80 transition" data-color="orange"></button> | |
| <button class="color-option h-10 w-10 rounded-full bg-amber-600 hover:opacity-80 transition" data-color="amber"></button> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- File Upload Modal --> | |
| <div id="upload-modal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center hidden z-50"> | |
| <div class="bg-white rounded-xl p-6 w-full max-w-md"> | |
| <div class="flex justify-between items-center mb-4"> | |
| <h3 class="text-lg font-semibold">Upload Dataset</h3> | |
| <button id="close-modal" class="text-gray-500 hover:text-gray-700"> | |
| <i class="fas fa-times"></i> | |
| </button> | |
| </div> | |
| <div class="border-2 border-dashed border-gray-300 rounded-lg p-8 text-center mb-4"> | |
| <i class="fas fa-file-csv text-4xl text-indigo-500 mb-3"></i> | |
| <p class="text-gray-600">Drag & drop your CSV or Excel file here</p> | |
| <p class="text-gray-400 text-sm mt-2">or</p> | |
| <input type="file" id="file-input" class="hidden" accept=".csv,.xlsx,.xls"> | |
| <button id="browse-btn" class="mt-3 bg-indigo-600 text-white px-4 py-2 rounded-lg hover:bg-indigo-700 transition"> | |
| Browse Files | |
| </button> | |
| </div> | |
| <div class="flex justify-end space-x-3"> | |
| <button id="cancel-upload" class="px-4 py-2 border border-gray-300 rounded-lg hover:bg-gray-100">Cancel</button> | |
| <button id="confirm-upload" class="px-4 py-2 bg-indigo-600 text-white rounded-lg hover:bg-indigo-700 disabled:opacity-50" disabled> | |
| Upload & Analyze | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| <script> | |
| // DOM Elements | |
| const darkModeToggle = document.getElementById('dark-mode-toggle'); | |
| const colorPickerBtn = document.getElementById('color-picker-btn'); | |
| const colorPickerModal = document.getElementById('color-picker-modal'); | |
| const closeColorModal = document.getElementById('close-color-modal'); | |
| const colorOptions = document.querySelectorAll('.color-option'); | |
| const visualizationButtons = document.getElementById('visualization-buttons'); | |
| const chatContainer = document.getElementById('chat-container'); | |
| const chatForm = document.getElementById('chat-form'); | |
| const messageInput = document.getElementById('message-input'); | |
| const uploadBtn = document.getElementById('upload-btn'); | |
| const sampleBtn = document.getElementById('sample-btn'); | |
| const uploadModal = document.getElementById('upload-modal'); | |
| const closeModal = document.getElementById('close-modal'); | |
| const cancelUpload = document.getElementById('cancel-upload'); | |
| const browseBtn = document.getElementById('browse-btn'); | |
| const fileInput = document.getElementById('file-input'); | |
| const confirmUpload = document.getElementById('confirm-upload'); | |
| const dataPanel = document.getElementById('data-panel'); | |
| const closePanel = document.getElementById('close-panel'); | |
| const dataInfoContent = document.getElementById('data-info-content'); | |
| const suggestionBtns = document.querySelectorAll('.suggestion-btn'); | |
| // Sample datasets | |
| const sampleDatasets = [ | |
| { name: "Iris Dataset", description: "Classic dataset with flower measurements" }, | |
| { name: "Titanic Dataset", description: "Passenger information from the Titanic" }, | |
| { name: "Housing Prices", description: "Real estate data with price predictions" } | |
| ]; | |
| // Event Listeners | |
| darkModeToggle.addEventListener('click', toggleDarkMode); | |
| colorPickerBtn.addEventListener('click', () => colorPickerModal.classList.remove('hidden')); | |
| closeColorModal.addEventListener('click', () => colorPickerModal.classList.add('hidden')); | |
| colorOptions.forEach(option => { | |
| option.addEventListener('click', (e) => { | |
| const color = e.target.getAttribute('data-color'); | |
| changeThemeColor(color); | |
| colorPickerModal.classList.add('hidden'); | |
| }); | |
| }); | |
| chatForm.addEventListener('submit', sendMessage); | |
| uploadBtn.addEventListener('click', showUploadModal); | |
| sampleBtn.addEventListener('click', showSampleOptions); | |
| closeModal.addEventListener('click', hideUploadModal); | |
| cancelUpload.addEventListener('click', hideUploadModal); | |
| browseBtn.addEventListener('click', () => fileInput.click()); | |
| fileInput.addEventListener('change', handleFileSelect); | |
| closePanel.addEventListener('click', () => dataPanel.classList.add('hidden')); | |
| suggestionBtns.forEach(btn => btn.addEventListener('click', (e) => { | |
| messageInput.value = e.target.textContent; | |
| messageInput.focus(); | |
| })); | |
| // Initialize theme color from localStorage | |
| const savedColor = localStorage.getItem('themeColor') || 'indigo'; | |
| changeThemeColor(savedColor); | |
| // Functions | |
| function showUploadModal() { | |
| uploadModal.classList.remove('hidden'); | |
| } | |
| function hideUploadModal() { | |
| uploadModal.classList.add('hidden'); | |
| fileInput.value = ''; | |
| confirmUpload.disabled = true; | |
| } | |
| function handleFileSelect(e) { | |
| if (e.target.files.length > 0) { | |
| confirmUpload.disabled = false; | |
| } | |
| } | |
| function showSampleOptions() { | |
| // Simulate loading a sample dataset | |
| addMessage('user', 'Load sample dataset'); | |
| setTimeout(() => { | |
| addMessage('bot', 'Which sample dataset would you like to use?', true); | |
| setTimeout(() => { | |
| const sampleOptions = document.createElement('div'); | |
| sampleOptions.className = 'message-animation flex'; | |
| sampleOptions.innerHTML = ` | |
| <div class="w-10 h-10 rounded-full bg-indigo-100 flex items-center justify-center mr-3 flex-shrink-0"> | |
| <i class="fas fa-robot text-indigo-600"></i> | |
| </div> | |
| <div class="bg-indigo-50 rounded-xl p-4 max-w-[80%]"> | |
| <div class="grid grid-cols-1 gap-2"> | |
| ${sampleDatasets.map(dataset => ` | |
| <button class="sample-dataset-btn text-left p-3 rounded-lg bg-white hover:bg-indigo-100 border border-gray-200 transition" data-name="${dataset.name}"> | |
| <p class="font-medium">${dataset.name}</p> | |
| <p class="text-sm text-gray-600">${dataset.description}</p> | |
| </button> | |
| `).join('')} | |
| </div> | |
| </div> | |
| `; | |
| chatContainer.appendChild(sampleOptions); | |
| // Add event listeners to sample dataset buttons | |
| document.querySelectorAll('.sample-dataset-btn').forEach(btn => { | |
| btn.addEventListener('click', (e) => { | |
| const datasetName = e.currentTarget.getAttribute('data-name'); | |
| loadSampleDataset(datasetName); | |
| }); | |
| }); | |
| // Scroll to bottom | |
| chatContainer.scrollTop = chatContainer.scrollHeight; | |
| }, 500); | |
| }, 1000); | |
| } | |
| function loadSampleDataset(name) { | |
| addMessage('user', `Use ${name}`); | |
| // Show typing indicator | |
| const typingId = showTypingIndicator(); | |
| // Simulate dataset loading | |
| setTimeout(() => { | |
| // Remove typing indicator | |
| removeTypingIndicator(typingId); | |
| // Add bot response | |
| addMessage('bot', `Successfully loaded the ${name}. Here's a quick overview:`, false); | |
| // Simulate data summary | |
| setTimeout(() => { | |
| const sampleData = { | |
| name: name, | |
| rows: Math.floor(Math.random() * 1000) + 500, | |
| columns: Math.floor(Math.random() * 15) + 5, | |
| preview: Array(5).fill().map(() => | |
| Array(5).fill().map(() => Math.random().toString(36).substring(2, 8)) | |
| ) | |
| }; | |
| showDatasetInfo(sampleData); | |
| addMessage('bot', ` | |
| <p>The dataset contains ${sampleData.rows} rows and ${sampleData.columns} columns.</p> | |
| <p class="mt-2">You can now ask questions about the data like:</p> | |
| <ul class="list-disc pl-5 mt-1 space-y-1"> | |
| <li>What are the column names?</li> | |
| <li>Show me summary statistics</li> | |
| <li>Are there any missing values?</li> | |
| </ul> | |
| `, false); | |
| }, 800); | |
| }, 1500); | |
| } | |
| function showDatasetInfo(data) { | |
| dataPanel.classList.remove('hidden'); | |
| // Create a simple table preview | |
| let tableHtml = ` | |
| <div> | |
| <div class="mb-4"> | |
| <h3 class="font-medium text-lg">${data.name}</h3> | |
| <p class="text-gray-600">${data.rows} rows × ${data.columns} columns</p> | |
| </div> | |
| <div class="overflow-x-auto"> | |
| <table class="min-w-full bg-white border border-gray-200"> | |
| <thead> | |
| <tr class="bg-gray-50"> | |
| ${data.preview[0].map((_, i) => `<th class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase border-b">Col ${i+1}</th>`).join('')} | |
| </tr> | |
| </thead> | |
| <tbody> | |
| ${data.preview.map(row => ` | |
| <tr class="hover:bg-gray-50"> | |
| ${row.map(cell => `<td class="px-4 py-2 border-b text-sm">${cell}</td>`).join('')} | |
| </tr> | |
| `).join('')} | |
| </tbody> | |
| </table> | |
| </div> | |
| <p class="text-sm text-gray-500 mt-2">Showing first 5 rows</p> | |
| </div> | |
| `; | |
| dataInfoContent.innerHTML = tableHtml; | |
| visualizationButtons.classList.remove('hidden'); | |
| setupVisualizationButtons(); | |
| } | |
| function sendMessage(e) { | |
| e.preventDefault(); | |
| const message = messageInput.value.trim(); | |
| if (!message) return; | |
| addMessage('user', message); | |
| messageInput.value = ''; | |
| // Show typing indicator | |
| const typingId = showTypingIndicator(); | |
| // Simulate bot response after a delay | |
| setTimeout(() => { | |
| // Remove typing indicator | |
| removeTypingIndicator(typingId); | |
| // Generate response | |
| const response = generateBotResponse(message); | |
| addMessage('bot', response, true); | |
| // If the message is about loading data, show the data panel | |
| if (message.toLowerCase().includes('load') || message.toLowerCase().includes('dataset')) { | |
| setTimeout(() => { | |
| dataPanel.classList.remove('hidden'); | |
| }, 500); | |
| } | |
| }, 1500 + Math.random() * 1000); | |
| } | |
| function showTypingIndicator() { | |
| const typingId = 'typing-' + Date.now(); | |
| const typingElement = document.createElement('div'); | |
| typingElement.id = typingId; | |
| typingElement.className = 'message-animation flex'; | |
| typingElement.innerHTML = ` | |
| <div class="w-10 h-10 rounded-full bg-indigo-100 flex items-center justify-center mr-3 flex-shrink-0"> | |
| <i class="fas fa-robot text-indigo-600"></i> | |
| </div> | |
| <div class="bg-indigo-50 rounded-xl p-4 max-w-[80%]"> | |
| <div class="typing-indicator text-gray-700">Thinking</div> | |
| </div> | |
| `; | |
| chatContainer.appendChild(typingElement); | |
| chatContainer.scrollTop = chatContainer.scrollHeight; | |
| return typingId; | |
| } | |
| function removeTypingIndicator(id) { | |
| const element = document.getElementById(id); | |
| if (element) { | |
| element.remove(); | |
| } | |
| } | |
| function addMessage(sender, content, isHTML = false) { | |
| const messageElement = document.createElement('div'); | |
| messageElement.className = 'message-animation flex'; | |
| if (sender === 'user') { | |
| messageElement.innerHTML = ` | |
| <div class="ml-auto max-w-[80%]"> | |
| <div class="bg-indigo-600 text-white rounded-xl p-4"> | |
| ${content} | |
| </div> | |
| </div> | |
| `; | |
| } else { | |
| messageElement.innerHTML = ` | |
| <div class="w-10 h-10 rounded-full bg-indigo-100 flex items-center justify-center mr-3 flex-shrink-0"> | |
| <i class="fas fa-robot text-indigo-600"></i> | |
| </div> | |
| <div class="bg-indigo-50 rounded-xl p-4 max-w-[80%]"> | |
| ${isHTML ? content : `<p class="text-gray-700">${content}</p>`} | |
| </div> | |
| `; | |
| } | |
| chatContainer.appendChild(messageElement); | |
| chatContainer.scrollTop = chatContainer.scrollHeight; | |
| } | |
| function changeThemeColor(color) { | |
| // Update all elements with indigo color classes | |
| document.querySelectorAll('.bg-indigo-600, .text-indigo-600, .border-indigo-600, .bg-indigo-50, .text-indigo-800, .bg-indigo-700, .hover:bg-indigo-700, .focus:ring-indigo-500') | |
| .forEach(el => { | |
| // Replace indigo with new color | |
| Array.from(el.classList).forEach(cls => { | |
| if (cls.includes('indigo')) { | |
| el.classList.remove(cls); | |
| el.classList.add(cls.replace('indigo', color)); | |
| } | |
| }); | |
| }); | |
| // Update dark mode variants | |
| document.querySelectorAll('.dark .bg-indigo-700, .dark .bg-indigo-800') | |
| .forEach(el => { | |
| Array.from(el.classList).forEach(cls => { | |
| if (cls.includes('indigo')) { | |
| el.classList.remove(cls); | |
| el.classList.add(cls.replace('indigo', color)); | |
| } | |
| }); | |
| }); | |
| // Store preference in localStorage | |
| localStorage.setItem('themeColor', color); | |
| } | |
| function toggleDarkMode() { | |
| document.documentElement.classList.toggle('dark'); | |
| const icon = darkModeToggle.querySelector('i'); | |
| if (document.documentElement.classList.contains('dark')) { | |
| icon.classList.replace('fa-moon', 'fa-sun'); | |
| } else { | |
| icon.classList.replace('fa-sun', 'fa-moon'); | |
| } | |
| } | |
| // Add viz button event listeners | |
| function setupVisualizationButtons() { | |
| const vizButtons = document.querySelectorAll('.viz-btn'); | |
| vizButtons.forEach(btn => { | |
| btn.addEventListener('click', (e) => { | |
| const vizType = e.target.textContent.trim() || | |
| e.target.querySelector('i').className.split(' ')[1].split('-')[1]; | |
| addMessage('user', `Create ${vizType} visualization`); | |
| // Show typing indicator | |
| const typingId = showTypingIndicator(); | |
| setTimeout(() => { | |
| removeTypingIndicator(typingId); | |
| addMessage('bot', generateVizResponse(vizType), true); | |
| }, 1000); | |
| }); | |
| }); | |
| } | |
| function generateVizResponse(vizType) { | |
| const vizNames = { | |
| 'bar': 'Histogram', | |
| 'line': 'Line Chart', | |
| 'pie': 'Pie Chart', | |
| 'scatter': 'Scatter Plot', | |
| 'heatmap': 'Heatmap', | |
| 'box': 'Box Plot' | |
| }; | |
| return `Here's your ${vizNames[vizType] || vizType} visualization: | |
| <div class="mt-3 bg-white dark:bg-gray-800 p-4 rounded-lg border border-gray-200 dark:border-gray-700"> | |
| <div class="h-64 bg-gray-100 dark:bg-gray-700 rounded flex items-center justify-center text-gray-400 dark:text-gray-500"> | |
| [Simulated ${vizNames[vizType] || vizType} Visualization] | |
| </div> | |
| <p class="mt-2 text-sm text-gray-600 dark:text-gray-400 text-center">${vizNames[vizType] || vizType} showing relevant data patterns</p> | |
| </div> | |
| <p class="mt-2">Would you like to customize this visualization or try a different type?</p>`; | |
| } | |
| function generateBotResponse(message) { | |
| const lowerMsg = message.toLowerCase(); | |
| if (lowerMsg.includes('hello') || lowerMsg.includes('hi') || lowerMsg.includes('hey')) { | |
| return "Hello! How can I assist you with your data exploration today?"; | |
| } | |
| if (lowerMsg.includes('thank')) { | |
| return "You're welcome! Let me know if you need any more help with your data analysis."; | |
| } | |
| if (lowerMsg.includes('summary') || lowerMsg.includes('statistic')) { | |
| return `Here's a summary of your dataset: | |
| <div class="mt-2"> | |
| <div class="grid grid-cols-2 gap-2"> | |
| <div class="bg-white p-3 rounded-lg border border-gray-200"> | |
| <p class="text-sm text-gray-500">Rows</p> | |
| <p class="font-medium">1,000</p> | |
| </div> | |
| <div class="bg-white p-3 rounded-lg border border-gray-200"> | |
| <p class="text-sm text-gray-500">Columns</p> | |
| <p class="font-medium">8</p> | |
| </div> | |
| </div> | |
| <div class="mt-2 bg-white p-3 rounded-lg border border-gray-200"> | |
| <p class="text-sm text-gray-500">Numerical Columns</p> | |
| <p class="font-medium">5 (age, income, score, height, weight)</p> | |
| </div> | |
| <div class="mt-2 bg-white p-3 rounded-lg border border-gray-200"> | |
| <p class="text-sm text-gray-500">Categorical Columns</p> | |
| <p class="font-medium">3 (gender, education, region)</p> | |
| </div> | |
| </div>`; | |
| } | |
| if (lowerMsg.includes('missing') || lowerMsg.includes('null')) { | |
| return `I've checked for missing values: | |
| <div class="mt-2"> | |
| <div class="bg-white p-3 rounded-lg border border-gray-200"> | |
| <p class="text-sm text-gray-500">Total Missing Values</p> | |
| <p class="font-medium">42 (0.42% of all data)</p> | |
| </div> | |
| <div class="mt-2 bg-white p-3 rounded-lg border border-gray-200"> | |
| <p class="text-sm text-gray-500">Columns with Missing Values</p> | |
| <p class="font-medium">income (12), education (30)</p> | |
| </div> | |
| <p class="mt-2 text-sm">Would you like me to suggest ways to handle these missing values?</p> | |
| </div>`; | |
| } | |
| if (lowerMsg.includes('visualization') || lowerMsg.includes('plot') || lowerMsg.includes('chart') || lowerMsg.includes('graph')) { | |
| return `I can generate various visualizations. Here's a sample histogram: | |
| <div class="mt-3 bg-white p-4 rounded-lg border border-gray-200"> | |
| <div class="h-48 bg-gray-100 rounded flex items-center justify-center text-gray-400"> | |
| [Simulated Histogram of Age Distribution] | |
| </div> | |
| <p class="mt-2 text-sm text-gray-600 text-center">Histogram showing the distribution of ages in your dataset</p> | |
| </div> | |
| <p class="mt-2">Would you like to see a different visualization?</p>`; | |
| } | |
| if (lowerMsg.includes('correlation') || lowerMsg.includes('relationship')) { | |
| return `Here's what I found about correlations: | |
| <div class="mt-2"> | |
| <div class="bg-white p-3 rounded-lg border border-gray-200"> | |
| <p class="text-sm text-gray-500">Strongest Positive Correlation</p> | |
| <p class="font-medium">Income vs. Score (0.72)</p> | |
| </div> | |
| <div class="mt-2 bg-white p-3 rounded-lg border border-gray-200"> | |
| <p class="text-sm text-gray-500">Strongest Negative Correlation</p> | |
| <p class="font-medium">Age vs. Weight (-0.34)</p> | |
| </div> | |
| <div class="mt-2 bg-white p-3 rounded-lg border border-gray-200"> | |
| <p class="text-sm text-gray-500">No Significant Correlation</p> | |
| <p class="font-medium">Height vs. Education (0.08)</p> | |
| </div> | |
| </div> | |
| <p class="mt-2">Would you like to see a correlation matrix visualization?</p>`; | |
| } | |
| if (lowerMsg.includes('column') && lowerMsg.includes('name')) { | |
| return `The columns in your dataset are: | |
| <div class="mt-2"> | |
| <ul class="list-disc pl-5 space-y-1"> | |
| <li>age (numerical)</li> | |
| <li>gender (categorical)</li> | |
| <li>income (numerical)</li> | |
| <li>education (categorical)</li> | |
| <li>score (numerical)</li> | |
| <li>height (numerical)</li> | |
| <li>weight (numerical)</li> | |
| <li>region (categorical)</li> | |
| </ul> | |
| </div>`; | |
| } | |
| // Default response | |
| return `I can help you analyze your data. Based on your message "${message}", I can: | |
| <ul class="list-disc pl-5 mt-2 space-y-1"> | |
| <li>Generate descriptive statistics and summaries</li> | |
| <li>Create visualizations (histograms, scatter plots, etc.)</li> | |
| <li>Identify patterns, correlations, and outliers</li> | |
| <li>Help with data cleaning and preprocessing</li> | |
| </ul> | |
| <p class="mt-2">Could you be more specific about what you'd like to explore?</p>`; | |
| } | |
| </script> | |
| <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=adithya0112/dea" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body> | |
| </html> |