gusbsuke commited on
Commit
b995fd0
·
verified ·
1 Parent(s): 7988425

Implement the Chatbot - Initial Deployment

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: Deepsite Sw
3
- emoji: 🐠
4
- colorFrom: purple
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: deepsite-sw
3
+ emoji: 🐳
4
+ colorFrom: green
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,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>Interactive 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 {
14
+ max-width: 80%;
15
+ word-wrap: break-word;
16
+ }
17
+ .typing-indicator {
18
+ display: flex;
19
+ align-items: center;
20
+ }
21
+ .typing-dot {
22
+ width: 8px;
23
+ height: 8px;
24
+ border-radius: 50%;
25
+ background-color: #4b5563;
26
+ margin: 0 2px;
27
+ animation: typing 1.5s infinite ease-in-out;
28
+ }
29
+ .typing-dot:nth-child(1) {
30
+ animation-delay: 0s;
31
+ }
32
+ .typing-dot:nth-child(2) {
33
+ animation-delay: 0.3s;
34
+ }
35
+ .typing-dot:nth-child(3) {
36
+ animation-delay: 0.6s;
37
+ }
38
+ @keyframes typing {
39
+ 0%, 100% {
40
+ transform: translateY(0);
41
+ }
42
+ 50% {
43
+ transform: translateY(-5px);
44
+ }
45
+ }
46
+ .chat-input {
47
+ resize: none;
48
+ }
49
+ .chat-input:focus {
50
+ outline: none;
51
+ }
52
+ </style>
53
+ </head>
54
+ <body class="bg-gray-100 font-sans">
55
+ <div class="max-w-4xl mx-auto p-4">
56
+ <div class="bg-white rounded-xl shadow-lg overflow-hidden">
57
+ <!-- Chat Header -->
58
+ <div class="bg-indigo-600 text-white p-4 flex items-center justify-between">
59
+ <div class="flex items-center space-x-3">
60
+ <div class="w-10 h-10 rounded-full bg-indigo-500 flex items-center justify-center">
61
+ <i class="fas fa-robot text-xl"></i>
62
+ </div>
63
+ <div>
64
+ <h2 class="font-bold text-lg">AI Assistant</h2>
65
+ <p class="text-xs opacity-80">Online</p>
66
+ </div>
67
+ </div>
68
+ <div class="flex space-x-3">
69
+ <button class="text-white hover:text-indigo-200 transition">
70
+ <i class="fas fa-ellipsis-v"></i>
71
+ </button>
72
+ </div>
73
+ </div>
74
+
75
+ <!-- Chat Messages -->
76
+ <div class="chat-container p-4 overflow-y-auto bg-gray-50">
77
+ <div id="chat-messages" class="space-y-4">
78
+ <!-- Welcome message -->
79
+ <div class="flex justify-start">
80
+ <div class="message bg-white p-3 rounded-lg rounded-tl-none shadow-sm">
81
+ <p>Hello! 👋 I'm your AI assistant. How can I help you today?</p>
82
+ </div>
83
+ </div>
84
+ </div>
85
+ </div>
86
+
87
+ <!-- Chat Input -->
88
+ <div class="border-t border-gray-200 p-4 bg-white">
89
+ <div class="flex items-end space-x-2">
90
+ <div class="flex-1 relative">
91
+ <textarea
92
+ id="chat-input"
93
+ class="chat-input w-full border border-gray-300 rounded-lg p-3 pr-10 focus:border-indigo-500 transition"
94
+ placeholder="Type your message here..."
95
+ rows="1"
96
+ ></textarea>
97
+ <button id="send-button" class="absolute right-2 bottom-2 text-indigo-600 hover:text-indigo-800 transition">
98
+ <i class="fas fa-paper-plane"></i>
99
+ </button>
100
+ </div>
101
+ <button id="mic-button" class="p-3 rounded-full bg-indigo-100 text-indigo-600 hover:bg-indigo-200 transition">
102
+ <i class="fas fa-microphone"></i>
103
+ </button>
104
+ </div>
105
+ <div class="mt-2 text-xs text-gray-500 flex justify-between">
106
+ <span>AI Assistant may produce inaccurate information</span>
107
+ <span id="char-count">0/500</span>
108
+ </div>
109
+ </div>
110
+ </div>
111
+ </div>
112
+
113
+ <script>
114
+ document.addEventListener('DOMContentLoaded', function() {
115
+ const chatMessages = document.getElementById('chat-messages');
116
+ const chatInput = document.getElementById('chat-input');
117
+ const sendButton = document.getElementById('send-button');
118
+ const micButton = document.getElementById('mic-button');
119
+ const charCount = document.getElementById('char-count');
120
+
121
+ // Auto-resize textarea
122
+ chatInput.addEventListener('input', function() {
123
+ this.style.height = 'auto';
124
+ this.style.height = (this.scrollHeight) + 'px';
125
+
126
+ // Update character count
127
+ const currentLength = this.value.length;
128
+ charCount.textContent = `${currentLength}/500`;
129
+
130
+ if (currentLength > 500) {
131
+ charCount.classList.add('text-red-500');
132
+ } else {
133
+ charCount.classList.remove('text-red-500');
134
+ }
135
+ });
136
+
137
+ // Send message on Enter (but allow Shift+Enter for new lines)
138
+ chatInput.addEventListener('keydown', function(e) {
139
+ if (e.key === 'Enter' && !e.shiftKey) {
140
+ e.preventDefault();
141
+ sendMessage();
142
+ }
143
+ });
144
+
145
+ // Send message on button click
146
+ sendButton.addEventListener('click', sendMessage);
147
+
148
+ // Mic button functionality
149
+ micButton.addEventListener('click', function() {
150
+ this.classList.toggle('bg-red-100');
151
+ this.classList.toggle('text-red-600');
152
+ const icon = this.querySelector('i');
153
+
154
+ if (icon.classList.contains('fa-microphone')) {
155
+ icon.classList.remove('fa-microphone');
156
+ icon.classList.add('fa-microphone-slash');
157
+ // In a real app, you would start voice recognition here
158
+ addMessage('user', '🎤 Voice input activated (demo)');
159
+ } else {
160
+ icon.classList.remove('fa-microphone-slash');
161
+ icon.classList.add('fa-microphone');
162
+ // In a real app, you would stop voice recognition here
163
+ }
164
+ });
165
+
166
+ function sendMessage() {
167
+ const message = chatInput.value.trim();
168
+ if (message === '') return;
169
+
170
+ // Add user message
171
+ addMessage('user', message);
172
+ chatInput.value = '';
173
+ chatInput.style.height = 'auto';
174
+ charCount.textContent = '0/500';
175
+
176
+ // Show typing indicator
177
+ showTypingIndicator();
178
+
179
+ // Simulate AI response after a delay
180
+ setTimeout(() => {
181
+ removeTypingIndicator();
182
+
183
+ // Simple response logic - in a real app, you would call an API
184
+ const responses = [
185
+ "I understand what you're asking about. Let me think...",
186
+ "That's an interesting question! Here's what I know...",
187
+ "Thanks for your message. I can help with that.",
188
+ "I'm processing your request. Please wait a moment...",
189
+ "Let me check my knowledge base for that information."
190
+ ];
191
+
192
+ const randomResponse = responses[Math.floor(Math.random() * responses.length)];
193
+ addMessage('bot', randomResponse);
194
+
195
+ // Scroll to bottom
196
+ chatMessages.scrollTop = chatMessages.scrollHeight;
197
+ }, 1500);
198
+ }
199
+
200
+ function addMessage(sender, text) {
201
+ const messageDiv = document.createElement('div');
202
+ messageDiv.className = `flex ${sender === 'user' ? 'justify-end' : 'justify-start'}`;
203
+
204
+ const messageContent = document.createElement('div');
205
+ messageContent.className = `message ${sender === 'user' ? 'bg-indigo-100 text-indigo-900 rounded-tr-none' : 'bg-white rounded-tl-none'} p-3 rounded-lg shadow-sm`;
206
+ messageContent.innerHTML = `<p>${text}</p>`;
207
+
208
+ messageDiv.appendChild(messageContent);
209
+ chatMessages.appendChild(messageDiv);
210
+
211
+ // Scroll to bottom
212
+ chatMessages.scrollTop = chatMessages.scrollHeight;
213
+ }
214
+
215
+ function showTypingIndicator() {
216
+ const typingDiv = document.createElement('div');
217
+ typingDiv.className = 'flex justify-start';
218
+ typingDiv.id = 'typing-indicator';
219
+
220
+ const typingContent = document.createElement('div');
221
+ typingContent.className = 'message bg-white p-3 rounded-lg rounded-tl-none shadow-sm typing-indicator';
222
+ typingContent.innerHTML = `
223
+ <div class="flex space-x-1 mr-2">
224
+ <div class="typing-dot"></div>
225
+ <div class="typing-dot"></div>
226
+ <div class="typing-dot"></div>
227
+ </div>
228
+ <span class="text-gray-500 text-sm">AI is typing...</span>
229
+ `;
230
+
231
+ typingDiv.appendChild(typingContent);
232
+ chatMessages.appendChild(typingDiv);
233
+
234
+ // Scroll to bottom
235
+ chatMessages.scrollTop = chatMessages.scrollHeight;
236
+ }
237
+
238
+ function removeTypingIndicator() {
239
+ const typingIndicator = document.getElementById('typing-indicator');
240
+ if (typingIndicator) {
241
+ typingIndicator.remove();
242
+ }
243
+ }
244
+
245
+ // Add some sample messages for demo
246
+ setTimeout(() => {
247
+ addMessage('bot', "I can answer questions, provide information, or just chat. What would you like to know?");
248
+ }, 1000);
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=gusbsuke/deepsite-sw" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
252
+ </html>