Spaces:
Running
Running
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>AI Chatbot</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> | |
| .chat-container { | |
| height: calc(100vh - 120px); | |
| } | |
| .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 span { | |
| animation: bounce 1.5s infinite ease-in-out; | |
| display: inline-block; | |
| } | |
| .typing-indicator span:nth-child(2) { | |
| animation-delay: 0.2s; | |
| } | |
| .typing-indicator span:nth-child(3) { | |
| animation-delay: 0.4s; | |
| } | |
| @keyframes bounce { | |
| 0%, 100% { transform: translateY(0); } | |
| 50% { transform: translateY(-5px); } | |
| } | |
| </style> | |
| </head> | |
| <body class="bg-gray-100 font-sans"> | |
| <div class="max-w-4xl mx-auto p-4"> | |
| <!-- Header --> | |
| <header class="bg-white rounded-t-lg shadow-sm p-4 flex items-center justify-between"> | |
| <div class="flex items-center space-x-3"> | |
| <div class="w-10 h-10 rounded-full bg-gradient-to-r from-blue-500 to-purple-600 flex items-center justify-center text-white"> | |
| <i class="fas fa-robot text-xl"></i> | |
| </div> | |
| <div> | |
| <h1 class="font-bold text-lg">AI Assistant</h1> | |
| <p class="text-xs text-gray-500">Always here to help</p> | |
| </div> | |
| </div> | |
| <div class="flex space-x-2"> | |
| <button class="p-2 rounded-full hover:bg-gray-100 text-gray-500"> | |
| <i class="fas fa-ellipsis-v"></i> | |
| </button> | |
| </div> | |
| </header> | |
| <!-- Chat container --> | |
| <div class="chat-container bg-white overflow-y-auto p-4 space-y-4" id="chatContainer"> | |
| <!-- Welcome message --> | |
| <div class="message-animation flex space-x-3"> | |
| <div class="flex-shrink-0"> | |
| <div class="w-8 h-8 rounded-full bg-gradient-to-r from-blue-500 to-purple-600 flex items-center justify-center text-white"> | |
| <i class="fas fa-robot text-sm"></i> | |
| </div> | |
| </div> | |
| <div class="bg-gray-100 rounded-lg p-3 max-w-xs md:max-w-md lg:max-w-lg"> | |
| <p class="text-gray-800">Hello! I'm your AI assistant. How can I help you today?</p> | |
| <p class="text-xs text-gray-500 mt-1">Just now</p> | |
| </div> | |
| </div> | |
| <!-- Sample conversation (will be populated dynamically) --> | |
| <div id="messagesContainer"></div> | |
| <!-- Typing indicator (hidden by default) --> | |
| <div id="typingIndicator" class="hidden flex space-x-3"> | |
| <div class="flex-shrink-0"> | |
| <div class="w-8 h-8 rounded-full bg-gradient-to-r from-blue-500 to-purple-600 flex items-center justify-center text-white"> | |
| <i class="fas fa-robot text-sm"></i> | |
| </div> | |
| </div> | |
| <div class="bg-gray-100 rounded-lg p-3 w-20"> | |
| <div class="typing-indicator flex space-x-1"> | |
| <span class="w-2 h-2 bg-gray-400 rounded-full"></span> | |
| <span class="w-2 h-2 bg-gray-400 rounded-full"></span> | |
| <span class="w-2 h-2 bg-gray-400 rounded-full"></span> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Input area --> | |
| <div class="bg-white rounded-b-lg shadow-sm p-4"> | |
| <form id="chatForm" class="flex space-x-2"> | |
| <div class="flex-grow relative"> | |
| <input | |
| type="text" | |
| id="userInput" | |
| placeholder="Type your message..." | |
| class="w-full border border-gray-300 rounded-full py-2 px-4 pr-10 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent" | |
| autocomplete="off" | |
| > | |
| <button type="button" class="absolute right-2 top-1/2 transform -translate-y-1/2 text-gray-400 hover:text-blue-500"> | |
| <i class="far fa-smile"></i> | |
| </button> | |
| </div> | |
| <button type="submit" class="bg-gradient-to-r from-blue-500 to-purple-600 text-white rounded-full w-10 h-10 flex items-center justify-center hover:from-blue-600 hover:to-purple-700 transition"> | |
| <i class="fas fa-paper-plane"></i> | |
| </button> | |
| </form> | |
| <div class="flex justify-between mt-2 text-xs text-gray-500"> | |
| <p>AI may produce inaccurate information</p> | |
| <p><i class="fas fa-shield-alt"></i> Secure</p> | |
| </div> | |
| </div> | |
| </div> | |
| <script> | |
| document.addEventListener('DOMContentLoaded', function() { | |
| const chatForm = document.getElementById('chatForm'); | |
| const userInput = document.getElementById('userInput'); | |
| const messagesContainer = document.getElementById('messagesContainer'); | |
| const chatContainer = document.getElementById('chatContainer'); | |
| const typingIndicator = document.getElementById('typingIndicator'); | |
| // Sample responses | |
| const sampleResponses = [ | |
| "I'd be happy to help with that. Could you provide more details?", | |
| "That's an interesting question. Here's what I know about it...", | |
| "I understand your concern. The best approach would be...", | |
| "Let me check my knowledge base for that information...", | |
| "Based on my training data, I can tell you that...", | |
| "I'm designed to be helpful, harmless, and honest in my responses." | |
| ]; | |
| // Add message to chat | |
| function addMessage(text, isUser) { | |
| const messageDiv = document.createElement('div'); | |
| messageDiv.className = `message-animation flex space-x-3 ${isUser ? 'justify-end' : ''}`; | |
| const timestamp = new Date().toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' }); | |
| messageDiv.innerHTML = ` | |
| ${!isUser ? ` | |
| <div class="flex-shrink-0"> | |
| <div class="w-8 h-8 rounded-full bg-gradient-to-r from-blue-500 to-purple-600 flex items-center justify-center text-white"> | |
| <i class="fas fa-robot text-sm"></i> | |
| </div> | |
| </div> | |
| ` : ''} | |
| <div class="${isUser ? 'bg-blue-500 text-white' : 'bg-gray-100 text-gray-800'} rounded-lg p-3 max-w-xs md:max-w-md lg:max-w-lg"> | |
| <p>${text}</p> | |
| <p class="text-xs ${isUser ? 'text-blue-100' : 'text-gray-500'} mt-1">${timestamp}</p> | |
| </div> | |
| ${isUser ? ` | |
| <div class="flex-shrink-0"> | |
| <div class="w-8 h-8 rounded-full bg-gray-200 flex items-center justify-center text-gray-600"> | |
| <i class="fas fa-user text-sm"></i> | |
| </div> | |
| </div> | |
| ` : ''} | |
| `; | |
| messagesContainer.appendChild(messageDiv); | |
| chatContainer.scrollTop = chatContainer.scrollHeight; | |
| } | |
| // Get random response | |
| function getRandomResponse() { | |
| return sampleResponses[Math.floor(Math.random() * sampleResponses.length)]; | |
| } | |
| // Handle form submission | |
| chatForm.addEventListener('submit', function(e) { | |
| e.preventDefault(); | |
| const message = userInput.value.trim(); | |
| if (message) { | |
| // Add user message | |
| addMessage(message, true); | |
| userInput.value = ''; | |
| // Show typing indicator | |
| typingIndicator.classList.remove('hidden'); | |
| chatContainer.scrollTop = chatContainer.scrollHeight; | |
| // Simulate AI thinking | |
| setTimeout(() => { | |
| typingIndicator.classList.add('hidden'); | |
| // Add AI response | |
| setTimeout(() => { | |
| addMessage(getRandomResponse(), false); | |
| }, 200); | |
| }, 1000 + Math.random() * 2000); | |
| } | |
| }); | |
| // Auto-focus input | |
| userInput.focus(); | |
| }); | |
| </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://deepsite.hf.co/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://deepsite.hf.co" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://deepsite.hf.co?remix=oxyle/aibbotnext" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body> | |
| </html> |