minhpqn commited on
Commit
dde583e
·
verified ·
1 Parent(s): eb11395

Add 2 files

Browse files
Files changed (2) hide show
  1. README.md +7 -5
  2. index.html +252 -19
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Ai Assistant
3
- emoji: 👁
4
- colorFrom: blue
5
- colorTo: purple
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: ai-assistant
3
+ emoji: 🐳
4
+ colorFrom: pink
5
+ colorTo: yellow
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,252 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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>Modern Chatbot UI</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
+ /* Custom scrollbar */
11
+ .chat-messages::-webkit-scrollbar {
12
+ width: 6px;
13
+ }
14
+ .chat-messages::-webkit-scrollbar-track {
15
+ background: #f1f1f1;
16
+ border-radius: 10px;
17
+ }
18
+ .chat-messages::-webkit-scrollbar-thumb {
19
+ background: #888;
20
+ border-radius: 10px;
21
+ }
22
+ .chat-messages::-webkit-scrollbar-thumb:hover {
23
+ background: #555;
24
+ }
25
+
26
+ /* Animation for new messages */
27
+ @keyframes fadeIn {
28
+ from { opacity: 0; transform: translateY(10px); }
29
+ to { opacity: 1; transform: translateY(0); }
30
+ }
31
+ .message-animate {
32
+ animation: fadeIn 0.3s ease-out;
33
+ }
34
+
35
+ /* Typing indicator animation */
36
+ @keyframes typing {
37
+ 0% { opacity: 0.5; }
38
+ 50% { opacity: 1; }
39
+ 100% { opacity: 0.5; }
40
+ }
41
+ .typing-dot {
42
+ animation: typing 1.5s infinite;
43
+ }
44
+ .typing-dot:nth-child(2) {
45
+ animation-delay: 0.3s;
46
+ }
47
+ .typing-dot:nth-child(3) {
48
+ animation-delay: 0.6s;
49
+ }
50
+ </style>
51
+ </head>
52
+ <body class="bg-gray-100 h-screen flex items-center justify-center p-4">
53
+ <div class="w-full max-w-2xl h-[80vh] flex flex-col bg-white rounded-2xl shadow-xl overflow-hidden">
54
+ <!-- Chat header -->
55
+ <div class="bg-indigo-600 text-white p-4 flex items-center">
56
+ <div class="w-10 h-10 rounded-full bg-indigo-500 flex items-center justify-center mr-3">
57
+ <i class="fas fa-robot text-xl"></i>
58
+ </div>
59
+ <div>
60
+ <h1 class="font-bold text-lg">AI Assistant</h1>
61
+ <p class="text-xs opacity-80">Online</p>
62
+ </div>
63
+ <div class="ml-auto flex space-x-2">
64
+ <button class="w-8 h-8 rounded-full bg-indigo-500 hover:bg-indigo-400 flex items-center justify-center">
65
+ <i class="fas fa-ellipsis-v text-sm"></i>
66
+ </button>
67
+ </div>
68
+ </div>
69
+
70
+ <!-- Chat messages area -->
71
+ <div class="flex-1 p-4 overflow-y-auto chat-messages" id="chat-messages">
72
+ <!-- Welcome message -->
73
+ <div class="flex mb-4">
74
+ <div class="w-8 h-8 rounded-full bg-gray-200 flex items-center justify-center mr-2">
75
+ <i class="fas fa-robot text-indigo-600"></i>
76
+ </div>
77
+ <div class="max-w-[80%]">
78
+ <div class="bg-gray-100 rounded-lg p-3 text-sm">
79
+ <p>Hello! I'm your AI assistant. How can I help you today?</p>
80
+ </div>
81
+ <p class="text-xs text-gray-500 mt-1">Just now</p>
82
+ </div>
83
+ </div>
84
+
85
+ <!-- Example user message -->
86
+ <div class="flex mb-4 justify-end">
87
+ <div class="max-w-[80%]">
88
+ <div class="bg-indigo-600 text-white rounded-lg p-3 text-sm">
89
+ <p>What can you do?</p>
90
+ </div>
91
+ <p class="text-xs text-gray-500 mt-1 text-right">Just now</p>
92
+ </div>
93
+ <div class="w-8 h-8 rounded-full bg-indigo-100 flex items-center justify-center ml-2">
94
+ <i class="fas fa-user text-indigo-600"></i>
95
+ </div>
96
+ </div>
97
+
98
+ <!-- Example bot response -->
99
+ <div class="flex mb-4">
100
+ <div class="w-8 h-8 rounded-full bg-gray-200 flex items-center justify-center mr-2">
101
+ <i class="fas fa-robot text-indigo-600"></i>
102
+ </div>
103
+ <div class="max-w-[80%]">
104
+ <div class="bg-gray-100 rounded-lg p-3 text-sm">
105
+ <p>I can answer questions, provide information, help with tasks, and more! Try asking me anything.</p>
106
+ </div>
107
+ <p class="text-xs text-gray-500 mt-1">Just now</p>
108
+ </div>
109
+ </div>
110
+ </div>
111
+
112
+ <!-- Typing indicator (hidden by default) -->
113
+ <div id="typing-indicator" class="hidden px-4 pb-2">
114
+ <div class="flex">
115
+ <div class="w-8 h-8 rounded-full bg-gray-200 flex items-center justify-center mr-2">
116
+ <i class="fas fa-robot text-indigo-600"></i>
117
+ </div>
118
+ <div class="bg-gray-100 rounded-lg p-3 flex space-x-1">
119
+ <div class="typing-dot w-2 h-2 rounded-full bg-gray-400"></div>
120
+ <div class="typing-dot w-2 h-2 rounded-full bg-gray-400"></div>
121
+ <div class="typing-dot w-2 h-2 rounded-full bg-gray-400"></div>
122
+ </div>
123
+ </div>
124
+ </div>
125
+
126
+ <!-- Message input area -->
127
+ <div class="p-4 border-t border-gray-200">
128
+ <form id="message-form" class="flex items-center">
129
+ <div class="flex-1 relative">
130
+ <input
131
+ type="text"
132
+ id="message-input"
133
+ placeholder="Type your message..."
134
+ class="w-full p-3 pr-10 rounded-full border border-gray-300 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent"
135
+ autocomplete="off"
136
+ >
137
+ <button type="button" class="absolute right-3 top-1/2 transform -translate-y-1/2 text-gray-400 hover:text-indigo-600">
138
+ <i class="far fa-smile"></i>
139
+ </button>
140
+ </div>
141
+ <button
142
+ type="submit"
143
+ class="ml-2 w-10 h-10 rounded-full bg-indigo-600 text-white flex items-center justify-center hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500"
144
+ >
145
+ <i class="fas fa-paper-plane"></i>
146
+ </button>
147
+ </form>
148
+ <p class="text-xs text-gray-500 mt-2 text-center">AI Assistant may produce inaccurate information</p>
149
+ </div>
150
+ </div>
151
+
152
+ <script>
153
+ document.addEventListener('DOMContentLoaded', function() {
154
+ const messageForm = document.getElementById('message-form');
155
+ const messageInput = document.getElementById('message-input');
156
+ const chatMessages = document.getElementById('chat-messages');
157
+ const typingIndicator = document.getElementById('typing-indicator');
158
+
159
+ // Function to add a new message to the chat
160
+ function addMessage(content, isUser) {
161
+ const messageDiv = document.createElement('div');
162
+ messageDiv.className = `flex mb-4 ${isUser ? 'justify-end' : ''} message-animate`;
163
+
164
+ const avatarDiv = document.createElement('div');
165
+ avatarDiv.className = `w-8 h-8 rounded-full flex items-center justify-center ${isUser ? 'ml-2 bg-indigo-100' : 'mr-2 bg-gray-200'}`;
166
+
167
+ const avatarIcon = document.createElement('i');
168
+ avatarIcon.className = `fas ${isUser ? 'fa-user text-indigo-600' : 'fa-robot text-indigo-600'}`;
169
+ avatarDiv.appendChild(avatarIcon);
170
+
171
+ const messageContentDiv = document.createElement('div');
172
+ messageContentDiv.className = `max-w-[80%]`;
173
+
174
+ const messageBubble = document.createElement('div');
175
+ messageBubble.className = `${isUser ? 'bg-indigo-600 text-white' : 'bg-gray-100'} rounded-lg p-3 text-sm`;
176
+ messageBubble.innerHTML = `<p>${content}</p>`;
177
+
178
+ const timeStamp = document.createElement('p');
179
+ timeStamp.className = `text-xs text-gray-500 mt-1 ${isUser ? 'text-right' : ''}`;
180
+
181
+ // Format current time
182
+ const now = new Date();
183
+ const hours = now.getHours().toString().padStart(2, '0');
184
+ const minutes = now.getMinutes().toString().padStart(2, '0');
185
+ timeStamp.textContent = `${hours}:${minutes}`;
186
+
187
+ messageContentDiv.appendChild(messageBubble);
188
+ messageContentDiv.appendChild(timeStamp);
189
+
190
+ if (isUser) {
191
+ messageDiv.appendChild(messageContentDiv);
192
+ messageDiv.appendChild(avatarDiv);
193
+ } else {
194
+ messageDiv.appendChild(avatarDiv);
195
+ messageDiv.appendChild(messageContentDiv);
196
+ }
197
+
198
+ chatMessages.appendChild(messageDiv);
199
+ chatMessages.scrollTop = chatMessages.scrollHeight;
200
+ }
201
+
202
+ // Function to simulate bot response
203
+ function respondToUser(message) {
204
+ // Show typing indicator
205
+ typingIndicator.classList.remove('hidden');
206
+ chatMessages.scrollTop = chatMessages.scrollHeight;
207
+
208
+ // Simple response logic
209
+ let response;
210
+ if (message.toLowerCase().includes('hello') || message.toLowerCase().includes('hi')) {
211
+ response = "Hello there! How can I assist you today?";
212
+ } else if (message.toLowerCase().includes('help')) {
213
+ response = "I can help with answering questions, providing information, and more. What specifically do you need help with?";
214
+ } else if (message.toLowerCase().includes('thank')) {
215
+ response = "You're welcome! Is there anything else I can help you with?";
216
+ } else {
217
+ response = "I understand you're asking about: " + message + ". Could you provide more details so I can better assist you?";
218
+ }
219
+
220
+ // Simulate typing delay
221
+ setTimeout(() => {
222
+ typingIndicator.classList.add('hidden');
223
+ addMessage(response, false);
224
+ }, 1000 + Math.random() * 2000);
225
+ }
226
+
227
+ // Handle form submission
228
+ messageForm.addEventListener('submit', function(e) {
229
+ e.preventDefault();
230
+ const message = messageInput.value.trim();
231
+
232
+ if (message) {
233
+ // Add user message
234
+ addMessage(message, true);
235
+ messageInput.value = '';
236
+
237
+ // Generate bot response
238
+ respondToUser(message);
239
+ }
240
+ });
241
+
242
+ // Optional: Allow sending message with Enter key
243
+ messageInput.addEventListener('keydown', function(e) {
244
+ if (e.key === 'Enter' && !e.shiftKey) {
245
+ e.preventDefault();
246
+ messageForm.dispatchEvent(new Event('submit'));
247
+ }
248
+ });
249
+ });
250
+ </script>
251
+ <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=minhpqn/ai-assistant" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
252
+ </html>