Download smart-chat.html from moazelgen/undefined: direct link, hf CLI and curl.
- Browser
- Download file 8.33 kB
-
https://huggingface.co/spaces/moazelgen/undefined/resolve/main/smart-chat.html
- Command line
-
hf download hf://spaces/moazelgen/undefined/smart-chat.html
-
curl -L -o smart-chat.html https://huggingface.co/spaces/moazelgen/undefined/resolve/main/smart-chat.html
8.33 kB
| <html lang="en" class="scroll-smooth"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Smart Chat | Cosmic Canvas</title> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <script src="https://unpkg.com/feather-icons"></script> | |
| <script src="https://cdn.jsdelivr.net/npm/vanta@latest/dist/vanta.globe.min.js"></script> | |
| <style> | |
| @import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&display=swap'); | |
| body { | |
| font-family: 'Space Grotesk', sans-serif; | |
| } | |
| #vanta-bg { | |
| position: absolute; | |
| top: 0; | |
| left: 0; | |
| width: 100%; | |
| height: 100%; | |
| z-index: -1; | |
| } | |
| .gradient-text { | |
| background: linear-gradient(90deg, #0ea5e9 0%, #8b5cf6 100%); | |
| -webkit-background-clip: text; | |
| background-clip: text; | |
| color: transparent; | |
| } | |
| .chat-container { | |
| height: 70vh; | |
| scrollbar-width: thin; | |
| scrollbar-color: #3b82f6 #1e293b; | |
| } | |
| .message-bubble { | |
| max-width: 80%; | |
| } | |
| </style> | |
| </head> | |
| <body class="bg-gray-900 text-white min-h-screen"> | |
| <div id="vanta-bg"></div> | |
| <nav class="fixed w-full z-50 bg-gray-900/80 backdrop-blur-md"> | |
| <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8"> | |
| <div class="flex justify-between h-16 items-center"> | |
| <div class="flex items-center"> | |
| <span class="text-2xl font-bold gradient-text">Cosmic Canvas</span> | |
| </div> | |
| <div class="hidden md:flex space-x-8"> | |
| <a href="index.html" class="text-white hover:text-primary-400 transition">Home</a> | |
| <a href="ai-lab.html" class="text-white hover:text-primary-400 transition">AI Lab</a> | |
| <a href="smart-chat.html" class="text-white hover:text-primary-400 transition font-bold">Smart Chat</a> | |
| <a href="about.html" class="text-white hover:text-primary-400 transition">About</a> | |
| </div> | |
| <button class="md:hidden text-white"> | |
| <i data-feather="menu"></i> | |
| </button> | |
| </div> | |
| </div> | |
| </nav> | |
| <main class="pt-24 pb-16 px-4 sm:px-6 lg:px-8"> | |
| <section class="max-w-4xl mx-auto"> | |
| <h1 class="text-4xl md:text-6xl font-bold mb-8 text-center"> | |
| <span class="gradient-text">Smart</span> Chat | |
| </h1> | |
| <div class="bg-gray-800/50 backdrop-blur-md rounded-xl border border-gray-700 p-6"> | |
| <div id="chat-window" class="chat-container overflow-y-auto mb-6 space-y-4"> | |
| <div class="flex justify-start"> | |
| <div class="message-bubble bg-gray-700 p-4 rounded-lg"> | |
| <p>Hello! I'm your smart AI assistant. How can I help you today?</p> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="flex items-center space-x-4"> | |
| <div class="flex-1 relative"> | |
| <textarea id="chat-input" class="w-full bg-gray-700 text-white px-4 py-3 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-500 pr-12" placeholder="Type your message..." rows="1"></textarea> | |
| <button id="voice-btn" class="absolute right-3 top-3 text-gray-400 hover:text-primary-400"> | |
| <i data-feather="mic"></i> | |
| </button> | |
| </div> | |
| <button id="send-btn" class="bg-primary-600 hover:bg-primary-700 text-white px-6 py-3 rounded-lg"> | |
| Send | |
| </button> | |
| </div> | |
| </div> | |
| </section> | |
| </main> | |
| <script> | |
| feather.replace(); | |
| // Initialize Vanta.js background | |
| VANTA.GLOBE({ | |
| el: "#vanta-bg", | |
| mouseControls: true, | |
| touchControls: true, | |
| gyroControls: false, | |
| minHeight: 200.00, | |
| minWidth: 200.00, | |
| scale: 1.00, | |
| scaleMobile: 1.00, | |
| color: 0x3b82f6, | |
| backgroundColor: 0x111827 | |
| }); | |
| // Chat functionality | |
| const chatWindow = document.getElementById('chat-window'); | |
| const chatInput = document.getElementById('chat-input'); | |
| const sendBtn = document.getElementById('send-btn'); | |
| const voiceBtn = document.getElementById('voice-btn'); | |
| // Auto-resize textarea | |
| chatInput.addEventListener('input', function() { | |
| this.style.height = 'auto'; | |
| this.style.height = (this.scrollHeight) + 'px'; | |
| }); | |
| // Send message function | |
| function sendMessage() { | |
| const message = chatInput.value.trim(); | |
| if (!message) return; | |
| // Add user message | |
| addMessage(message, 'user'); | |
| // Clear input | |
| chatInput.value = ''; | |
| chatInput.style.height = 'auto'; | |
| // Simulate AI response | |
| setTimeout(() => { | |
| const responses = [ | |
| "That's an interesting point! Could you elaborate more?", | |
| "I understand what you're saying. Here's what I think about that...", | |
| "Thanks for sharing! Based on my knowledge...", | |
| "That's a great question! The answer is...", | |
| "I've processed your input. Here's my analysis..." | |
| ]; | |
| const randomResponse = responses[Math.floor(Math.random() * responses.length)]; | |
| addMessage(randomResponse, 'ai'); | |
| }, 1000); | |
| } | |
| // Add message to chat | |
| function addMessage(text, sender) { | |
| const messageDiv = document.createElement('div'); | |
| messageDiv.className = `flex ${sender === 'user' ? 'justify-end' : 'justify-start'}`; | |
| const bubbleDiv = document.createElement('div'); | |
| bubbleDiv.className = `message-bubble ${sender === 'user' ? 'bg-primary-600' : 'bg-gray-700'} p-4 rounded-lg`; | |
| bubbleDiv.innerHTML = `<p>${text}</p>`; | |
| messageDiv.appendChild(bubbleDiv); | |
| chatWindow.appendChild(messageDiv); | |
| // Scroll to bottom | |
| chatWindow.scrollTop = chatWindow.scrollHeight; | |
| } | |
| // Event listeners | |
| sendBtn.addEventListener('click', sendMessage); | |
| chatInput.addEventListener('keypress', function(e) { | |
| if (e.key === 'Enter' && !e.shiftKey) { | |
| e.preventDefault(); | |
| sendMessage(); | |
| } | |
| }); | |
| // Voice recognition | |
| const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition; | |
| if (SpeechRecognition) { | |
| const recognition = new SpeechRecognition(); | |
| recognition.lang = 'en-US'; | |
| recognition.interimResults = false; | |
| recognition.maxAlternatives = 1; | |
| voiceBtn.addEventListener('click', function() { | |
| recognition.start(); | |
| voiceBtn.innerHTML = '<i data-feather="mic-off"></i>'; | |
| feather.replace(); | |
| }); | |
| recognition.onresult = function(event) { | |
| const speechResult = event.results[0][0].transcript; | |
| chatInput.value = speechResult; | |
| chatInput.dispatchEvent(new Event('input')); | |
| voiceBtn.innerHTML = '<i data-feather="mic"></i>'; | |
| feather.replace(); | |
| }; | |
| recognition.onerror = function(event) { | |
| console.error('Speech recognition error', event.error); | |
| voiceBtn.innerHTML = '<i data-feather="mic"></i>'; | |
| feather.replace(); | |
| }; | |
| recognition.onend = function() { | |
| voiceBtn.innerHTML = '<i data-feather="mic"></i>'; | |
| feather.replace(); | |
| }; | |
| } else { | |
| voiceBtn.style.display = 'none'; | |
| } | |
| </script> | |
| </body> | |
| </html> |