Spaces:
Running
Running
remove exsitisn page and create on simple ai chat assistant page - Initial Deployment
Browse files- README.md +7 -5
- index.html +235 -19
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: test-ai-assistant
|
| 3 |
+
emoji: 🐳
|
| 4 |
+
colorFrom: pink
|
| 5 |
+
colorTo: gray
|
| 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,235 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Simple AI Assistant</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.4s infinite ease-in-out;
|
| 22 |
+
}
|
| 23 |
+
.typing-indicator span:nth-child(2) {
|
| 24 |
+
animation-delay: 0.2s;
|
| 25 |
+
}
|
| 26 |
+
.typing-indicator span:nth-child(3) {
|
| 27 |
+
animation-delay: 0.4s;
|
| 28 |
+
}
|
| 29 |
+
@keyframes bounce {
|
| 30 |
+
0%, 100% { transform: translateY(0); }
|
| 31 |
+
50% { transform: translateY(-5px); }
|
| 32 |
+
}
|
| 33 |
+
</style>
|
| 34 |
+
</head>
|
| 35 |
+
<body class="bg-gray-100">
|
| 36 |
+
<div class="max-w-4xl mx-auto p-4">
|
| 37 |
+
<!-- Header -->
|
| 38 |
+
<header class="bg-indigo-600 text-white rounded-lg shadow-md p-4 mb-4">
|
| 39 |
+
<div class="flex items-center">
|
| 40 |
+
<div class="w-12 h-12 rounded-full bg-indigo-500 flex items-center justify-center mr-3">
|
| 41 |
+
<i class="fas fa-robot text-2xl"></i>
|
| 42 |
+
</div>
|
| 43 |
+
<div>
|
| 44 |
+
<h1 class="text-2xl font-bold">AI Assistant</h1>
|
| 45 |
+
<p class="text-indigo-100">How can I help you today?</p>
|
| 46 |
+
</div>
|
| 47 |
+
</div>
|
| 48 |
+
</header>
|
| 49 |
+
|
| 50 |
+
<!-- Chat Container -->
|
| 51 |
+
<div class="bg-white rounded-lg shadow-md overflow-hidden chat-container flex flex-col">
|
| 52 |
+
<!-- Messages -->
|
| 53 |
+
<div class="flex-1 p-4 overflow-y-auto" id="chat-messages">
|
| 54 |
+
<!-- Initial greeting -->
|
| 55 |
+
<div class="mb-4 message-animation">
|
| 56 |
+
<div class="flex items-start">
|
| 57 |
+
<div class="w-8 h-8 rounded-full bg-indigo-100 flex items-center justify-center mr-2">
|
| 58 |
+
<i class="fas fa-robot text-indigo-600"></i>
|
| 59 |
+
</div>
|
| 60 |
+
<div class="bg-indigo-50 rounded-lg p-3 max-w-xs md:max-w-md lg:max-w-lg">
|
| 61 |
+
<p class="text-gray-800">Hello! I'm your AI assistant. Ask me anything and I'll do my best to help you.</p>
|
| 62 |
+
</div>
|
| 63 |
+
</div>
|
| 64 |
+
<p class="text-xs text-gray-500 ml-10 mt-1">Just now</p>
|
| 65 |
+
</div>
|
| 66 |
+
</div>
|
| 67 |
+
|
| 68 |
+
<!-- Input Area -->
|
| 69 |
+
<div class="border-t border-gray-200 p-4 bg-gray-50">
|
| 70 |
+
<div class="flex items-center">
|
| 71 |
+
<input
|
| 72 |
+
type="text"
|
| 73 |
+
id="user-input"
|
| 74 |
+
placeholder="Type your message here..."
|
| 75 |
+
class="flex-1 border border-gray-300 rounded-l-lg px-4 py-2 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent"
|
| 76 |
+
autocomplete="off"
|
| 77 |
+
>
|
| 78 |
+
<button
|
| 79 |
+
id="send-btn"
|
| 80 |
+
class="bg-indigo-600 text-white px-4 py-2 rounded-r-lg hover:bg-indigo-700 transition duration-200 flex items-center justify-center"
|
| 81 |
+
>
|
| 82 |
+
<i class="fas fa-paper-plane mr-2"></i> Send
|
| 83 |
+
</button>
|
| 84 |
+
</div>
|
| 85 |
+
<div class="flex justify-between mt-2 text-xs text-gray-500">
|
| 86 |
+
<div>
|
| 87 |
+
<button class="mr-2 hover:text-indigo-600"><i class="fas fa-microphone"></i> Voice</button>
|
| 88 |
+
<button class="hover:text-indigo-600"><i class="fas fa-image"></i> Image</button>
|
| 89 |
+
</div>
|
| 90 |
+
<div>
|
| 91 |
+
<button class="hover:text-indigo-600"><i class="fas fa-ellipsis-h"></i> More</button>
|
| 92 |
+
</div>
|
| 93 |
+
</div>
|
| 94 |
+
</div>
|
| 95 |
+
</div>
|
| 96 |
+
</div>
|
| 97 |
+
|
| 98 |
+
<script>
|
| 99 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 100 |
+
const chatMessages = document.getElementById('chat-messages');
|
| 101 |
+
const userInput = document.getElementById('user-input');
|
| 102 |
+
const sendBtn = document.getElementById('send-btn');
|
| 103 |
+
|
| 104 |
+
// Sample AI responses
|
| 105 |
+
const aiResponses = [
|
| 106 |
+
"I understand what you're asking. Here's what I can tell you about that...",
|
| 107 |
+
"That's an interesting question! Based on my knowledge, I'd say...",
|
| 108 |
+
"I'm not entirely sure about that, but I can look it up for you.",
|
| 109 |
+
"Let me think about that for a moment...",
|
| 110 |
+
"I'd be happy to help with that! Here's what I know...",
|
| 111 |
+
"That's a great point. From my perspective...",
|
| 112 |
+
"I'm designed to assist with questions like this. Here's my response..."
|
| 113 |
+
];
|
| 114 |
+
|
| 115 |
+
// Add a new message to the chat
|
| 116 |
+
function addMessage(content, isUser = false) {
|
| 117 |
+
const messageDiv = document.createElement('div');
|
| 118 |
+
messageDiv.className = `mb-4 message-animation`;
|
| 119 |
+
|
| 120 |
+
const messageContent = `
|
| 121 |
+
<div class="flex items-start ${isUser ? 'justify-end' : ''}">
|
| 122 |
+
${!isUser ? `
|
| 123 |
+
<div class="w-8 h-8 rounded-full bg-indigo-100 flex items-center justify-center mr-2">
|
| 124 |
+
<i class="fas fa-robot text-indigo-600"></i>
|
| 125 |
+
</div>
|
| 126 |
+
` : ''}
|
| 127 |
+
<div class="${isUser ? 'bg-indigo-600 text-white' : 'bg-indigo-50'} rounded-lg p-3 max-w-xs md:max-w-md lg:max-w-lg">
|
| 128 |
+
<p>${content}</p>
|
| 129 |
+
</div>
|
| 130 |
+
${isUser ? `
|
| 131 |
+
<div class="w-8 h-8 rounded-full bg-indigo-100 flex items-center justify-center ml-2">
|
| 132 |
+
<i class="fas fa-user text-indigo-600"></i>
|
| 133 |
+
</div>
|
| 134 |
+
` : ''}
|
| 135 |
+
</div>
|
| 136 |
+
<p class="text-xs text-gray-500 ${isUser ? 'text-right' : 'ml-10'} mt-1">${new Date().toLocaleTimeString([], {hour: '2-digit', minute:'2-digit'})}</p>
|
| 137 |
+
`;
|
| 138 |
+
|
| 139 |
+
messageDiv.innerHTML = messageContent;
|
| 140 |
+
chatMessages.appendChild(messageDiv);
|
| 141 |
+
chatMessages.scrollTop = chatMessages.scrollHeight;
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
// Show typing indicator
|
| 145 |
+
function showTypingIndicator() {
|
| 146 |
+
const typingDiv = document.createElement('div');
|
| 147 |
+
typingDiv.className = 'mb-4 message-animation';
|
| 148 |
+
typingDiv.id = 'typing-indicator';
|
| 149 |
+
|
| 150 |
+
typingDiv.innerHTML = `
|
| 151 |
+
<div class="flex items-start">
|
| 152 |
+
<div class="w-8 h-8 rounded-full bg-indigo-100 flex items-center justify-center mr-2">
|
| 153 |
+
<i class="fas fa-robot text-indigo-600"></i>
|
| 154 |
+
</div>
|
| 155 |
+
<div class="bg-indigo-50 rounded-lg p-3 max-w-xs md:max-w-md lg:max-w-lg">
|
| 156 |
+
<div class="typing-indicator flex space-x-1">
|
| 157 |
+
<span class="w-2 h-2 bg-indigo-400 rounded-full"></span>
|
| 158 |
+
<span class="w-2 h-2 bg-indigo-400 rounded-full"></span>
|
| 159 |
+
<span class="w-2 h-2 bg-indigo-400 rounded-full"></span>
|
| 160 |
+
</div>
|
| 161 |
+
</div>
|
| 162 |
+
</div>
|
| 163 |
+
`;
|
| 164 |
+
|
| 165 |
+
chatMessages.appendChild(typingDiv);
|
| 166 |
+
chatMessages.scrollTop = chatMessages.scrollHeight;
|
| 167 |
+
return typingDiv;
|
| 168 |
+
}
|
| 169 |
+
|
| 170 |
+
// Remove typing indicator
|
| 171 |
+
function removeTypingIndicator() {
|
| 172 |
+
const typingIndicator = document.getElementById('typing-indicator');
|
| 173 |
+
if (typingIndicator) {
|
| 174 |
+
typingIndicator.remove();
|
| 175 |
+
}
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
// Handle send button click
|
| 179 |
+
sendBtn.addEventListener('click', sendMessage);
|
| 180 |
+
|
| 181 |
+
// Handle Enter key press
|
| 182 |
+
userInput.addEventListener('keypress', function(e) {
|
| 183 |
+
if (e.key === 'Enter') {
|
| 184 |
+
sendMessage();
|
| 185 |
+
}
|
| 186 |
+
});
|
| 187 |
+
|
| 188 |
+
// Send message function
|
| 189 |
+
function sendMessage() {
|
| 190 |
+
const message = userInput.value.trim();
|
| 191 |
+
if (message === '') return;
|
| 192 |
+
|
| 193 |
+
// Add user message
|
| 194 |
+
addMessage(message, true);
|
| 195 |
+
userInput.value = '';
|
| 196 |
+
|
| 197 |
+
// Show typing indicator
|
| 198 |
+
const typingIndicator = showTypingIndicator();
|
| 199 |
+
|
| 200 |
+
// Simulate AI thinking (1-2 seconds delay)
|
| 201 |
+
setTimeout(() => {
|
| 202 |
+
removeTypingIndicator();
|
| 203 |
+
|
| 204 |
+
// Get random AI response
|
| 205 |
+
const randomResponse = aiResponses[Math.floor(Math.random() * aiResponses.length)];
|
| 206 |
+
addMessage(randomResponse);
|
| 207 |
+
}, 1000 + Math.random() * 1000);
|
| 208 |
+
}
|
| 209 |
+
|
| 210 |
+
// Sample questions for quick testing
|
| 211 |
+
const sampleQuestions = [
|
| 212 |
+
"What's the weather today?",
|
| 213 |
+
"Tell me a joke",
|
| 214 |
+
"How do I reset my password?",
|
| 215 |
+
"What's the capital of France?",
|
| 216 |
+
"Explain quantum computing"
|
| 217 |
+
];
|
| 218 |
+
|
| 219 |
+
// Add sample questions to input placeholder on focus
|
| 220 |
+
let currentPlaceholderIndex = 0;
|
| 221 |
+
userInput.addEventListener('focus', function() {
|
| 222 |
+
const placeholderInterval = setInterval(() => {
|
| 223 |
+
currentPlaceholderIndex = (currentPlaceholderIndex + 1) % sampleQuestions.length;
|
| 224 |
+
userInput.placeholder = sampleQuestions[currentPlaceholderIndex];
|
| 225 |
+
}, 3000);
|
| 226 |
+
|
| 227 |
+
userInput.addEventListener('blur', function() {
|
| 228 |
+
clearInterval(placeholderInterval);
|
| 229 |
+
userInput.placeholder = "Type your message here...";
|
| 230 |
+
}, {once: true});
|
| 231 |
+
});
|
| 232 |
+
});
|
| 233 |
+
</script>
|
| 234 |
+
<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=vinnothj/test-ai-assistant" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
| 235 |
+
</html>
|