alterzick commited on
Commit
fbb0415
·
verified ·
1 Parent(s): 5c6c3b8

undefined - Initial Deployment

Browse files
Files changed (2) hide show
  1. README.md +7 -5
  2. index.html +492 -18
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Chatbot V1
3
- emoji: 👁
4
- colorFrom: indigo
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: chatbot-v1
3
+ emoji: 🐳
4
+ colorFrom: red
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,493 @@
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
+
2
+ <!DOCTYPE html>
3
+ <html lang="en">
4
+ <head>
5
+ <meta charset="UTF-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <title>AI Chatbot</title>
8
+ <style>
9
+ :root {
10
+ --primary-color: #4361ee;
11
+ --secondary-color: #3f37c9;
12
+ --user-message: #4361ee;
13
+ --bot-message: #f8f9fa;
14
+ --text-dark: #212529;
15
+ --text-light: #f8f9fa;
16
+ }
17
+
18
+ body {
19
+ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
20
+ margin: 0;
21
+ padding: 0;
22
+ height: 100vh;
23
+ display: flex;
24
+ flex-direction: column;
25
+ background-color: #f1f3f5;
26
+ }
27
+
28
+ .chat-container {
29
+ display: flex;
30
+ flex-direction: column;
31
+ max-width: 800px;
32
+ margin: 0 auto;
33
+ height: 100vh;
34
+ box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
35
+ background-color: white;
36
+ }
37
+
38
+ .chat-header {
39
+ background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
40
+ color: white;
41
+ padding: 15px 20px;
42
+ display: flex;
43
+ justify-content: space-between;
44
+ align-items: center;
45
+ border-radius: 0 0 10px 10px;
46
+ }
47
+
48
+ .chat-header h1 {
49
+ margin: 0;
50
+ font-size: 1.5rem;
51
+ }
52
+
53
+ .status {
54
+ display: flex;
55
+ align-items: center;
56
+ gap: 8px;
57
+ }
58
+
59
+ .status-indicator {
60
+ width: 10px;
61
+ height: 10px;
62
+ border-radius: 50%;
63
+ background-color: #4ade80;
64
+ }
65
+
66
+ .status-text {
67
+ font-size: 0.9rem;
68
+ }
69
+
70
+ .chat-messages {
71
+ flex: 1;
72
+ padding: 20px;
73
+ overflow-y: auto;
74
+ display: flex;
75
+ flex-direction: column;
76
+ gap: 15px;
77
+ }
78
+
79
+ .message {
80
+ max-width: 70%;
81
+ padding: 12px 15px;
82
+ border-radius: 18px;
83
+ font-size: 0.95rem;
84
+ line-height: 1.4;
85
+ animation: fadeIn 0.3s ease-out;
86
+ position: relative;
87
+ }
88
+
89
+ .user-message {
90
+ align-self: flex-end;
91
+ background-color: var(--user-message);
92
+ color: var(--text-light);
93
+ border-bottom-right-radius: 5px;
94
+ }
95
+
96
+ .bot-message {
97
+ align-self: flex-start;
98
+ background-color: var(--bot-message);
99
+ color: var(--text-dark);
100
+ border: 1px solid #dee2e6;
101
+ border-bottom-left-radius: 5px;
102
+ }
103
+
104
+ .timestamp {
105
+ font-size: 0.7rem;
106
+ opacity: 0.7;
107
+ margin-top: 5px;
108
+ text-align: right;
109
+ }
110
+
111
+ .typing-indicator {
112
+ display: inline-flex;
113
+ gap: 5px;
114
+ padding: 12px 15px;
115
+ background-color: var(--bot-message);
116
+ border-radius: 18px;
117
+ align-self: flex-start;
118
+ border: 1px solid #dee2e6;
119
+ }
120
+
121
+ .typing-dot {
122
+ width: 8px;
123
+ height: 8px;
124
+ background-color: #6c757d;
125
+ border-radius: 50%;
126
+ animation: typingAnimation 1.4s infinite ease-in-out;
127
+ }
128
+
129
+ .typing-dot:nth-child(1) { animation-delay: 0s; }
130
+ .typing-dot:nth-child(2) { animation-delay: 0.2s; }
131
+ .typing-dot:nth-child(3) { animation-delay: 0.4s; }
132
+
133
+ .input-area {
134
+ display: flex;
135
+ padding: 15px;
136
+ border-top: 1px solid #dee2e6;
137
+ background-color: white;
138
+ }
139
+
140
+ .message-input {
141
+ flex: 1;
142
+ padding: 12px 15px;
143
+ border: 1px solid #dee2e6;
144
+ border-radius: 24px;
145
+ font-size: 0.95rem;
146
+ outline: none;
147
+ transition: border-color 0.3s;
148
+ }
149
+
150
+ .message-input:focus {
151
+ border-color: var(--primary-color);
152
+ }
153
+
154
+ .send-button {
155
+ background-color: var(--primary-color);
156
+ color: white;
157
+ border: none;
158
+ border-radius: 50%;
159
+ width: 48px;
160
+ height: 48px;
161
+ margin-left: 10px;
162
+ cursor: pointer;
163
+ display: flex;
164
+ align-items: center;
165
+ justify-content: center;
166
+ transition: background-color 0.3s;
167
+ }
168
+
169
+ .send-button:hover {
170
+ background-color: var(--secondary-color);
171
+ }
172
+
173
+ .send-icon {
174
+ width: 20px;
175
+ height: 20px;
176
+ }
177
+
178
+ @keyframes fadeIn {
179
+ from { opacity: 0; transform: translateY(10px); }
180
+ to { opacity: 1; transform: translateY(0); }
181
+ }
182
+
183
+ @keyframes typingAnimation {
184
+ 0%, 60%, 100% { transform: translateY(0); }
185
+ 30% { transform: translateY(-5px); }
186
+ }
187
+
188
+ .agent-select {
189
+ padding: 5px 10px;
190
+ border-radius: 15px;
191
+ border: 1px solid rgba(255,255,255,0.3);
192
+ background-color: rgba(255,255,255,0.1);
193
+ color: white;
194
+ margin-left: 10px;
195
+ font-size: 0.9rem;
196
+ }
197
+
198
+ .history-button {
199
+ background: none;
200
+ border: none;
201
+ color: var(--primary-color);
202
+ padding: 10px;
203
+ cursor: pointer;
204
+ border-radius: 50%;
205
+ transition: background-color 0.2s;
206
+ }
207
+
208
+ .history-button:hover {
209
+ background-color: rgba(0,0,0,0.05);
210
+ }
211
+
212
+ /* History modal styles */
213
+ .history-modal {
214
+ position: fixed;
215
+ top: 0;
216
+ left: 0;
217
+ right: 0;
218
+ bottom: 0;
219
+ background: rgba(0,0,0,0.5);
220
+ display: none;
221
+ z-index: 100;
222
+ padding: 20px;
223
+ }
224
+
225
+ .history-content {
226
+ background: white;
227
+ max-width: 600px;
228
+ margin: 20px auto;
229
+ padding: 20px;
230
+ border-radius: 10px;
231
+ max-height: 80vh;
232
+ overflow-y: auto;
233
+ }
234
+
235
+ @media (max-width: 768px) {
236
+ .chat-container {
237
+ max-width: 100%;
238
+ border-radius: 0;
239
+ }
240
+
241
+ .message {
242
+ max-width: 85%;
243
+ }
244
+ }
245
+ </style>
246
+ </head>
247
+ <body>
248
+ <div class="chat-container">
249
+ <div class="chat-header">
250
+ <h1 id="agent-title">AI Assistant</h1>
251
+ <select id="agent-selector" class="agent-select">
252
+ <option value="general">General Assistant</option>
253
+ <option value="tech">Tech Support</option>
254
+ <option value="sales">Sales Agent</option>
255
+ </select>
256
+ <div class="status">
257
+ <div class="status-indicator"></div>
258
+ <span class="status-text">Online</span>
259
+ </div>
260
+ </div>
261
+
262
+ <div class="chat-messages" id="chat-messages">
263
+ <!-- Messages will be added here dynamically -->
264
+ <div class="message bot-message">
265
+ Hello! I'm your General Assistant. How can I help you today?
266
+ <div class="timestamp">Just now</div>
267
+ </div>
268
+ </div>
269
+
270
+ <div class="input-area">
271
+ <button id="history-button" class="history-button" title="View chat history" style="margin-right: 10px;">
272
+ <svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor">
273
+ <path d="M3 3v18h18M7 16l4-4-4-4m6 8l4-4-4-4"/>
274
+ </svg>
275
+ </button>
276
+ <input type="text" class="message-input" id="user-input" placeholder="Type your message..." autocomplete="off">
277
+ <button class="send-button" id="send-button">
278
+ <svg class="send-icon" viewBox="0 0 24 24">
279
+ <path fill="currentColor" d="M2,21L23,12L2,3V10L17,12L2,14V21Z" />
280
+ </svg>
281
+ </button>
282
+ </div>
283
+ </div>
284
+
285
+ <!-- History Modal -->
286
+ <div class="history-modal" id="history-modal">
287
+ <div class="history-content">
288
+ <h2>Chat History</h2>
289
+ <div id="history-list"></div>
290
+ <button id="close-history" class="history-close">Close</button>
291
+ </div>
292
+ </div>
293
+
294
+ <script>
295
+ const chatMessages = document.getElementById('chat-messages');
296
+ const userInput = document.getElementById('user-input');
297
+ const sendButton = document.getElementById('send-button');
298
+
299
+ // Chat state and configuration
300
+ let chatState = {
301
+ agent: 'general',
302
+ history: []
303
+ };
304
+
305
+ // Agent configurations
306
+ const agents = {
307
+ general: {
308
+ name: "General Assistant",
309
+ responses: [
310
+ "I can help with general questions. How may I assist you today?",
311
+ "I'm your general assistant. What do you need help with?"
312
+ ]
313
+ },
314
+ tech: {
315
+ name: "Tech Support",
316
+ responses: [
317
+ "I specialize in technology support. What technical issue can I help with?",
318
+ "For technical issues, try restarting first. What's the specific problem?"
319
+ ]
320
+ },
321
+ sales: {
322
+ name: "Sales Agent",
323
+ responses: [
324
+ "I can help with product questions and purchases. What are you interested in?",
325
+ "We have great deals today! How can I assist with your purchase?"
326
+ ]
327
+ }
328
+ };
329
+
330
+ // DOM elements
331
+ const agentTitle = document.getElementById('agent-title');
332
+ const agentSelector = document.getElementById('agent-selector');
333
+ const historyButton = document.getElementById('history-button');
334
+ const historyModal = document.getElementById('history-modal');
335
+ const historyList = document.getElementById('history-list');
336
+
337
+ // Add a message to the chat
338
+ function addMessage(text, isUser) {
339
+ const messageDiv = document.createElement('div');
340
+ messageDiv.classList.add('message');
341
+ messageDiv.classList.add(isUser ? 'user-message' : 'bot-message');
342
+
343
+ const textNode = document.createTextNode(text);
344
+ messageDiv.appendChild(textNode);
345
+
346
+ // Add timestamp
347
+ const timestamp = document.createElement('div');
348
+ timestamp.classList.add('timestamp');
349
+ const now = new Date();
350
+ timestamp.textContent = now.toLocaleTimeString([], {hour: '2-digit', minute:'2-digit'});
351
+ messageDiv.appendChild(timestamp);
352
+
353
+ chatMessages.appendChild(messageDiv);
354
+ chatMessages.scrollTop = chatMessages.scrollHeight;
355
+
356
+ return messageDiv;
357
+ }
358
+
359
+ // Show typing indicator
360
+ function showTypingIndicator() {
361
+ const typingDiv = document.createElement('div');
362
+ typingDiv.classList.add('typing-indicator');
363
+ typingDiv.id = 'typing-indicator';
364
+
365
+ for (let i = 0; i < 3; i++) {
366
+ const dot = document.createElement('div');
367
+ dot.classList.add('typing-dot');
368
+ typingDiv.appendChild(dot);
369
+ }
370
+
371
+ chatMessages.appendChild(typingDiv);
372
+ chatMessages.scrollTop = chatMessages.scrollHeight;
373
+ return typingDiv;
374
+ }
375
+
376
+ // Remove typing indicator
377
+ function removeTypingIndicator() {
378
+ const typingIndicator = document.getElementById('typing-indicator');
379
+ if (typingIndicator) {
380
+ typingIndicator.remove();
381
+ }
382
+ }
383
+
384
+ // Get agent-specific response
385
+ function getBotResponse() {
386
+ const agent = agents[chatState.agent];
387
+ return agent.responses[Math.floor(Math.random() * agent.responses.length)];
388
+ }
389
+
390
+ // Handle sending a message
391
+ function sendMessage() {
392
+ const message = userInput.value.trim();
393
+ if (message === '') return;
394
+
395
+ // Add user message
396
+ addMessage(message, true);
397
+ userInput.value = '';
398
+
399
+ // Show typing indicator
400
+ const typing = showTypingIndicator();
401
+
402
+ // Simulate bot thinking
403
+ setTimeout(() => {
404
+ removeTypingIndicator();
405
+
406
+ // Add bot response
407
+ const response = getBotResponse();
408
+ addMessage(response, false);
409
+ }, 1500 + Math.random() * 2000);
410
+ }
411
+
412
+ // Event listeners
413
+ sendButton.addEventListener('click', sendMessage);
414
+ userInput.addEventListener('keypress', (e) => {
415
+ if (e.key === 'Enter') {
416
+ sendMessage();
417
+ }
418
+ });
419
+
420
+ // Agent selector change handler
421
+ agentSelector.addEventListener('change', (e) => {
422
+ chatState.agent = e.target.value;
423
+ agentTitle.textContent = agents[chatState.agent].name;
424
+ addMessage(`Agent changed to ${agents[chatState.agent].name}`, false);
425
+ });
426
+
427
+ // History button click handler
428
+ historyButton.addEventListener('click', showHistory);
429
+ document.getElementById('close-history').addEventListener('click', hideHistory);
430
+
431
+ // Show conversation history
432
+ function showHistory() {
433
+ historyList.innerHTML = chatState.history.map(entry =>
434
+ `<div class="history-entry">
435
+ <span class="history-time">${new Date(entry.time).toLocaleString()}</span>
436
+ <strong>${entry.role === 'user' ? 'You' : 'AI'}:</strong> ${entry.text}
437
+ </div>`
438
+ ).join('');
439
+ historyModal.style.display = 'block';
440
+ }
441
+
442
+ function hideHistory() {
443
+ historyModal.style.display = 'none';
444
+ }
445
+
446
+ // Modified addMessage to track history
447
+ function addMessage(text, isUser) {
448
+ const messageDiv = document.createElement('div');
449
+ messageDiv.classList.add('message');
450
+ messageDiv.classList.add(isUser ? 'user-message' : 'bot-message');
451
+
452
+ const textNode = document.createTextNode(text);
453
+ messageDiv.appendChild(textNode);
454
+
455
+ const timestamp = document.createElement('div');
456
+ timestamp.classList.add('timestamp');
457
+ const now = new Date();
458
+ timestamp.textContent = now.toLocaleTimeString([], {hour: '2-digit', minute:'2-digit'});
459
+ messageDiv.appendChild(timestamp);
460
+
461
+ chatMessages.appendChild(messageDiv);
462
+ chatMessages.scrollTop = chatMessages.scrollHeight;
463
+
464
+ // Save to history
465
+ chatState.history.push({
466
+ text: text,
467
+ role: isUser ? 'user' : 'bot',
468
+ time: now.getTime()
469
+ });
470
+
471
+ return messageDiv;
472
+ }
473
+
474
+ // Get agent-specific response
475
+ function getBotResponse() {
476
+ const agent = agents[chatState.agent];
477
+ return agent.responses[Math.floor(Math.random() * agent.responses.length)];
478
+ }
479
+
480
+ // Initial greeting
481
+ window.addEventListener('load', () => {
482
+ chatState.history.push({
483
+ text: "Hello! I'm your General Assistant. How can I help you today?",
484
+ role: 'bot',
485
+ time: Date.now()
486
+ });
487
+ chatMessages.scrollTop = chatMessages.scrollHeight;
488
+ });
489
+ </script>
490
+ <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=alterzick/chatbot-v1" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
491
  </html>
492
+
493
+ ```