Add 2 files
Browse files- README.md +7 -5
- index.html +482 -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: my-space
|
3 |
+
emoji: 🐳
|
4 |
+
colorFrom: blue
|
5 |
+
colorTo: blue
|
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,482 @@
|
|
1 |
-
<!
|
2 |
-
<html>
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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>Knowledge Base 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 |
+
.custom-scrollbar::-webkit-scrollbar {
|
22 |
+
width: 6px;
|
23 |
+
}
|
24 |
+
|
25 |
+
.custom-scrollbar::-webkit-scrollbar-track {
|
26 |
+
background: #f1f1f1;
|
27 |
+
border-radius: 10px;
|
28 |
+
}
|
29 |
+
|
30 |
+
.custom-scrollbar::-webkit-scrollbar-thumb {
|
31 |
+
background: #888;
|
32 |
+
border-radius: 10px;
|
33 |
+
}
|
34 |
+
|
35 |
+
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
|
36 |
+
background: #555;
|
37 |
+
}
|
38 |
+
|
39 |
+
/* Pulse animation for typing indicator */
|
40 |
+
@keyframes pulse {
|
41 |
+
0%, 100% { opacity: 1; }
|
42 |
+
50% { opacity: 0.5; }
|
43 |
+
}
|
44 |
+
|
45 |
+
.typing-dot {
|
46 |
+
animation: pulse 1.5s infinite ease-in-out;
|
47 |
+
}
|
48 |
+
|
49 |
+
.typing-dot:nth-child(1) {
|
50 |
+
animation-delay: 0s;
|
51 |
+
}
|
52 |
+
|
53 |
+
.typing-dot:nth-child(2) {
|
54 |
+
animation-delay: 0.3s;
|
55 |
+
}
|
56 |
+
|
57 |
+
.typing-dot:nth-child(3) {
|
58 |
+
animation-delay: 0.6s;
|
59 |
+
}
|
60 |
+
</style>
|
61 |
+
</head>
|
62 |
+
<body class="bg-gray-100 font-sans">
|
63 |
+
<div class="container mx-auto max-w-6xl p-4">
|
64 |
+
<!-- Header -->
|
65 |
+
<header class="flex justify-between items-center mb-6">
|
66 |
+
<div class="flex items-center">
|
67 |
+
<div class="w-12 h-12 rounded-full bg-blue-600 flex items-center justify-center mr-3">
|
68 |
+
<i class="fas fa-robot text-white text-2xl"></i>
|
69 |
+
</div>
|
70 |
+
<div>
|
71 |
+
<h1 class="text-2xl font-bold text-gray-800">Knowledge Base Assistant</h1>
|
72 |
+
<p class="text-gray-600">Ask me anything from our documentation</p>
|
73 |
+
</div>
|
74 |
+
</div>
|
75 |
+
<div class="flex space-x-2">
|
76 |
+
<button id="clearChat" class="px-4 py-2 bg-gray-200 hover:bg-gray-300 rounded-lg text-gray-700 transition">
|
77 |
+
<i class="fas fa-trash-alt mr-2"></i>Clear
|
78 |
+
</button>
|
79 |
+
<button class="px-4 py-2 bg-blue-600 hover:bg-blue-700 rounded-lg text-white transition">
|
80 |
+
<i class="fas fa-book mr-2"></i>Knowledge Base
|
81 |
+
</button>
|
82 |
+
</div>
|
83 |
+
</header>
|
84 |
+
|
85 |
+
<!-- Main Chat Area -->
|
86 |
+
<div class="bg-white rounded-xl shadow-lg overflow-hidden">
|
87 |
+
<div class="flex h-[70vh]">
|
88 |
+
<!-- Sidebar with categories -->
|
89 |
+
<div class="w-64 bg-gray-50 border-r border-gray-200 p-4 hidden md:block">
|
90 |
+
<div class="mb-6">
|
91 |
+
<h3 class="font-semibold text-gray-700 mb-3">Categories</h3>
|
92 |
+
<ul class="space-y-2">
|
93 |
+
<li>
|
94 |
+
<button class="category-btn w-full text-left px-3 py-2 rounded-lg bg-blue-100 text-blue-700 font-medium">
|
95 |
+
<i class="fas fa-cog mr-2"></i>Getting Started
|
96 |
+
</button>
|
97 |
+
</li>
|
98 |
+
<li>
|
99 |
+
<button class="category-btn w-full text-left px-3 py-2 rounded-lg hover:bg-gray-100 text-gray-700 transition">
|
100 |
+
<i class="fas fa-user mr-2"></i>User Guide
|
101 |
+
</button>
|
102 |
+
</li>
|
103 |
+
<li>
|
104 |
+
<button class="category-btn w-full text-left px-3 py-2 rounded-lg hover:bg-gray-100 text-gray-700 transition">
|
105 |
+
<i class="fas fa-tools mr-2"></i>Troubleshooting
|
106 |
+
</button>
|
107 |
+
</li>
|
108 |
+
<li>
|
109 |
+
<button class="category-btn w-full text-left px-3 py-2 rounded-lg hover:bg-gray-100 text-gray-700 transition">
|
110 |
+
<i class="fas fa-shield-alt mr-2"></i>Security
|
111 |
+
</button>
|
112 |
+
</li>
|
113 |
+
<li>
|
114 |
+
<button class="category-btn w-full text-left px-3 py-2 rounded-lg hover:bg-gray-100 text-gray-700 transition">
|
115 |
+
<i class="fas fa-chart-line mr-2"></i>API Reference
|
116 |
+
</button>
|
117 |
+
</li>
|
118 |
+
</ul>
|
119 |
+
</div>
|
120 |
+
<div>
|
121 |
+
<h3 class="font-semibold text-gray-700 mb-3">Popular Questions</h3>
|
122 |
+
<ul class="space-y-2">
|
123 |
+
<li>
|
124 |
+
<button class="suggested-question w-full text-left px-3 py-2 text-sm rounded-lg hover:bg-gray-100 text-gray-600 transition">
|
125 |
+
How do I reset my password?
|
126 |
+
</button>
|
127 |
+
</li>
|
128 |
+
<li>
|
129 |
+
<button class="suggested-question w-full text-left px-3 py-2 text-sm rounded-lg hover:bg-gray-100 text-gray-600 transition">
|
130 |
+
Where can I download the mobile app?
|
131 |
+
</button>
|
132 |
+
</li>
|
133 |
+
<li>
|
134 |
+
<button class="suggested-question w-full text-left px-3 py-2 text-sm rounded-lg hover:bg-gray-100 text-gray-600 transition">
|
135 |
+
What are the system requirements?
|
136 |
+
</button>
|
137 |
+
</li>
|
138 |
+
<li>
|
139 |
+
<button class="suggested-question w-full text-left px-3 py-2 text-sm rounded-lg hover:bg-gray-100 text-gray-600 transition">
|
140 |
+
How to enable two-factor authentication?
|
141 |
+
</button>
|
142 |
+
</li>
|
143 |
+
</ul>
|
144 |
+
</div>
|
145 |
+
</div>
|
146 |
+
|
147 |
+
<!-- Chat messages -->
|
148 |
+
<div class="flex-1 flex flex-col">
|
149 |
+
<div id="chatMessages" class="flex-1 p-6 overflow-y-auto custom-scrollbar">
|
150 |
+
<!-- Welcome message -->
|
151 |
+
<div class="message mb-6">
|
152 |
+
<div class="flex items-start">
|
153 |
+
<div class="w-10 h-10 rounded-full bg-blue-100 flex items-center justify-center mr-3">
|
154 |
+
<i class="fas fa-robot text-blue-600"></i>
|
155 |
+
</div>
|
156 |
+
<div class="flex-1">
|
157 |
+
<div class="bg-gray-100 rounded-xl p-4 inline-block max-w-3xl">
|
158 |
+
<h3 class="font-bold text-gray-800 mb-1">Hello! 👋</h3>
|
159 |
+
<p class="text-gray-700">I'm your Knowledge Base Assistant. I can help you find answers from our documentation. Try asking me something like:</p>
|
160 |
+
<ul class="mt-2 space-y-1">
|
161 |
+
<li class="text-blue-600">• How do I create an account?</li>
|
162 |
+
<li class="text-blue-600">• Where can I find the user manual?</li>
|
163 |
+
<li class="text-blue-600">• What's the refund policy?</li>
|
164 |
+
</ul>
|
165 |
+
</div>
|
166 |
+
<p class="text-xs text-gray-500 mt-1">Today at <span id="currentTime"></span></p>
|
167 |
+
</div>
|
168 |
+
</div>
|
169 |
+
</div>
|
170 |
+
</div>
|
171 |
+
|
172 |
+
<!-- Typing indicator (hidden by default) -->
|
173 |
+
<div id="typingIndicator" class="px-6 pb-4 hidden">
|
174 |
+
<div class="flex items-start">
|
175 |
+
<div class="w-10 h-10 rounded-full bg-blue-100 flex items-center justify-center mr-3">
|
176 |
+
<i class="fas fa-robot text-blue-600"></i>
|
177 |
+
</div>
|
178 |
+
<div class="flex items-center space-x-1 bg-gray-100 rounded-xl p-3">
|
179 |
+
<div class="typing-dot w-2 h-2 bg-gray-500 rounded-full"></div>
|
180 |
+
<div class="typing-dot w-2 h-2 bg-gray-500 rounded-full"></div>
|
181 |
+
<div class="typing-dot w-2 h-2 bg-gray-500 rounded-full"></div>
|
182 |
+
</div>
|
183 |
+
</div>
|
184 |
+
</div>
|
185 |
+
|
186 |
+
<!-- Input area -->
|
187 |
+
<div class="border-t border-gray-200 p-4 bg-gray-50">
|
188 |
+
<form id="chatForm" class="flex items-center">
|
189 |
+
<div class="flex-1 relative">
|
190 |
+
<input
|
191 |
+
id="userInput"
|
192 |
+
type="text"
|
193 |
+
placeholder="Ask a question..."
|
194 |
+
class="w-full p-4 pr-12 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"
|
195 |
+
autocomplete="off"
|
196 |
+
>
|
197 |
+
<button type="button" id="attachFile" class="absolute right-12 top-4 text-gray-500 hover:text-gray-700">
|
198 |
+
<i class="fas fa-paperclip"></i>
|
199 |
+
</button>
|
200 |
+
<button type="button" id="voiceInput" class="absolute right-4 top-4 text-gray-500 hover:text-gray-700">
|
201 |
+
<i class="fas fa-microphone"></i>
|
202 |
+
</button>
|
203 |
+
</div>
|
204 |
+
<button type="submit" class="ml-3 w-12 h-12 rounded-lg bg-blue-600 text-white hover:bg-blue-700 transition flex items-center justify-center">
|
205 |
+
<i class="fas fa-paper-plane"></i>
|
206 |
+
</button>
|
207 |
+
</form>
|
208 |
+
<div class="mt-2 text-xs text-gray-500 flex justify-between">
|
209 |
+
<div>
|
210 |
+
<span id="charCount">0</span>/500 characters
|
211 |
+
</div>
|
212 |
+
<div>
|
213 |
+
<button id="suggestQuestions" class="text-blue-600 hover:underline">Need inspiration?</button>
|
214 |
+
</div>
|
215 |
+
</div>
|
216 |
+
</div>
|
217 |
+
</div>
|
218 |
+
</div>
|
219 |
+
</div>
|
220 |
+
|
221 |
+
<!-- Feedback modal (hidden by default) -->
|
222 |
+
<div id="feedbackModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden">
|
223 |
+
<div class="bg-white rounded-xl p-6 w-full max-w-md">
|
224 |
+
<div class="flex justify-between items-center mb-4">
|
225 |
+
<h3 class="text-lg font-semibold">Was this response helpful?</h3>
|
226 |
+
<button id="closeFeedbackModal" class="text-gray-500 hover:text-gray-700">
|
227 |
+
<i class="fas fa-times"></i>
|
228 |
+
</button>
|
229 |
+
</div>
|
230 |
+
<div class="flex space-x-3 mb-4">
|
231 |
+
<button class="feedback-btn flex-1 py-2 rounded-lg border border-gray-300 hover:bg-green-50 hover:border-green-500 text-gray-700" data-feedback="yes">
|
232 |
+
<i class="fas fa-thumbs-up mr-2 text-green-500"></i> Yes
|
233 |
+
</button>
|
234 |
+
<button class="feedback-btn flex-1 py-2 rounded-lg border border-gray-300 hover:bg-red-50 hover:border-red-500 text-gray-700" data-feedback="no">
|
235 |
+
<i class="fas fa-thumbs-down mr-2 text-red-500"></i> No
|
236 |
+
</button>
|
237 |
+
</div>
|
238 |
+
<div id="feedbackCommentArea" class="hidden">
|
239 |
+
<textarea class="w-full p-3 border border-gray-300 rounded-lg mb-3" placeholder="What could be improved?"></textarea>
|
240 |
+
<button id="submitFeedback" class="w-full py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700">Submit Feedback</button>
|
241 |
+
</div>
|
242 |
+
</div>
|
243 |
+
</div>
|
244 |
+
</div>
|
245 |
+
|
246 |
+
<script>
|
247 |
+
document.addEventListener('DOMContentLoaded', function() {
|
248 |
+
// Set current time
|
249 |
+
const now = new Date();
|
250 |
+
const timeString = now.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
|
251 |
+
document.getElementById('currentTime').textContent = timeString;
|
252 |
+
|
253 |
+
// Character counter for input
|
254 |
+
const userInput = document.getElementById('userInput');
|
255 |
+
const charCount = document.getElementById('charCount');
|
256 |
+
|
257 |
+
userInput.addEventListener('input', function() {
|
258 |
+
charCount.textContent = this.value.length;
|
259 |
+
});
|
260 |
+
|
261 |
+
// Chat form submission
|
262 |
+
const chatForm = document.getElementById('chatForm');
|
263 |
+
const chatMessages = document.getElementById('chatMessages');
|
264 |
+
const typingIndicator = document.getElementById('typingIndicator');
|
265 |
+
|
266 |
+
chatForm.addEventListener('submit', function(e) {
|
267 |
+
e.preventDefault();
|
268 |
+
const message = userInput.value.trim();
|
269 |
+
if (message === '') return;
|
270 |
+
|
271 |
+
// Add user message to chat
|
272 |
+
addMessageToChat('user', message);
|
273 |
+
userInput.value = '';
|
274 |
+
charCount.textContent = '0';
|
275 |
+
|
276 |
+
// Show typing indicator
|
277 |
+
typingIndicator.classList.remove('hidden');
|
278 |
+
|
279 |
+
// Scroll to bottom
|
280 |
+
chatMessages.scrollTop = chatMessages.scrollHeight;
|
281 |
+
|
282 |
+
// Simulate bot response after a delay
|
283 |
+
setTimeout(() => {
|
284 |
+
typingIndicator.classList.add('hidden');
|
285 |
+
const botResponse = generateBotResponse(message);
|
286 |
+
addMessageToChat('bot', botResponse);
|
287 |
+
|
288 |
+
// Scroll to bottom after bot responds
|
289 |
+
setTimeout(() => {
|
290 |
+
chatMessages.scrollTop = chatMessages.scrollHeight;
|
291 |
+
}, 100);
|
292 |
+
}, 1500);
|
293 |
+
});
|
294 |
+
|
295 |
+
// Clear chat button
|
296 |
+
document.getElementById('clearChat').addEventListener('click', function() {
|
297 |
+
chatMessages.innerHTML = `
|
298 |
+
<div class="message mb-6">
|
299 |
+
<div class="flex items-start">
|
300 |
+
<div class="w-10 h-10 rounded-full bg-blue-100 flex items-center justify-center mr-3">
|
301 |
+
<i class="fas fa-robot text-blue-600"></i>
|
302 |
+
</div>
|
303 |
+
<div class="flex-1">
|
304 |
+
<div class="bg-gray-100 rounded-xl p-4 inline-block max-w-3xl">
|
305 |
+
<h3 class="font-bold text-gray-800 mb-1">Hello! 👋</h3>
|
306 |
+
<p class="text-gray-700">I'm your Knowledge Base Assistant. I can help you find answers from our documentation. Try asking me something like:</p>
|
307 |
+
<ul class="mt-2 space-y-1">
|
308 |
+
<li class="text-blue-600">• How do I create an account?</li>
|
309 |
+
<li class="text-blue-600">• Where can I find the user manual?</li>
|
310 |
+
<li class="text-blue-600">• What's the refund policy?</li>
|
311 |
+
</ul>
|
312 |
+
</div>
|
313 |
+
<p class="text-xs text-gray-500 mt-1">Today at ${timeString}</p>
|
314 |
+
</div>
|
315 |
+
</div>
|
316 |
+
</div>
|
317 |
+
`;
|
318 |
+
});
|
319 |
+
|
320 |
+
// Suggested questions
|
321 |
+
document.querySelectorAll('.suggested-question').forEach(button => {
|
322 |
+
button.addEventListener('click', function() {
|
323 |
+
userInput.value = this.textContent;
|
324 |
+
userInput.focus();
|
325 |
+
});
|
326 |
+
});
|
327 |
+
|
328 |
+
// Need inspiration button
|
329 |
+
document.getElementById('suggestQuestions').addEventListener('click', function() {
|
330 |
+
const suggestions = [
|
331 |
+
"How do I update my profile information?",
|
332 |
+
"Where can I find the pricing plans?",
|
333 |
+
"How to export my data?",
|
334 |
+
"What payment methods do you accept?",
|
335 |
+
"How to contact customer support?"
|
336 |
+
];
|
337 |
+
|
338 |
+
const randomSuggestion = suggestions[Math.floor(Math.random() * suggestions.length)];
|
339 |
+
userInput.value = randomSuggestion;
|
340 |
+
userInput.focus();
|
341 |
+
});
|
342 |
+
|
343 |
+
// Feedback modal
|
344 |
+
const feedbackModal = document.getElementById('feedbackModal');
|
345 |
+
const closeFeedbackModal = document.getElementById('closeFeedbackModal');
|
346 |
+
const feedbackBtns = document.querySelectorAll('.feedback-btn');
|
347 |
+
const feedbackCommentArea = document.getElementById('feedbackCommentArea');
|
348 |
+
const submitFeedback = document.getElementById('submitFeedback');
|
349 |
+
|
350 |
+
feedbackBtns.forEach(btn => {
|
351 |
+
btn.addEventListener('click', function() {
|
352 |
+
if (this.dataset.feedback === 'no') {
|
353 |
+
feedbackCommentArea.classList.remove('hidden');
|
354 |
+
} else {
|
355 |
+
feedbackModal.classList.add('hidden');
|
356 |
+
showToast('Thanks for your feedback!');
|
357 |
+
}
|
358 |
+
});
|
359 |
+
});
|
360 |
+
|
361 |
+
closeFeedbackModal.addEventListener('click', function() {
|
362 |
+
feedbackModal.classList.add('hidden');
|
363 |
+
});
|
364 |
+
|
365 |
+
submitFeedback.addEventListener('click', function() {
|
366 |
+
feedbackModal.classList.add('hidden');
|
367 |
+
showToast('Feedback submitted. Thank you!');
|
368 |
+
});
|
369 |
+
|
370 |
+
// Helper functions
|
371 |
+
function addMessageToChat(sender, message) {
|
372 |
+
const now = new Date();
|
373 |
+
const timeString = now.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
|
374 |
+
|
375 |
+
if (sender === 'user') {
|
376 |
+
const messageElement = `
|
377 |
+
<div class="message mb-6">
|
378 |
+
<div class="flex items-start justify-end">
|
379 |
+
<div class="flex-1 max-w-3xl">
|
380 |
+
<div class="bg-blue-600 text-white rounded-xl p-4 inline-block">
|
381 |
+
${message}
|
382 |
+
</div>
|
383 |
+
<p class="text-xs text-gray-500 mt-1 text-right">${timeString}</p>
|
384 |
+
</div>
|
385 |
+
<div class="w-10 h-10 rounded-full bg-blue-600 flex items-center justify-center ml-3">
|
386 |
+
<i class="fas fa-user text-white"></i>
|
387 |
+
</div>
|
388 |
+
</div>
|
389 |
+
</div>
|
390 |
+
`;
|
391 |
+
chatMessages.insertAdjacentHTML('beforeend', messageElement);
|
392 |
+
} else {
|
393 |
+
const messageElement = `
|
394 |
+
<div class="message mb-6">
|
395 |
+
<div class="flex items-start">
|
396 |
+
<div class="w-10 h-10 rounded-full bg-blue-100 flex items-center justify-center mr-3">
|
397 |
+
<i class="fas fa-robot text-blue-600"></i>
|
398 |
+
</div>
|
399 |
+
<div class="flex-1">
|
400 |
+
<div class="bg-gray-100 rounded-xl p-4 inline-block max-w-3xl">
|
401 |
+
${message}
|
402 |
+
</div>
|
403 |
+
<div class="mt-2 flex items-center space-x-3">
|
404 |
+
<button class="text-xs text-blue-600 hover:underline feedback-trigger">Was this helpful?</button>
|
405 |
+
<button class="text-xs text-gray-500 hover:text-gray-700">
|
406 |
+
<i class="fas fa-copy mr-1"></i>Copy
|
407 |
+
</button>
|
408 |
+
</div>
|
409 |
+
<p class="text-xs text-gray-500 mt-1">${timeString}</p>
|
410 |
+
</div>
|
411 |
+
</div>
|
412 |
+
</div>
|
413 |
+
`;
|
414 |
+
chatMessages.insertAdjacentHTML('beforeend', messageElement);
|
415 |
+
|
416 |
+
// Add event listener to the new feedback button
|
417 |
+
const lastMessage = chatMessages.lastElementChild;
|
418 |
+
const feedbackTrigger = lastMessage.querySelector('.feedback-trigger');
|
419 |
+
feedbackTrigger.addEventListener('click', function() {
|
420 |
+
feedbackModal.classList.remove('hidden');
|
421 |
+
});
|
422 |
+
}
|
423 |
+
}
|
424 |
+
|
425 |
+
function generateBotResponse(question) {
|
426 |
+
// This is a simplified response generator
|
427 |
+
// In a real app, you would connect to your knowledge base API
|
428 |
+
|
429 |
+
const responses = {
|
430 |
+
"hello": "Hello! How can I assist you with our knowledge base today?",
|
431 |
+
"hi": "Hi there! What would you like to know?",
|
432 |
+
"help": "I'm here to help! Please ask me a specific question about our product or service.",
|
433 |
+
"account": "To manage your account, please go to Settings > Account. There you can update your profile, change your password, and manage security settings.",
|
434 |
+
"password": "To reset your password: 1) Go to the login page 2) Click 'Forgot password' 3) Enter your email 4) Follow the instructions in the email you receive.",
|
435 |
+
"contact": "You can contact our support team by email at [email protected] or by phone at (555) 123-4567. Our support hours are Monday-Friday, 9AM-5PM.",
|
436 |
+
"refund": "Our refund policy allows for returns within 30 days of purchase. Please contact our support team with your order number to initiate a refund.",
|
437 |
+
"download": "You can download our mobile app from the Apple App Store or Google Play Store. Search for 'OurProductName' to find it."
|
438 |
+
};
|
439 |
+
|
440 |
+
// Check for exact matches first
|
441 |
+
const lowerQuestion = question.toLowerCase();
|
442 |
+
if (responses[lowerQuestion]) {
|
443 |
+
return responses[lowerQuestion];
|
444 |
+
}
|
445 |
+
|
446 |
+
// Check for keywords
|
447 |
+
if (lowerQuestion.includes('password')) {
|
448 |
+
return responses['password'];
|
449 |
+
} else if (lowerQuestion.includes('account')) {
|
450 |
+
return responses['account'];
|
451 |
+
} else if (lowerQuestion.includes('contact') || lowerQuestion.includes('support')) {
|
452 |
+
return responses['contact'];
|
453 |
+
} else if (lowerQuestion.includes('refund') || lowerQuestion.includes('return')) {
|
454 |
+
return responses['refund'];
|
455 |
+
} else if (lowerQuestion.includes('download') || lowerQuestion.includes('app')) {
|
456 |
+
return responses['download'];
|
457 |
+
}
|
458 |
+
|
459 |
+
// Default response
|
460 |
+
return `I found this information that might help with your question about "${question}":<br><br>
|
461 |
+
<div class="bg-blue-50 border-l-4 border-blue-500 p-3 rounded-r-lg mb-3">
|
462 |
+
<h4 class="font-semibold text-blue-800">Related Article</h4>
|
463 |
+
<p class="text-blue-700">"${question.replace('?', '')}" in our knowledge base</p>
|
464 |
+
<a href="#" class="text-blue-600 text-sm hover:underline mt-1 inline-block">Read more →</a>
|
465 |
+
</div>
|
466 |
+
Does this answer your question? If not, please try rephrasing or ask something more specific.`;
|
467 |
+
}
|
468 |
+
|
469 |
+
function showToast(message) {
|
470 |
+
const toast = document.createElement('div');
|
471 |
+
toast.className = 'fixed bottom-4 right-4 bg-gray-800 text-white px-4 py-2 rounded-lg shadow-lg animate-fade-in-out';
|
472 |
+
toast.textContent = message;
|
473 |
+
document.body.appendChild(toast);
|
474 |
+
|
475 |
+
setTimeout(() => {
|
476 |
+
toast.remove();
|
477 |
+
}, 3000);
|
478 |
+
}
|
479 |
+
});
|
480 |
+
</script>
|
481 |
+
<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=UjjwalK/my-space" style="color: #fff;text-decoration: underline;" target="_blank" >🧬 Remix</a></p></body>
|
482 |
+
</html>
|