Spaces:
Running
Running
Write an clai chatbot with next.js - Initial Deployment
Browse files- README.md +7 -5
- index.html +203 -19
- prompts.txt +1 -0
README.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
+
title: aibbotnext
|
| 3 |
+
emoji: 🐳
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: red
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
tags:
|
| 9 |
+
- deepsite
|
| 10 |
---
|
| 11 |
|
| 12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
index.html
CHANGED
|
@@ -1,19 +1,203 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>AI Chatbot</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
| 9 |
+
<style>
|
| 10 |
+
.chat-container {
|
| 11 |
+
height: calc(100vh - 120px);
|
| 12 |
+
}
|
| 13 |
+
.message-animation {
|
| 14 |
+
animation: fadeIn 0.3s ease-in-out;
|
| 15 |
+
}
|
| 16 |
+
@keyframes fadeIn {
|
| 17 |
+
from { opacity: 0; transform: translateY(10px); }
|
| 18 |
+
to { opacity: 1; transform: translateY(0); }
|
| 19 |
+
}
|
| 20 |
+
.typing-indicator span {
|
| 21 |
+
animation: bounce 1.5s infinite ease-in-out;
|
| 22 |
+
display: inline-block;
|
| 23 |
+
}
|
| 24 |
+
.typing-indicator span:nth-child(2) {
|
| 25 |
+
animation-delay: 0.2s;
|
| 26 |
+
}
|
| 27 |
+
.typing-indicator span:nth-child(3) {
|
| 28 |
+
animation-delay: 0.4s;
|
| 29 |
+
}
|
| 30 |
+
@keyframes bounce {
|
| 31 |
+
0%, 100% { transform: translateY(0); }
|
| 32 |
+
50% { transform: translateY(-5px); }
|
| 33 |
+
}
|
| 34 |
+
</style>
|
| 35 |
+
</head>
|
| 36 |
+
<body class="bg-gray-100 font-sans">
|
| 37 |
+
<div class="max-w-4xl mx-auto p-4">
|
| 38 |
+
<!-- Header -->
|
| 39 |
+
<header class="bg-white rounded-t-lg shadow-sm p-4 flex items-center justify-between">
|
| 40 |
+
<div class="flex items-center space-x-3">
|
| 41 |
+
<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">
|
| 42 |
+
<i class="fas fa-robot text-xl"></i>
|
| 43 |
+
</div>
|
| 44 |
+
<div>
|
| 45 |
+
<h1 class="font-bold text-lg">AI Assistant</h1>
|
| 46 |
+
<p class="text-xs text-gray-500">Always here to help</p>
|
| 47 |
+
</div>
|
| 48 |
+
</div>
|
| 49 |
+
<div class="flex space-x-2">
|
| 50 |
+
<button class="p-2 rounded-full hover:bg-gray-100 text-gray-500">
|
| 51 |
+
<i class="fas fa-ellipsis-v"></i>
|
| 52 |
+
</button>
|
| 53 |
+
</div>
|
| 54 |
+
</header>
|
| 55 |
+
|
| 56 |
+
<!-- Chat container -->
|
| 57 |
+
<div class="chat-container bg-white overflow-y-auto p-4 space-y-4" id="chatContainer">
|
| 58 |
+
<!-- Welcome message -->
|
| 59 |
+
<div class="message-animation flex space-x-3">
|
| 60 |
+
<div class="flex-shrink-0">
|
| 61 |
+
<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">
|
| 62 |
+
<i class="fas fa-robot text-sm"></i>
|
| 63 |
+
</div>
|
| 64 |
+
</div>
|
| 65 |
+
<div class="bg-gray-100 rounded-lg p-3 max-w-xs md:max-w-md lg:max-w-lg">
|
| 66 |
+
<p class="text-gray-800">Hello! I'm your AI assistant. How can I help you today?</p>
|
| 67 |
+
<p class="text-xs text-gray-500 mt-1">Just now</p>
|
| 68 |
+
</div>
|
| 69 |
+
</div>
|
| 70 |
+
|
| 71 |
+
<!-- Sample conversation (will be populated dynamically) -->
|
| 72 |
+
<div id="messagesContainer"></div>
|
| 73 |
+
|
| 74 |
+
<!-- Typing indicator (hidden by default) -->
|
| 75 |
+
<div id="typingIndicator" class="hidden flex space-x-3">
|
| 76 |
+
<div class="flex-shrink-0">
|
| 77 |
+
<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">
|
| 78 |
+
<i class="fas fa-robot text-sm"></i>
|
| 79 |
+
</div>
|
| 80 |
+
</div>
|
| 81 |
+
<div class="bg-gray-100 rounded-lg p-3 w-20">
|
| 82 |
+
<div class="typing-indicator flex space-x-1">
|
| 83 |
+
<span class="w-2 h-2 bg-gray-400 rounded-full"></span>
|
| 84 |
+
<span class="w-2 h-2 bg-gray-400 rounded-full"></span>
|
| 85 |
+
<span class="w-2 h-2 bg-gray-400 rounded-full"></span>
|
| 86 |
+
</div>
|
| 87 |
+
</div>
|
| 88 |
+
</div>
|
| 89 |
+
</div>
|
| 90 |
+
|
| 91 |
+
<!-- Input area -->
|
| 92 |
+
<div class="bg-white rounded-b-lg shadow-sm p-4">
|
| 93 |
+
<form id="chatForm" class="flex space-x-2">
|
| 94 |
+
<div class="flex-grow relative">
|
| 95 |
+
<input
|
| 96 |
+
type="text"
|
| 97 |
+
id="userInput"
|
| 98 |
+
placeholder="Type your message..."
|
| 99 |
+
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"
|
| 100 |
+
autocomplete="off"
|
| 101 |
+
>
|
| 102 |
+
<button type="button" class="absolute right-2 top-1/2 transform -translate-y-1/2 text-gray-400 hover:text-blue-500">
|
| 103 |
+
<i class="far fa-smile"></i>
|
| 104 |
+
</button>
|
| 105 |
+
</div>
|
| 106 |
+
<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">
|
| 107 |
+
<i class="fas fa-paper-plane"></i>
|
| 108 |
+
</button>
|
| 109 |
+
</form>
|
| 110 |
+
<div class="flex justify-between mt-2 text-xs text-gray-500">
|
| 111 |
+
<p>AI may produce inaccurate information</p>
|
| 112 |
+
<p><i class="fas fa-shield-alt"></i> Secure</p>
|
| 113 |
+
</div>
|
| 114 |
+
</div>
|
| 115 |
+
</div>
|
| 116 |
+
|
| 117 |
+
<script>
|
| 118 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 119 |
+
const chatForm = document.getElementById('chatForm');
|
| 120 |
+
const userInput = document.getElementById('userInput');
|
| 121 |
+
const messagesContainer = document.getElementById('messagesContainer');
|
| 122 |
+
const chatContainer = document.getElementById('chatContainer');
|
| 123 |
+
const typingIndicator = document.getElementById('typingIndicator');
|
| 124 |
+
|
| 125 |
+
// Sample responses
|
| 126 |
+
const sampleResponses = [
|
| 127 |
+
"I'd be happy to help with that. Could you provide more details?",
|
| 128 |
+
"That's an interesting question. Here's what I know about it...",
|
| 129 |
+
"I understand your concern. The best approach would be...",
|
| 130 |
+
"Let me check my knowledge base for that information...",
|
| 131 |
+
"Based on my training data, I can tell you that...",
|
| 132 |
+
"I'm designed to be helpful, harmless, and honest in my responses."
|
| 133 |
+
];
|
| 134 |
+
|
| 135 |
+
// Add message to chat
|
| 136 |
+
function addMessage(text, isUser) {
|
| 137 |
+
const messageDiv = document.createElement('div');
|
| 138 |
+
messageDiv.className = `message-animation flex space-x-3 ${isUser ? 'justify-end' : ''}`;
|
| 139 |
+
|
| 140 |
+
const timestamp = new Date().toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
|
| 141 |
+
|
| 142 |
+
messageDiv.innerHTML = `
|
| 143 |
+
${!isUser ? `
|
| 144 |
+
<div class="flex-shrink-0">
|
| 145 |
+
<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">
|
| 146 |
+
<i class="fas fa-robot text-sm"></i>
|
| 147 |
+
</div>
|
| 148 |
+
</div>
|
| 149 |
+
` : ''}
|
| 150 |
+
<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">
|
| 151 |
+
<p>${text}</p>
|
| 152 |
+
<p class="text-xs ${isUser ? 'text-blue-100' : 'text-gray-500'} mt-1">${timestamp}</p>
|
| 153 |
+
</div>
|
| 154 |
+
${isUser ? `
|
| 155 |
+
<div class="flex-shrink-0">
|
| 156 |
+
<div class="w-8 h-8 rounded-full bg-gray-200 flex items-center justify-center text-gray-600">
|
| 157 |
+
<i class="fas fa-user text-sm"></i>
|
| 158 |
+
</div>
|
| 159 |
+
</div>
|
| 160 |
+
` : ''}
|
| 161 |
+
`;
|
| 162 |
+
|
| 163 |
+
messagesContainer.appendChild(messageDiv);
|
| 164 |
+
chatContainer.scrollTop = chatContainer.scrollHeight;
|
| 165 |
+
}
|
| 166 |
+
|
| 167 |
+
// Get random response
|
| 168 |
+
function getRandomResponse() {
|
| 169 |
+
return sampleResponses[Math.floor(Math.random() * sampleResponses.length)];
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
// Handle form submission
|
| 173 |
+
chatForm.addEventListener('submit', function(e) {
|
| 174 |
+
e.preventDefault();
|
| 175 |
+
const message = userInput.value.trim();
|
| 176 |
+
|
| 177 |
+
if (message) {
|
| 178 |
+
// Add user message
|
| 179 |
+
addMessage(message, true);
|
| 180 |
+
userInput.value = '';
|
| 181 |
+
|
| 182 |
+
// Show typing indicator
|
| 183 |
+
typingIndicator.classList.remove('hidden');
|
| 184 |
+
chatContainer.scrollTop = chatContainer.scrollHeight;
|
| 185 |
+
|
| 186 |
+
// Simulate AI thinking
|
| 187 |
+
setTimeout(() => {
|
| 188 |
+
typingIndicator.classList.add('hidden');
|
| 189 |
+
|
| 190 |
+
// Add AI response
|
| 191 |
+
setTimeout(() => {
|
| 192 |
+
addMessage(getRandomResponse(), false);
|
| 193 |
+
}, 200);
|
| 194 |
+
}, 1000 + Math.random() * 2000);
|
| 195 |
+
}
|
| 196 |
+
});
|
| 197 |
+
|
| 198 |
+
// Auto-focus input
|
| 199 |
+
userInput.focus();
|
| 200 |
+
});
|
| 201 |
+
</script>
|
| 202 |
+
<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>
|
| 203 |
+
</html>
|
prompts.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
Write an clai chatbot with next.js
|