Hdjsjsbvsbsb commited on
Commit
11fbc9a
·
verified ·
1 Parent(s): 2e74e9e

Make it talkable to the user - Initial Deployment

Browse files
Files changed (2) hide show
  1. README.md +6 -4
  2. index.html +326 -19
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: K Aigp1
3
- emoji: 🌖
4
  colorFrom: gray
5
- colorTo: pink
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: k-aigp1
3
+ emoji: 🐳
4
  colorFrom: gray
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,326 @@
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>AI Chatbot 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
+ /* Custom animations */
11
+ @keyframes fadeIn {
12
+ from { opacity: 0; transform: translateY(10px); }
13
+ to { opacity: 1; transform: translateY(0); }
14
+ }
15
+
16
+ .message {
17
+ animation: fadeIn 0.3s ease-out forwards;
18
+ }
19
+
20
+ /* Custom scrollbar */
21
+ .chat-container::-webkit-scrollbar {
22
+ width: 6px;
23
+ }
24
+
25
+ .chat-container::-webkit-scrollbar-track {
26
+ background: #f1f1f1;
27
+ border-radius: 10px;
28
+ }
29
+
30
+ .chat-container::-webkit-scrollbar-thumb {
31
+ background: #888;
32
+ border-radius: 10px;
33
+ }
34
+
35
+ .chat-container::-webkit-scrollbar-thumb:hover {
36
+ background: #555;
37
+ }
38
+
39
+ /* Typing indicator animation */
40
+ @keyframes typing {
41
+ 0% { opacity: 0.5; }
42
+ 50% { opacity: 1; }
43
+ 100% { opacity: 0.5; }
44
+ }
45
+
46
+ .typing-dot {
47
+ animation: typing 1.5s infinite ease-in-out;
48
+ }
49
+
50
+ .typing-dot:nth-child(2) {
51
+ animation-delay: 0.3s;
52
+ }
53
+
54
+ .typing-dot:nth-child(3) {
55
+ animation-delay: 0.6s;
56
+ }
57
+ </style>
58
+ </head>
59
+ <body class="bg-gray-100 h-screen flex flex-col">
60
+ <!-- Header -->
61
+ <header class="bg-indigo-600 text-white p-4 shadow-md">
62
+ <div class="container mx-auto flex items-center justify-between">
63
+ <div class="flex items-center space-x-3">
64
+ <div class="w-10 h-10 rounded-full bg-indigo-500 flex items-center justify-center">
65
+ <i class="fas fa-robot text-xl"></i>
66
+ </div>
67
+ <h1 class="text-xl font-bold">AI Assistant</h1>
68
+ </div>
69
+ <div class="flex items-center space-x-4">
70
+ <button id="speech-toggle" class="p-2 rounded-full hover:bg-indigo-500 transition" title="Toggle speech">
71
+ <i class="fas fa-volume-up"></i>
72
+ </button>
73
+ <button class="p-2 rounded-full hover:bg-indigo-500 transition">
74
+ <i class="fas fa-cog"></i>
75
+ </button>
76
+ <button class="p-2 rounded-full hover:bg-indigo-500 transition">
77
+ <i class="fas fa-moon"></i>
78
+ </button>
79
+ </div>
80
+ </div>
81
+ </header>
82
+
83
+ <!-- Chat container -->
84
+ <div class="flex-1 overflow-hidden container mx-auto p-4 flex flex-col max-w-4xl">
85
+ <div class="chat-container flex-1 overflow-y-auto mb-4 space-y-4 p-2">
86
+ <!-- Welcome message -->
87
+ <div class="message flex">
88
+ <div class="flex-shrink-0 w-10 h-10 rounded-full bg-indigo-100 flex items-center justify-center mr-3">
89
+ <i class="fas fa-robot text-indigo-600"></i>
90
+ </div>
91
+ <div class="bg-white p-4 rounded-lg shadow-sm max-w-[80%]">
92
+ <p class="text-gray-800">Hello! 👋 I'm your AI assistant. How can I help you today?</p>
93
+ <div class="mt-2 flex flex-wrap gap-2">
94
+ <button class="suggestion-btn bg-indigo-50 hover:bg-indigo-100 text-indigo-700 px-3 py-1 rounded-full text-sm transition">
95
+ What can you do?
96
+ </button>
97
+ <button class="suggestion-btn bg-indigo-50 hover:bg-indigo-100 text-indigo-700 px-3 py-1 rounded-full text-sm transition">
98
+ Tell me a joke
99
+ </button>
100
+ <button class="suggestion-btn bg-indigo-50 hover:bg-indigo-100 text-indigo-700 px-3 py-1 rounded-full text-sm transition">
101
+ Current time
102
+ </button>
103
+ </div>
104
+ </div>
105
+ </div>
106
+
107
+ <!-- Sample conversation (will be populated by JS) -->
108
+ <div id="chat-messages"></div>
109
+
110
+ <!-- Typing indicator (hidden by default) -->
111
+ <div id="typing-indicator" class="flex items-center hidden">
112
+ <div class="flex-shrink-0 w-10 h-10 rounded-full bg-indigo-100 flex items-center justify-center mr-3">
113
+ <i class="fas fa-robot text-indigo-600"></i>
114
+ </div>
115
+ <div class="bg-white p-3 rounded-lg shadow-sm">
116
+ <div class="flex space-x-1">
117
+ <div class="typing-dot w-2 h-2 rounded-full bg-gray-400"></div>
118
+ <div class="typing-dot w-2 h-2 rounded-full bg-gray-400"></div>
119
+ <div class="typing-dot w-2 h-2 rounded-full bg-gray-400"></div>
120
+ </div>
121
+ </div>
122
+ </div>
123
+ </div>
124
+
125
+ <!-- Input area -->
126
+ <div class="bg-white rounded-lg shadow-md p-3">
127
+ <form id="chat-form" class="flex items-center space-x-2">
128
+ <div class="flex-1 relative">
129
+ <input
130
+ id="user-input"
131
+ type="text"
132
+ placeholder="Type your message here..."
133
+ class="w-full p-3 pr-10 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent"
134
+ autocomplete="off"
135
+ >
136
+ <div class="absolute right-3 top-3 flex space-x-1">
137
+ <button type="button" class="text-gray-400 hover:text-indigo-600 transition">
138
+ <i class="fas fa-paperclip"></i>
139
+ </button>
140
+ <button type="button" class="text-gray-400 hover:text-indigo-600 transition">
141
+ <i class="fas fa-microphone"></i>
142
+ </button>
143
+ </div>
144
+ </div>
145
+ <button
146
+ type="submit"
147
+ class="bg-indigo-600 hover:bg-indigo-700 text-white p-3 rounded-lg transition duration-200 flex items-center justify-center"
148
+ >
149
+ <i class="fas fa-paper-plane"></i>
150
+ <span class="ml-2 hidden sm:inline">Send</span>
151
+ </button>
152
+ </form>
153
+ </div>
154
+ </div>
155
+
156
+ <script>
157
+ document.addEventListener('DOMContentLoaded', function() {
158
+ const chatForm = document.getElementById('chat-form');
159
+ const userInput = document.getElementById('user-input');
160
+ const chatMessages = document.getElementById('chat-messages');
161
+ const typingIndicator = document.getElementById('typing-indicator');
162
+ const suggestionButtons = document.querySelectorAll('.suggestion-btn');
163
+ const speechToggle = document.getElementById('speech-toggle');
164
+ let speechEnabled = true;
165
+ const synth = window.speechSynthesis;
166
+
167
+ // Enhanced responses
168
+ const responses = {
169
+ greetings: [
170
+ "Hello there! How can I assist you today?",
171
+ "Hi! 😊 What can I do for you?",
172
+ "Greetings! How may I help you?"
173
+ ],
174
+ capabilities: "I can answer questions, explain concepts, tell jokes, give the current time, help with calculations, and more! What would you like to know?",
175
+ jokes: [
176
+ "Why don't scientists trust atoms? Because they make up everything!",
177
+ "Why did the scarecrow win an award? Because he was outstanding in his field!",
178
+ "What do you call fake spaghetti? An impasta!"
179
+ ],
180
+ time: `The current time is ${new Date().toLocaleTimeString()}.`,
181
+ thanks: [
182
+ "You're welcome! Happy to help.",
183
+ "My pleasure! Is there anything else?",
184
+ "Glad I could assist you! 😊"
185
+ ],
186
+ default: "I'm not entirely sure about that. Could you try rephrasing or ask something else? I'm happy to help with general knowledge, jokes, time, and more!"
187
+ };
188
+
189
+ // Add user message to chat
190
+ function addUserMessage(message) {
191
+ const messageDiv = document.createElement('div');
192
+ messageDiv.className = 'message flex justify-end';
193
+ messageDiv.innerHTML = `
194
+ <div class="bg-indigo-600 text-white p-4 rounded-lg shadow-sm max-w-[80%]">
195
+ <p>${message}</p>
196
+ </div>
197
+ `;
198
+ chatMessages.appendChild(messageDiv);
199
+ scrollToBottom();
200
+ }
201
+
202
+ // Add bot message to chat
203
+ function addBotMessage(message) {
204
+ const messageDiv = document.createElement('div');
205
+ messageDiv.className = 'message flex';
206
+ messageDiv.innerHTML = `
207
+ <div class="flex-shrink-0 w-10 h-10 rounded-full bg-indigo-100 flex items-center justify-center mr-3">
208
+ <i class="fas fa-robot text-indigo-600"></i>
209
+ </div>
210
+ <div class="bg-white p-4 rounded-lg shadow-sm max-w-[80%]">
211
+ <p class="text-gray-800">${message}</p>
212
+ </div>
213
+ `;
214
+ chatMessages.appendChild(messageDiv);
215
+ scrollToBottom();
216
+ }
217
+
218
+ // Scroll to bottom of chat
219
+ function scrollToBottom() {
220
+ const container = document.querySelector('.chat-container');
221
+ container.scrollTop = container.scrollHeight;
222
+ }
223
+
224
+ // Process user input with enhanced matching
225
+ function processInput(input) {
226
+ const lowerInput = input.toLowerCase().trim();
227
+
228
+ // Show typing indicator
229
+ typingIndicator.classList.remove('hidden');
230
+ scrollToBottom();
231
+
232
+ // Simulate thinking time
233
+ setTimeout(() => {
234
+ typingIndicator.classList.add('hidden');
235
+
236
+ let response = responses.default;
237
+
238
+ // Greetings
239
+ if (/^(hello|hi|hey|greetings)\b/i.test(lowerInput)) {
240
+ response = responses.greetings[Math.floor(Math.random() * responses.greetings.length)];
241
+ }
242
+ // Capabilities
243
+ else if (/(what can you do|help|abilities)/i.test(lowerInput)) {
244
+ response = responses.capabilities;
245
+ }
246
+ // Jokes
247
+ else if (/(joke|funny|humor)/i.test(lowerInput)) {
248
+ response = responses.jokes[Math.floor(Math.random() * responses.jokes.length)];
249
+ }
250
+ // Time
251
+ else if (/(time|current time|what time is it)/i.test(lowerInput)) {
252
+ response = responses.time;
253
+ }
254
+ // Thanks
255
+ else if (/(thanks|thank you|appreciate)/i.test(lowerInput)) {
256
+ response = responses.thanks[Math.floor(Math.random() * responses.thanks.length)];
257
+ }
258
+ // Simple math
259
+ else if (/(calculate|what is|add|subtract|multiply|divide)/i.test(lowerInput)) {
260
+ try {
261
+ const mathExpr = lowerInput.replace(/[^\d+\-*/().]/g, '');
262
+ if (mathExpr) {
263
+ response = `The answer is: ${eval(mathExpr)}`;
264
+ }
265
+ } catch {
266
+ response = "I couldn't calculate that. Please try a simpler math expression.";
267
+ }
268
+ }
269
+
270
+ addBotMessage(response);
271
+
272
+ // Speak the response if speech is enabled
273
+ if (speechEnabled && synth) {
274
+ const utterance = new SpeechSynthesisUtterance(response);
275
+ utterance.rate = 0.9;
276
+ utterance.pitch = 1;
277
+ synth.speak(utterance);
278
+ }
279
+ }, 1000 + Math.random() * 2000); // Random delay between 1-3 seconds
280
+ }
281
+
282
+ // Handle form submission
283
+ chatForm.addEventListener('submit', function(e) {
284
+ e.preventDefault();
285
+ const message = userInput.value.trim();
286
+
287
+ if (message) {
288
+ addUserMessage(message);
289
+ userInput.value = '';
290
+ processInput(message);
291
+ }
292
+ });
293
+
294
+ // Toggle speech functionality
295
+ speechToggle.addEventListener('click', function() {
296
+ speechEnabled = !speechEnabled;
297
+ if (speechEnabled) {
298
+ this.innerHTML = '<i class="fas fa-volume-up"></i>';
299
+ this.title = "Speech enabled (click to disable)";
300
+ } else {
301
+ this.innerHTML = '<i class="fas fa-volume-mute"></i>';
302
+ this.title = "Speech disabled (click to enable)";
303
+ synth.cancel(); // Stop any ongoing speech
304
+ }
305
+ });
306
+
307
+ // Handle suggestion buttons
308
+ suggestionButtons.forEach(button => {
309
+ button.addEventListener('click', function() {
310
+ const suggestion = this.textContent.trim();
311
+ addUserMessage(suggestion);
312
+ processInput(suggestion);
313
+ });
314
+ });
315
+
316
+ // Allow pressing Enter to send message (but Shift+Enter for new line)
317
+ userInput.addEventListener('keydown', function(e) {
318
+ if (e.key === 'Enter' && !e.shiftKey) {
319
+ e.preventDefault();
320
+ chatForm.dispatchEvent(new Event('submit'));
321
+ }
322
+ });
323
+ });
324
+ </script>
325
+ <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=Hdjsjsbvsbsb/k-aigp1" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
326
+ </html>