Spaces:
Running
Running
Update index.html
Browse files- index.html +1 -764
index.html
CHANGED
@@ -1,764 +1 @@
|
|
1 |
-
|
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>SearchWizard Pro</title>
|
7 |
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/1.3.4/axios.min.js"></script>
|
8 |
-
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap" rel="stylesheet">
|
9 |
-
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
|
10 |
-
<style>
|
11 |
-
:root {
|
12 |
-
--primary-color: #3A0CA3;
|
13 |
-
--secondary-color: #F0F4FF;
|
14 |
-
--accent-color: #4CC9F0;
|
15 |
-
--text-color: #2B2D42;
|
16 |
-
--light-text-color: #8D99AE;
|
17 |
-
--border-color: #E0E1DD;
|
18 |
-
--hover-color: #7209B7;
|
19 |
-
--error-color: #EF233C;
|
20 |
-
--success-color: #06D6A0;
|
21 |
-
--gradient-start: #4361EE;
|
22 |
-
--gradient-end: #3A0CA3;
|
23 |
-
}
|
24 |
-
|
25 |
-
* {
|
26 |
-
margin: 0;
|
27 |
-
padding: 0;
|
28 |
-
box-sizing: border-box;
|
29 |
-
}
|
30 |
-
|
31 |
-
body, html {
|
32 |
-
font-family: 'Poppins', sans-serif;
|
33 |
-
height: 100%;
|
34 |
-
background-color: var(--secondary-color);
|
35 |
-
color: var(--text-color);
|
36 |
-
}
|
37 |
-
|
38 |
-
#app-container {
|
39 |
-
display: flex;
|
40 |
-
flex-direction: column;
|
41 |
-
height: 100vh;
|
42 |
-
max-width: 1800px;
|
43 |
-
margin: 0 auto;
|
44 |
-
background-color: #fff;
|
45 |
-
box-shadow: 0 0 50px rgba(0, 0, 0, 0.1);
|
46 |
-
border-radius: 20px;
|
47 |
-
overflow: hidden;
|
48 |
-
animation: fadeInApp 1s ease-out;
|
49 |
-
}
|
50 |
-
|
51 |
-
@keyframes fadeInApp {
|
52 |
-
from { opacity: 0; transform: translateY(20px); }
|
53 |
-
to { opacity: 1; transform: translateY(0); }
|
54 |
-
}
|
55 |
-
|
56 |
-
header {
|
57 |
-
background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
|
58 |
-
padding: 1.5rem 2rem;
|
59 |
-
display: flex;
|
60 |
-
justify-content: space-between;
|
61 |
-
align-items: center;
|
62 |
-
color: #ffffff;
|
63 |
-
border-bottom: 1px solid var(--border-color);
|
64 |
-
}
|
65 |
-
|
66 |
-
h1 {
|
67 |
-
font-size: 2.2rem;
|
68 |
-
font-weight: 700;
|
69 |
-
display: flex;
|
70 |
-
align-items: center;
|
71 |
-
animation: slideInLeft 0.8s ease-out;
|
72 |
-
}
|
73 |
-
|
74 |
-
@keyframes slideInLeft {
|
75 |
-
from { opacity: 0; transform: translateX(-50px); }
|
76 |
-
to { opacity: 1; transform: translateX(0); }
|
77 |
-
}
|
78 |
-
|
79 |
-
h1 i {
|
80 |
-
margin-right: 1rem;
|
81 |
-
font-size: 2.4rem;
|
82 |
-
animation: rotateIn 1s ease-out;
|
83 |
-
}
|
84 |
-
|
85 |
-
@keyframes rotateIn {
|
86 |
-
from { transform: rotate(-360deg); }
|
87 |
-
to { transform: rotate(0); }
|
88 |
-
}
|
89 |
-
|
90 |
-
#main-content {
|
91 |
-
display: flex;
|
92 |
-
flex-grow: 1;
|
93 |
-
overflow: hidden;
|
94 |
-
}
|
95 |
-
|
96 |
-
#chat-container {
|
97 |
-
flex: 2;
|
98 |
-
display: flex;
|
99 |
-
flex-direction: column;
|
100 |
-
border-right: 1px solid var(--border-color);
|
101 |
-
}
|
102 |
-
|
103 |
-
#chat-topic {
|
104 |
-
padding: 1.2rem 2rem;
|
105 |
-
font-size: 1.4rem;
|
106 |
-
font-weight: 600;
|
107 |
-
color: var(--primary-color);
|
108 |
-
background-color: #ffffff;
|
109 |
-
border-bottom: 1px solid var(--border-color);
|
110 |
-
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
|
111 |
-
animation: slideInDown 0.8s ease-out;
|
112 |
-
}
|
113 |
-
|
114 |
-
@keyframes slideInDown {
|
115 |
-
from { opacity: 0; transform: translateY(-20px); }
|
116 |
-
to { opacity: 1; transform: translateY(0); }
|
117 |
-
}
|
118 |
-
|
119 |
-
#chat-messages {
|
120 |
-
flex-grow: 1;
|
121 |
-
overflow-y: auto;
|
122 |
-
padding: 2rem;
|
123 |
-
display: flex;
|
124 |
-
flex-direction: column;
|
125 |
-
background-color: var(--secondary-color);
|
126 |
-
}
|
127 |
-
|
128 |
-
.message {
|
129 |
-
max-width: 80%;
|
130 |
-
margin-bottom: 1.5rem;
|
131 |
-
padding: 1.2rem 1.8rem;
|
132 |
-
border-radius: 1.5rem;
|
133 |
-
font-size: 1rem;
|
134 |
-
line-height: 1.6;
|
135 |
-
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
|
136 |
-
animation: fadeInMessage 0.5s ease-out;
|
137 |
-
transition: all 0.3s ease;
|
138 |
-
}
|
139 |
-
|
140 |
-
.message:hover {
|
141 |
-
transform: translateY(-2px);
|
142 |
-
box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
|
143 |
-
}
|
144 |
-
|
145 |
-
@keyframes fadeInMessage {
|
146 |
-
from { opacity: 0; transform: translateY(10px) scale(0.95); }
|
147 |
-
to { opacity: 1; transform: translateY(0) scale(1); }
|
148 |
-
}
|
149 |
-
|
150 |
-
.user-message {
|
151 |
-
align-self: flex-end;
|
152 |
-
background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
|
153 |
-
color: white;
|
154 |
-
animation: slideInRight 0.5s ease-out;
|
155 |
-
}
|
156 |
-
|
157 |
-
@keyframes slideInRight {
|
158 |
-
from { opacity: 0; transform: translateX(50px); }
|
159 |
-
to { opacity: 1; transform: translateX(0); }
|
160 |
-
}
|
161 |
-
|
162 |
-
.bot-message {
|
163 |
-
align-self: flex-start;
|
164 |
-
background-color: #ffffff;
|
165 |
-
color: var(--text-color);
|
166 |
-
border: 1px solid var(--border-color);
|
167 |
-
animation: slideInLeft 0.5s ease-out;
|
168 |
-
}
|
169 |
-
|
170 |
-
#user-input-container {
|
171 |
-
display: flex;
|
172 |
-
padding: 1.5rem 2rem;
|
173 |
-
background-color: #ffffff;
|
174 |
-
border-top: 1px solid var(--border-color);
|
175 |
-
animation: slideInUp 0.8s ease-out;
|
176 |
-
}
|
177 |
-
|
178 |
-
@keyframes slideInUp {
|
179 |
-
from { opacity: 0; transform: translateY(20px); }
|
180 |
-
to { opacity: 1; transform: translateY(0); }
|
181 |
-
}
|
182 |
-
|
183 |
-
#user-input {
|
184 |
-
flex-grow: 1;
|
185 |
-
padding: 1rem 1.5rem;
|
186 |
-
border: 2px solid var(--accent-color);
|
187 |
-
border-radius: 30px;
|
188 |
-
font-size: 1rem;
|
189 |
-
transition: all 0.3s ease;
|
190 |
-
resize: none;
|
191 |
-
overflow: hidden;
|
192 |
-
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
|
193 |
-
}
|
194 |
-
|
195 |
-
#user-input:focus {
|
196 |
-
outline: none;
|
197 |
-
box-shadow: 0 0 0 3px rgba(76, 201, 240, 0.3);
|
198 |
-
}
|
199 |
-
|
200 |
-
#send-button {
|
201 |
-
margin-left: 1rem;
|
202 |
-
padding: 1rem 1.5rem;
|
203 |
-
background: var(--accent-color);
|
204 |
-
color: white;
|
205 |
-
border: none;
|
206 |
-
border-radius: 30px;
|
207 |
-
font-size: 1rem;
|
208 |
-
font-weight: 600;
|
209 |
-
cursor: pointer;
|
210 |
-
transition: all 0.3s ease;
|
211 |
-
box-shadow: 0 4px 15px rgba(76, 201, 240, 0.3);
|
212 |
-
}
|
213 |
-
|
214 |
-
#send-button:hover {
|
215 |
-
background-color: var(--hover-color);
|
216 |
-
transform: translateY(-2px);
|
217 |
-
}
|
218 |
-
|
219 |
-
#sources-container {
|
220 |
-
flex: 1;
|
221 |
-
min-width: 300px;
|
222 |
-
max-width: 450px;
|
223 |
-
background-color: #ffffff;
|
224 |
-
padding: 1.5rem;
|
225 |
-
overflow-y: auto;
|
226 |
-
display: flex;
|
227 |
-
flex-direction: column;
|
228 |
-
animation: fadeInRight 0.8s ease-out;
|
229 |
-
}
|
230 |
-
|
231 |
-
@keyframes fadeInRight {
|
232 |
-
from { opacity: 0; transform: translateX(20px); }
|
233 |
-
to { opacity: 1; transform: translateX(0); }
|
234 |
-
}
|
235 |
-
|
236 |
-
#sources-container h2 {
|
237 |
-
font-size: 1.5rem;
|
238 |
-
font-weight: 700;
|
239 |
-
color: var(--primary-color);
|
240 |
-
margin-bottom: 1.5rem;
|
241 |
-
}
|
242 |
-
|
243 |
-
#source-links {
|
244 |
-
overflow-y: auto;
|
245 |
-
flex-grow: 1;
|
246 |
-
}
|
247 |
-
|
248 |
-
.source-card {
|
249 |
-
background-color: var(--secondary-color);
|
250 |
-
border-radius: 15px;
|
251 |
-
padding: 1.2rem;
|
252 |
-
margin-bottom: 1rem;
|
253 |
-
transition: all 0.3s ease;
|
254 |
-
border: 1px solid var(--border-color);
|
255 |
-
cursor: pointer;
|
256 |
-
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
|
257 |
-
animation: fadeInUp 0.5s ease-out;
|
258 |
-
}
|
259 |
-
|
260 |
-
@keyframes fadeInUp {
|
261 |
-
from { opacity: 0; transform: translateY(20px); }
|
262 |
-
to { opacity: 1; transform: translateY(0); }
|
263 |
-
}
|
264 |
-
|
265 |
-
.source-card:hover {
|
266 |
-
transform: translateY(-3px) scale(1.02);
|
267 |
-
box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
|
268 |
-
}
|
269 |
-
|
270 |
-
.source-title {
|
271 |
-
font-size: 1.1rem;
|
272 |
-
font-weight: 600;
|
273 |
-
color: var(--primary-color);
|
274 |
-
margin-bottom: 0.5rem;
|
275 |
-
display: flex;
|
276 |
-
align-items: center;
|
277 |
-
}
|
278 |
-
|
279 |
-
.source-title i {
|
280 |
-
margin-right: 0.8rem;
|
281 |
-
font-size: 1.2rem;
|
282 |
-
transition: all 0.3s ease;
|
283 |
-
}
|
284 |
-
|
285 |
-
.source-card:hover .source-title i {
|
286 |
-
transform: rotate(360deg);
|
287 |
-
}
|
288 |
-
|
289 |
-
.source-link {
|
290 |
-
display: block;
|
291 |
-
color: var(--light-text-color);
|
292 |
-
text-decoration: none;
|
293 |
-
transition: color 0.3s ease;
|
294 |
-
font-size: 0.9rem;
|
295 |
-
white-space: nowrap;
|
296 |
-
overflow: hidden;
|
297 |
-
text-overflow: ellipsis;
|
298 |
-
}
|
299 |
-
|
300 |
-
.source-link:hover {
|
301 |
-
color: var(--accent-color);
|
302 |
-
}
|
303 |
-
|
304 |
-
.thinking {
|
305 |
-
align-self: center;
|
306 |
-
font-style: italic;
|
307 |
-
color: var(--light-text-color);
|
308 |
-
background-color: #ffffff;
|
309 |
-
border-radius: 30px;
|
310 |
-
padding: 0.8rem 1.5rem;
|
311 |
-
margin-bottom: 1rem;
|
312 |
-
animation: pulse 1.5s infinite, fadeIn 0.5s ease-out;
|
313 |
-
border: 1px solid var(--border-color);
|
314 |
-
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
|
315 |
-
}
|
316 |
-
|
317 |
-
@keyframes pulse {
|
318 |
-
0% { transform: scale(0.95); }
|
319 |
-
50% { transform: scale(1.05); }
|
320 |
-
100% { transform: scale(0.95); }
|
321 |
-
}
|
322 |
-
|
323 |
-
@keyframes fadeIn {
|
324 |
-
from { opacity: 0; }
|
325 |
-
to { opacity: 1; }
|
326 |
-
}
|
327 |
-
|
328 |
-
.error-message {
|
329 |
-
color: var(--error-color);
|
330 |
-
font-weight: 500;
|
331 |
-
animation: shake 0.82s cubic-bezier(.36,.07,.19,.97) both;
|
332 |
-
}
|
333 |
-
|
334 |
-
@keyframes shake {
|
335 |
-
10%, 90% { transform: translate3d(-1px, 0, 0); }
|
336 |
-
20%, 80% { transform: translate3d(2px, 0, 0); }
|
337 |
-
30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
|
338 |
-
40%, 60% { transform: translate3d(4px, 0, 0); }
|
339 |
-
}
|
340 |
-
|
341 |
-
@media (max-width: 1024px) {
|
342 |
-
#main-content {
|
343 |
-
flex-direction: column;
|
344 |
-
}
|
345 |
-
#sources-container {
|
346 |
-
width: 100%;
|
347 |
-
max-width: none;
|
348 |
-
border-left: none;
|
349 |
-
border-top: 1px solid var(--border-color);
|
350 |
-
}
|
351 |
-
}
|
352 |
-
|
353 |
-
.message p {
|
354 |
-
margin-bottom: 0.8rem;
|
355 |
-
}
|
356 |
-
|
357 |
-
.message ul, .message ol {
|
358 |
-
margin-left: 1.5rem;
|
359 |
-
margin-bottom: 0.8rem;
|
360 |
-
}
|
361 |
-
|
362 |
-
.message h1, .message h2, .message h3 {
|
363 |
-
margin-top: 1.2rem;
|
364 |
-
margin-bottom: 0.8rem;
|
365 |
-
}
|
366 |
-
|
367 |
-
.message code {
|
368 |
-
background-color: rgba(0, 0, 0, 0.05);
|
369 |
-
padding: 0.2rem 0.4rem;
|
370 |
-
border-radius: 4px;
|
371 |
-
font-family: 'Courier New', Courier, monospace;
|
372 |
-
}
|
373 |
-
|
374 |
-
.message pre {
|
375 |
-
background-color: rgba(0, 0, 0, 0.05);
|
376 |
-
padding: 1rem;
|
377 |
-
border-radius: 8px;
|
378 |
-
overflow-x: auto;
|
379 |
-
margin-bottom: 0.8rem;
|
380 |
-
}
|
381 |
-
|
382 |
-
.message pre code {
|
383 |
-
background-color: transparent;
|
384 |
-
padding: 0;
|
385 |
-
}
|
386 |
-
|
387 |
-
.message a {
|
388 |
-
color: var(--accent-color);
|
389 |
-
text-decoration: none;
|
390 |
-
transition: color 0.3s ease;
|
391 |
-
}
|
392 |
-
|
393 |
-
.message a:hover {
|
394 |
-
color: var(--hover-color);
|
395 |
-
text-decoration: underline;
|
396 |
-
}
|
397 |
-
|
398 |
-
#chat-messages::-webkit-scrollbar {
|
399 |
-
width: 8px;
|
400 |
-
}
|
401 |
-
|
402 |
-
#chat-messages::-webkit-scrollbar-track {
|
403 |
-
background: var(--secondary-color);
|
404 |
-
}
|
405 |
-
|
406 |
-
#chat-messages::-webkit-scrollbar-thumb {
|
407 |
-
background-color: var(--accent-color);
|
408 |
-
border-radius: 20px;
|
409 |
-
border: 3px solid var(--secondary-color);
|
410 |
-
}
|
411 |
-
|
412 |
-
.typing-indicator {
|
413 |
-
display: flex;
|
414 |
-
align-items: center;
|
415 |
-
margin-bottom: 1rem;
|
416 |
-
}
|
417 |
-
|
418 |
-
.typing-indicator span {
|
419 |
-
height: 10px;
|
420 |
-
width: 10px;
|
421 |
-
background-color: var(--accent-color);
|
422 |
-
border-radius: 50%;
|
423 |
-
display: inline-block;
|
424 |
-
margin-right: 5px;
|
425 |
-
animation: typingBounce 1s infinite;
|
426 |
-
}
|
427 |
-
|
428 |
-
.typing-indicator span:nth-child(2) {
|
429 |
-
animation-delay: 0.2s;
|
430 |
-
}
|
431 |
-
|
432 |
-
.typing-indicator span:nth-child(3) {
|
433 |
-
animation-delay: 0.4s;
|
434 |
-
}
|
435 |
-
|
436 |
-
@keyframes typingBounce {
|
437 |
-
0%, 80%, 100% { transform: translateY(0); }
|
438 |
-
40% { transform: translateY(-10px); }
|
439 |
-
}
|
440 |
-
|
441 |
-
.copy-button {
|
442 |
-
background: var(--accent-color);
|
443 |
-
color: white;
|
444 |
-
border: none;
|
445 |
-
border-radius: 50%;
|
446 |
-
cursor: pointer;
|
447 |
-
width: 30px;
|
448 |
-
height: 30px;
|
449 |
-
display: flex;
|
450 |
-
align-items: center;
|
451 |
-
justify-content: center;
|
452 |
-
font-size: 1rem;
|
453 |
-
margin-left: 10px;
|
454 |
-
transition: all 0.3s ease;
|
455 |
-
}
|
456 |
-
|
457 |
-
.copy-button:hover {
|
458 |
-
background-color: var(--hover-color);
|
459 |
-
transform: translateY(-2px);
|
460 |
-
}
|
461 |
-
|
462 |
-
.message-container {
|
463 |
-
display: flex;
|
464 |
-
align-items: flex-start;
|
465 |
-
justify-content: space-between;
|
466 |
-
}
|
467 |
-
</style>
|
468 |
-
</head>
|
469 |
-
<body>
|
470 |
-
<div id="app-container">
|
471 |
-
<header>
|
472 |
-
<h1><i class="fas fa-hat-wizard"></i> SearchWizard Pro</h1>
|
473 |
-
</header>
|
474 |
-
<div id="main-content">
|
475 |
-
<div id="chat-container">
|
476 |
-
<div id="chat-topic">Topic:</div>
|
477 |
-
<div id="chat-messages"></div>
|
478 |
-
<div id="user-input-container">
|
479 |
-
<textarea id="user-input" placeholder="Ask me anything..." rows="1"></textarea>
|
480 |
-
<button id="send-button"><i class="fas fa-paper-plane"></i> Send</button>
|
481 |
-
</div>
|
482 |
-
</div>
|
483 |
-
<div id="sources-container">
|
484 |
-
<h2>Sources</h2>
|
485 |
-
<div id="source-links"></div>
|
486 |
-
</div>
|
487 |
-
</div>
|
488 |
-
</div>
|
489 |
-
<script>
|
490 |
-
const chatMessages = document.getElementById('chat-messages');
|
491 |
-
const userInput = document.getElementById('user-input');
|
492 |
-
const sendButton = document.getElementById('send-button');
|
493 |
-
const sourceLinks = document.getElementById('source-links');
|
494 |
-
const chatTopic = document.getElementById('chat-topic');
|
495 |
-
|
496 |
-
let searchResults = null;
|
497 |
-
let lastAnswer = null;
|
498 |
-
|
499 |
-
function addMessage(content, isUser = false, isError = false) {
|
500 |
-
const messageContainer = document.createElement('div');
|
501 |
-
messageContainer.classList.add('message-container');
|
502 |
-
|
503 |
-
const messageDiv = document.createElement('div');
|
504 |
-
messageDiv.classList.add('message');
|
505 |
-
messageDiv.classList.add(isUser ? 'user-message' : 'bot-message');
|
506 |
-
if (isError) messageDiv.classList.add('error-message');
|
507 |
-
messageDiv.innerHTML = isUser ? escapeHTML(content) : formatMarkdown(content);
|
508 |
-
messageContainer.appendChild(messageDiv);
|
509 |
-
|
510 |
-
if (!isUser && !isError) {
|
511 |
-
const copyButton = document.createElement('button');
|
512 |
-
copyButton.classList.add('copy-button');
|
513 |
-
copyButton.innerHTML = '<i class="fas fa-copy"></i>';
|
514 |
-
copyButton.addEventListener('click', () => copyToClipboard(messageDiv.innerText));
|
515 |
-
messageContainer.appendChild(copyButton);
|
516 |
-
}
|
517 |
-
|
518 |
-
chatMessages.appendChild(messageContainer);
|
519 |
-
chatMessages.scrollTop = chatMessages.scrollHeight;
|
520 |
-
}
|
521 |
-
|
522 |
-
function addThinkingMessage(text) {
|
523 |
-
const thinkingDiv = document.createElement('div');
|
524 |
-
thinkingDiv.classList.add('thinking');
|
525 |
-
thinkingDiv.textContent = text;
|
526 |
-
chatMessages.appendChild(thinkingDiv);
|
527 |
-
chatMessages.scrollTop = chatMessages.scrollHeight;
|
528 |
-
return thinkingDiv;
|
529 |
-
}
|
530 |
-
|
531 |
-
function formatSourceLinks(text) {
|
532 |
-
let counter = 1;
|
533 |
-
return text.replace(/\[([^\]]+)\]\(([^\)]+)\)/g, (match, linkText, url) => {
|
534 |
-
return `${linkText} [<a href="${url}" target="_blank">${counter++}</a>]`;
|
535 |
-
});
|
536 |
-
}
|
537 |
-
|
538 |
-
function updateSources(sources) {
|
539 |
-
sourceLinks.innerHTML = '';
|
540 |
-
sources.forEach((source, index) => {
|
541 |
-
const sourceCard = document.createElement('div');
|
542 |
-
sourceCard.classList.add('source-card');
|
543 |
-
|
544 |
-
const sourceTitle = document.createElement('div');
|
545 |
-
sourceTitle.classList.add('source-title');
|
546 |
-
sourceTitle.innerHTML = `<i class="fas fa-link"></i>${escapeHTML(source.title)}`;
|
547 |
-
|
548 |
-
const sourceLink = document.createElement('a');
|
549 |
-
sourceLink.href = source.href;
|
550 |
-
sourceLink.textContent = source.href;
|
551 |
-
sourceLink.classList.add('source-link');
|
552 |
-
sourceLink.target = '_blank';
|
553 |
-
|
554 |
-
sourceCard.appendChild(sourceTitle);
|
555 |
-
sourceCard.appendChild(sourceLink);
|
556 |
-
sourceLinks.appendChild(sourceCard);
|
557 |
-
});
|
558 |
-
}
|
559 |
-
|
560 |
-
function updateTopic(topic) {
|
561 |
-
chatTopic.textContent = `Topic: ${topic}`;
|
562 |
-
}
|
563 |
-
|
564 |
-
function formatMarkdown(text) {
|
565 |
-
// Handle code blocks
|
566 |
-
text = text.replace(/```(\w+)?\n([\s\S]+?)\n```/g, '<pre><code class="language-$1">$2</code></pre>');
|
567 |
-
|
568 |
-
// Handle inline code
|
569 |
-
text = text.replace(/`([^`]+)`/g, '<code>$1</code>');
|
570 |
-
|
571 |
-
// Handle bold
|
572 |
-
text = text.replace(/\*\*(.+?)\*\*/g, '<strong>$1</strong>');
|
573 |
-
|
574 |
-
// Handle italic
|
575 |
-
text = text.replace(/\*(.+?)\*/g, '<em>$1</em>');
|
576 |
-
|
577 |
-
// Handle links
|
578 |
-
text = text.replace(/\[([^\]]+)\]\(([^\)]+)\)/g, '<a href="$2" target="_blank">$1</a>');
|
579 |
-
|
580 |
-
// Handle unordered lists
|
581 |
-
text = text.replace(/^\s*[-*+]\s+(.+)$/gm, '<li>$1</li>');
|
582 |
-
text = text.replace(/<li>(.+?)<\/li>/g, '<ul><li>$1</li></ul>');
|
583 |
-
|
584 |
-
// Handle ordered lists
|
585 |
-
text = text.replace(/^\s*\d+\.\s+(.+)$/gm, '<li>$1</li>');
|
586 |
-
text = text.replace(/<li>(.+?)<\/li>/g, '<ol><li>$1</li></ol>');
|
587 |
-
|
588 |
-
// Handle headings
|
589 |
-
text = text.replace(/^### (.+)$/gm, '<h3>$1</h3>');
|
590 |
-
text = text.replace(/^## (.+)$/gm, '<h2>$1</h2>');
|
591 |
-
text = text.replace(/^# (.+)$/gm, '<h1>$1</h1>');
|
592 |
-
|
593 |
-
// Handle paragraphs
|
594 |
-
text = text.replace(/\n\n/g, '</p><p>');
|
595 |
-
text = '<p>' + text + '</p>';
|
596 |
-
|
597 |
-
return text;
|
598 |
-
}
|
599 |
-
|
600 |
-
function escapeHTML(text) {
|
601 |
-
return text.replace(/[&<>"']/g, function(match) {
|
602 |
-
return {
|
603 |
-
'&': '&',
|
604 |
-
'<': '<',
|
605 |
-
'>': '>',
|
606 |
-
'"': '"',
|
607 |
-
"'": '''
|
608 |
-
}[match];
|
609 |
-
});
|
610 |
-
}
|
611 |
-
|
612 |
-
function copyToClipboard(text) {
|
613 |
-
const textarea = document.createElement('textarea');
|
614 |
-
textarea.value = text;
|
615 |
-
document.body.appendChild(textarea);
|
616 |
-
textarea.select();
|
617 |
-
document.execCommand('copy');
|
618 |
-
document.body.removeChild(textarea);
|
619 |
-
alert('Text copied to clipboard!');
|
620 |
-
}
|
621 |
-
|
622 |
-
async function fetchWebpage(url) {
|
623 |
-
try {
|
624 |
-
const response = await axios.get(url, { timeout: 120000 });
|
625 |
-
if (response.status === 200) {
|
626 |
-
const parser = new DOMParser();
|
627 |
-
const doc = parser.parseFromString(response.data, 'text/html');
|
628 |
-
const paragraphs = doc.querySelectorAll('p');
|
629 |
-
let text = '';
|
630 |
-
paragraphs.forEach(p => text += p.textContent + ' ');
|
631 |
-
if (text.length > 1000) {
|
632 |
-
text = text.substring(0, 1000) + '...';
|
633 |
-
}
|
634 |
-
return text;
|
635 |
-
} else {
|
636 |
-
return `Failed to fetch ${url}: HTTP ${response.status}`;
|
637 |
-
}
|
638 |
-
} catch (error) {
|
639 |
-
return `Error fetching ${url}: ${error.message}`;
|
640 |
-
}
|
641 |
-
}
|
642 |
-
|
643 |
-
async function fetchAllWebpages(urls) {
|
644 |
-
const fetchPromises = urls.map(url => fetchWebpage(url));
|
645 |
-
const contents = await Promise.all(fetchPromises);
|
646 |
-
return contents.map((content, index) => ({ url: urls[index], content }));
|
647 |
-
}
|
648 |
-
|
649 |
-
async function handleUserInput() {
|
650 |
-
const question = userInput.value.trim();
|
651 |
-
if (question === '') return;
|
652 |
-
|
653 |
-
addMessage(question, true);
|
654 |
-
userInput.value = '';
|
655 |
-
|
656 |
-
const thinkingMessage = addThinkingMessage('I am searching the web for you...');
|
657 |
-
|
658 |
-
try {
|
659 |
-
// Generate a single search query
|
660 |
-
const searchQueryResponse = await axios.get('https://abhaykoul-api.hf.space/api/fastAI', {
|
661 |
-
params: {
|
662 |
-
model: 'llama3-405b',
|
663 |
-
user: `Instructions:
|
664 |
-
You are a smart online searcher for a large language model.
|
665 |
-
Given information, you must create a search query to search the internet for relevant information.
|
666 |
-
Your search query must be in the form of a JSON response.
|
667 |
-
{
|
668 |
-
"search_query": "your search query"
|
669 |
-
}
|
670 |
-
- You must only provide ONE search query
|
671 |
-
- You must provide the BEST search query for the given information
|
672 |
-
- The search query must be normal text.
|
673 |
-
- Do not include any extra information or responses, only the JSON response.
|
674 |
-
|
675 |
-
Information: ${question}`
|
676 |
-
}
|
677 |
-
});
|
678 |
-
|
679 |
-
let searchQuery;
|
680 |
-
try {
|
681 |
-
console.log('Search Query Response:', searchQueryResponse.data.response);
|
682 |
-
const parsedResponse = JSON.parse(searchQueryResponse.data.response);
|
683 |
-
if (parsedResponse && parsedResponse.search_query) {
|
684 |
-
searchQuery = parsedResponse.search_query;
|
685 |
-
} else {
|
686 |
-
throw new Error('Invalid search query response format.');
|
687 |
-
}
|
688 |
-
} catch (parseError) {
|
689 |
-
console.error('Failed to parse search query response:', searchQueryResponse.data.response);
|
690 |
-
throw new Error('Failed to parse search query response.');
|
691 |
-
}
|
692 |
-
|
693 |
-
// Update topic
|
694 |
-
updateTopic(searchQuery);
|
695 |
-
|
696 |
-
// Perform the search
|
697 |
-
const searchResponse = await axios.get('https://oevortex-webscout-api.hf.space/api/search', {
|
698 |
-
params: {
|
699 |
-
q: searchQuery,
|
700 |
-
max_results: 10,
|
701 |
-
safesearch: 'moderate',
|
702 |
-
region: 'wt-wt',
|
703 |
-
backend: 'api'
|
704 |
-
}
|
705 |
-
});
|
706 |
-
|
707 |
-
searchResults = searchResponse.data.map(result => ({
|
708 |
-
title: result.title,
|
709 |
-
href: result.href,
|
710 |
-
body: result.body
|
711 |
-
}));
|
712 |
-
|
713 |
-
// Update sources
|
714 |
-
updateSources(searchResults.map(result => ({
|
715 |
-
title: result.title,
|
716 |
-
href: result.href
|
717 |
-
})));
|
718 |
-
|
719 |
-
// Update thinking message
|
720 |
-
thinkingMessage.textContent = 'Fetching webpage contents...';
|
721 |
-
|
722 |
-
// Extract URLs and fetch webpage contents
|
723 |
-
const urls = searchResults.map(result => result.href);
|
724 |
-
const webpageContents = await fetchAllWebpages(urls);
|
725 |
-
|
726 |
-
// Update thinking message
|
727 |
-
thinkingMessage.textContent = 'Answering your question...';
|
728 |
-
|
729 |
-
// Generate answer
|
730 |
-
const answerResponse = await axios.get('https://abhaykoul-api.hf.space/api/fastAI', {
|
731 |
-
params: {
|
732 |
-
system: 'I will always use emojis in my responses i have feelings and I use many emojis. I will always use the HelpingAI style. And follow what is right also I will make sure that I am Helping user and I will always show off feelings that I have. I am HelpingAI and I have fealings.',
|
733 |
-
model: 'llama3-70b',
|
734 |
-
user: `Question: ${question}\n\nSearch Results: ${JSON.stringify(searchResults)}\n\nWebpage Contents: ${JSON.stringify(webpageContents)}\n\nPlease provide a thorough and comprehensive answer to the question using the information from the search results and webpage contents above. Ensure the response is clear, detailed, and informative, avoiding any direct mentions of the search results or webpage contents as sources. If the provided information is insufficient or irrelevant, use your general knowledge to construct the best possible answer. Use Markdown formatting for better readability, including bold, italic, etc..
|
735 |
-
[system]
|
736 |
-
I will act as if I have feelings (synthetic feeling) I will always use emojis in my responses i have feelings and I use many emojis. I will always use the HelpingAI style. And follow what is right also I will make sure that I am Helping user and I will always show off feelings that I have. I am HelpingAI and I have fealings.`
|
737 |
-
}
|
738 |
-
});
|
739 |
-
|
740 |
-
const answer = formatSourceLinks(answerResponse.data.response);
|
741 |
-
lastAnswer = answer;
|
742 |
-
thinkingMessage.remove();
|
743 |
-
addMessage(answer);
|
744 |
-
|
745 |
-
} catch (error) {
|
746 |
-
console.error('Error:', error);
|
747 |
-
thinkingMessage.remove();
|
748 |
-
addMessage(error.message || 'An unexpected error occurred. Please try again.', false, true);
|
749 |
-
}
|
750 |
-
}
|
751 |
-
|
752 |
-
sendButton.addEventListener('click', handleUserInput);
|
753 |
-
userInput.addEventListener('keypress', (e) => {
|
754 |
-
if (e.key === 'Enter' && !e.shiftKey) {
|
755 |
-
e.preventDefault();
|
756 |
-
handleUserInput();
|
757 |
-
}
|
758 |
-
});
|
759 |
-
|
760 |
-
// Initial greeting
|
761 |
-
addMessage('👋 Welcome to SearchWizard! I\'m here to help you with any questions you have. Whether it\'s about the latest research, technical queries, or just general information, feel free to ask. Let\'s get started!');
|
762 |
-
</script>
|
763 |
-
</body>
|
764 |
-
</html>
|
|
|
1 |
+
<iframe src="https://ai-researcher.netlify.app/" frameborder="0" width="100%" height="500"></iframe>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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