Ashrafb commited on
Commit
b3a6ecc
1 Parent(s): d365f4d

Upload static_index (52).html

Browse files
Files changed (1) hide show
  1. static/static_index (52).html +533 -0
static/static_index (52).html ADDED
@@ -0,0 +1,533 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <!-- Coding By CodingNepal - www.codingnepalweb.com -->
3
+ <html lang="en" dir="ltr">
4
+ <head>
5
+ <meta charset="utf-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <!-- Google Fonts Link For Icons -->
8
+ <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200" />
9
+ <style>
10
+ /* Import Google font - Poppins */
11
+ @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600&display=swap');
12
+ * {
13
+ margin: 0;
14
+ padding: 0;
15
+ box-sizing: border-box;
16
+ font-family: "Poppins", sans-serif;
17
+ }
18
+ :root {
19
+ --text-color: #FFFFFF;
20
+ --icon-color: #ACACBE;
21
+ --icon-hover-bg: #5b5e71;
22
+ --placeholder-color: #dcdcdc;
23
+ --outgoing-chat-bg: #343541;
24
+ --incoming-chat-bg: #444654;
25
+ --outgoing-chat-border: #343541;
26
+ --incoming-chat-border: #444654;
27
+ }
28
+ .light-mode {
29
+ --text-color: #343541;
30
+ --icon-color: #a9a9bc;
31
+ --icon-hover-bg: #f1f1f3;
32
+ --placeholder-color: #6c6c6c;
33
+ --outgoing-chat-bg: #FFFFFF;
34
+ --incoming-chat-bg: #F7F7F8;
35
+ --outgoing-chat-border: #FFFFFF;
36
+ --incoming-chat-border: #D9D9E3;
37
+ }
38
+ body {
39
+ background: var(--outgoing-chat-bg);
40
+ }
41
+
42
+ /* Chats container styling */
43
+ .chat-container {
44
+ overflow-y: auto;
45
+ max-height: 100vh;
46
+ padding-bottom: 150px;
47
+ }
48
+ :where(.chat-container, textarea)::-webkit-scrollbar {
49
+ width: 6px;
50
+ }
51
+ :where(.chat-container, textarea)::-webkit-scrollbar-track {
52
+ background: var(--incoming-chat-bg);
53
+ border-radius: 25px;
54
+ }
55
+ :where(.chat-container, textarea)::-webkit-scrollbar-thumb {
56
+ background: var(--icon-color);
57
+ border-radius: 25px;
58
+ }
59
+ .default-text {
60
+ display: flex;
61
+ align-items: center;
62
+ justify-content: center;
63
+ flex-direction: column;
64
+ height: 70vh;
65
+ padding: 0 10px;
66
+ text-align: center;
67
+ color: var(--text-color);
68
+ }
69
+ .default-text h1 {
70
+ font-size: 3.3rem;
71
+ }
72
+ .default-text p {
73
+ margin-top: 10px;
74
+ font-size: 1.1rem;
75
+ }
76
+ .chat-container .chat {
77
+ padding: 25px 10px;
78
+ display: flex;
79
+ justify-content: center;
80
+ color: var(--text-color);
81
+ }
82
+ .chat-container .chat.outgoing {
83
+ background: var(--outgoing-chat-bg);
84
+ border: 1px solid var(--outgoing-chat-border);
85
+ }
86
+ .chat-container .chat.incoming {
87
+ background: var(--incoming-chat-bg);
88
+ border: 1px solid var(--incoming-chat-border);
89
+ }
90
+ .chat .chat-content {
91
+ display: flex;
92
+ max-width: 1200px;
93
+ width: 100%;
94
+ align-items: flex-start;
95
+ justify-content: space-between;
96
+ }
97
+ span.material-symbols-rounded {
98
+ user-select: none;
99
+ cursor: pointer;
100
+ }
101
+ .chat .chat-content span {
102
+ cursor: pointer;
103
+ font-size: 1.3rem;
104
+ color: var(--icon-color);
105
+ visibility: hidden;
106
+ }
107
+ .chat:hover .chat-content:not(:has(.typing-animation), :has(.error)) span {
108
+ visibility: visible;
109
+ }
110
+ .chat .chat-details {
111
+ display: flex;
112
+ align-items: center;
113
+ }
114
+ .chat .chat-details img {
115
+ width: 35px;
116
+ height: 35px;
117
+ align-self: flex-start;
118
+ object-fit: cover;
119
+ border-radius: 2px;
120
+ }
121
+ .chat .chat-details p {
122
+ white-space: pre-wrap;
123
+ font-size: 1.05rem;
124
+ padding: 0 50px 0 25px;
125
+ color: var(--text-color);
126
+ word-break: break-word;
127
+ }
128
+ .chat .chat-details p.error {
129
+ color: #e55865;
130
+ }
131
+ .chat .typing-animation {
132
+ padding-left: 25px;
133
+ display: inline-flex;
134
+ }
135
+ .typing-animation .typing-dot {
136
+ height: 7px;
137
+ width: 7px;
138
+ border-radius: 50%;
139
+ margin: 0 3px;
140
+ opacity: 0.7;
141
+ background: var(--text-color);
142
+ animation: animateDots 1.5s var(--delay) ease-in-out infinite;
143
+ }
144
+ .typing-animation .typing-dot:first-child {
145
+ margin-left: 0;
146
+ }
147
+ @keyframes animateDots {
148
+ 0%,
149
+ 44% {
150
+ transform: translateY(0px);
151
+ }
152
+ 28% {
153
+ opacity: 0.4;
154
+ transform: translateY(-6px);
155
+ }
156
+ 44% {
157
+ opacity: 0.2;
158
+ }
159
+ }
160
+
161
+ /* Typing container styling */
162
+ .typing-container {
163
+ position: fixed;
164
+ bottom: 0;
165
+ width: 100%;
166
+ display: flex;
167
+ padding: 20px 10px;
168
+ justify-content: center;
169
+ background: var(--outgoing-chat-bg);
170
+ border-top: 1px solid var(--incoming-chat-border);
171
+ }
172
+ .typing-container .typing-content {
173
+ display: flex;
174
+ max-width: 950px;
175
+ width: 100%;
176
+ align-items: flex-end;
177
+ }
178
+ .typing-container .typing-textarea {
179
+ width: 100%;
180
+ display: flex;
181
+ position: relative;
182
+ }
183
+ .typing-textarea textarea {
184
+ resize: none;
185
+ height: 55px;
186
+ width: 100%;
187
+ border: none;
188
+ padding: 15px 45px 15px 20px;
189
+ color: var(--text-color);
190
+ font-size: 1rem;
191
+ border-radius: 4px;
192
+ max-height: 250px;
193
+ overflow-y: auto;
194
+ background: var(--incoming-chat-bg);
195
+ outline: 1px solid var(--incoming-chat-border);
196
+ }
197
+ .typing-textarea textarea::placeholder {
198
+ color: var(--placeholder-color);
199
+ }
200
+ .typing-content span {
201
+ width: 55px;
202
+ height: 55px;
203
+ display: flex;
204
+ border-radius: 4px;
205
+ font-size: 1.35rem;
206
+ align-items: center;
207
+ justify-content: center;
208
+ color: var(--icon-color);
209
+ }
210
+ .typing-textarea span {
211
+ position: absolute;
212
+ right: 0;
213
+ bottom: 0;
214
+ visibility: hidden;
215
+ }
216
+ .typing-textarea textarea:valid ~ span {
217
+ visibility: visible;
218
+ }
219
+ .typing-controls {
220
+ display: flex;
221
+ }
222
+ .typing-controls span {
223
+ margin-left: 7px;
224
+ font-size: 1.4rem;
225
+ background: var(--incoming-chat-bg);
226
+ outline: 1px solid var(--incoming-chat-border);
227
+ }
228
+ .typing-controls span:hover {
229
+ background: var(--icon-hover-bg);
230
+ }
231
+
232
+ /* Reponsive Media Query */
233
+ @media screen and (max-width: 600px) {
234
+ .default-text h1 {
235
+ font-size: 2.3rem;
236
+ }
237
+ :where(.default-text p, textarea, .chat p) {
238
+ font-size: 0.95rem!important;
239
+ }
240
+ .chat-container .chat {
241
+ padding: 20px 10px;
242
+ }
243
+ .chat-container .chat img {
244
+ height: 32px;
245
+ width: 32px;
246
+ }
247
+ .chat-container .chat p {
248
+ padding: 0 20px;
249
+ }
250
+ .chat .chat-content:not(:has(.typing-animation), :has(.error)) span {
251
+ visibility: visible;
252
+ }
253
+ .typing-container {
254
+ padding: 15px 10px;
255
+ }
256
+ .typing-textarea textarea {
257
+ height: 45px;
258
+ padding: 10px 40px 10px 10px;
259
+ }
260
+ .typing-content span {
261
+ height: 45px;
262
+ width: 45px;
263
+ margin-left: 5px;
264
+ }
265
+ span.material-symbols-rounded {
266
+ font-size: 1.25rem!important;
267
+ }
268
+ }
269
+ /* New CSS style for "Text Copied" message */
270
+ .copied-message {
271
+ font-size: 0.5rem;
272
+ }
273
+ .message-box {
274
+ height: calc(50vh - 5rem);
275
+ overflow-y: auto;
276
+ }
277
+
278
+ .messagebar {
279
+ position: fixed;
280
+ bottom: 0;
281
+ height: 5rem;
282
+ width: 100%;
283
+ display: flex;
284
+ align-items: center;
285
+ justify-content: center;
286
+ border-top: 1px solid #494b59;
287
+ background-color: #33343f;
288
+ }
289
+ .messagebar .bar-wrapper {
290
+ background-color: #494b59;
291
+ border-radius: 5px;
292
+ width: 60vw;
293
+ padding: 10px;
294
+ display: flex;
295
+ align-items: center;
296
+ justify-content: space-between;
297
+ }
298
+ .bar-wrapper input {
299
+ width: 100%;
300
+ padding: 5px;
301
+ border: none;
302
+ outline: none;
303
+ font-size: 14px;
304
+ background: none;
305
+ color: #ccc;
306
+ }
307
+ .bar-wrapper input::placeholder {
308
+ color: #ccc;
309
+ }
310
+ .messagebar button {
311
+ display: flex;
312
+ align-items: center;
313
+ justify-content: center;
314
+ background: none;
315
+ border: none;
316
+ color: #fff;
317
+ cursor: pointer;
318
+ }
319
+ .message-box {
320
+ height: calc(100vh - 5rem);
321
+ overflow-y: auto;
322
+ }
323
+ .chat {
324
+ display: flex;
325
+ gap: 20px;
326
+ padding: 25px;
327
+ color: #fff;
328
+ font-size: 15px;
329
+ font-weight: 300;
330
+ }
331
+ .chat img {
332
+ width: 35px;
333
+ height: 35px;
334
+ }
335
+ .response {
336
+ background-color: #494b59;
337
+ }
338
+ .chatbox-wrapper {
339
+ margin-bottom: 0;
340
+ }
341
+ .copied-text {
342
+ font-size: 0.4rem; /* Adjust this size as needed */
343
+ }
344
+
345
+
346
+ </style>
347
+ </head>
348
+ <body>
349
+ <div class="chatbox-wrapper">
350
+ <div class="message-box">
351
+ <div class="chat response">
352
+ <img src="img/chatbot.jpg">
353
+ <span>Hello there! <br> How can I help you today.</span>
354
+ </div>
355
+
356
+ <!-- Chats container -->
357
+ <div class="chat-container"></div>
358
+
359
+ <!-- Typing container -->
360
+ <div class="typing-container">
361
+ <div class="typing-content">
362
+ <div class="typing-textarea">
363
+ <textarea id="chat-input" spellcheck="false" placeholder="Enter a prompt here" required></textarea>
364
+ <span id="send-btn" class="material-symbols-rounded">send</span>
365
+ </div>
366
+ <div class="typing-controls">
367
+ <span id="theme-btn" class="material-symbols-rounded">light_mode</span>
368
+ <span id="delete-btn" class="material-symbols-rounded">delete</span>
369
+
370
+ </div>
371
+ </div>
372
+ </div>
373
+ </div>
374
+ <script>
375
+ // Selecting DOM elements
376
+ const chatInput = document.querySelector("#chat-input");
377
+ const sendButton = document.querySelector("#send-btn");
378
+ const chatContainer = document.querySelector(".chat-container");
379
+ const themeButton = document.querySelector("#theme-btn");
380
+ const deleteButton = document.querySelector("#delete-btn");
381
+ const copyButton = document.querySelector("#copy-btn");
382
+
383
+ // Endpoint for fetching bot responses (replace with your actual endpoint URL)
384
+ const API_URL = "/generate/";
385
+
386
+ // Maintain chat history locally
387
+ let chatHistory = [];
388
+
389
+ // Load data from localStorage on page load
390
+ const loadDataFromLocalStorage = () => {
391
+ const themeColor = localStorage.getItem("themeColor");
392
+
393
+ document.body.classList.toggle("light-mode", themeColor === "light_mode");
394
+ themeButton.innerText = document.body.classList.contains("light-mode") ? "dark_mode" : "light_mode";
395
+
396
+ chatContainer.innerHTML = localStorage.getItem("all-chats") || '<div class="default-text"><h1>Welcome</h1><p>Start a conversation by typing a message.</p></div>';
397
+ chatContainer.scrollTo(0, chatContainer.scrollHeight);
398
+ }
399
+
400
+ // Function to create a chat message element
401
+ const createChatElement = (content, className) => {
402
+ const chatDiv = document.createElement("div");
403
+ chatDiv.classList.add("chat", className);
404
+ chatDiv.innerHTML = content;
405
+ return chatDiv;
406
+ }
407
+
408
+ // Function to fetch bot response from API
409
+ const getChatResponse = async (message) => {
410
+ try {
411
+ const response = await fetch(API_URL, {
412
+ method: "POST",
413
+ headers: {
414
+ "Content-Type": "application/x-www-form-urlencoded"
415
+ },
416
+ body: new URLSearchParams({
417
+ prompt: message,
418
+ history: "[]",
419
+ temperature: "0.9",
420
+ max_new_tokens: "512",
421
+ top_p: "0.95",
422
+ repetition_penalty: "1.0"
423
+ })
424
+ });
425
+
426
+ if (!response.ok) {
427
+ throw new Error(`HTTP error! Status: ${response.status}`);
428
+ }
429
+
430
+ const data = await response.json();
431
+ return data.response;
432
+ } catch (error) {
433
+ console.error("Error fetching data:", error);
434
+ return "Oops! Something went wrong while fetching the response.";
435
+ }
436
+ }
437
+
438
+ // Function to display user message and bot response
439
+ const showResponse = async (userMessage) => {
440
+ const userHtml = `<div class="chat-content">
441
+ <div class="chat-details">
442
+ <img src="img/user.jpg">
443
+ <p>${userMessage}</p>
444
+ </div>
445
+ </div>`;
446
+
447
+ const outgoingChatDiv = createChatElement(userHtml, "outgoing");
448
+ chatContainer.querySelector(".default-text")?.remove();
449
+ chatContainer.appendChild(outgoingChatDiv);
450
+ chatContainer.scrollTo(0, chatContainer.scrollHeight);
451
+
452
+ const botResponse = await getChatResponse(userMessage);
453
+
454
+ const botHtml = `<div class="chat-content">
455
+ <div class="chat-details">
456
+ <img src="img/chatbot.jpg"><span class="new">...</span>
457
+ <p contenteditable="false" class="copy-text">${botResponse}</p>
458
+ </div>
459
+ <span class="material-symbols-rounded copy-icon">content_copy</span>
460
+ </div>`;
461
+
462
+ const incomingChatDiv = createChatElement(botHtml, "incoming");
463
+ chatContainer.appendChild(incomingChatDiv);
464
+ chatContainer.scrollTo(0, chatContainer.scrollHeight);
465
+
466
+ // Update chat history
467
+ chatHistory.push([userMessage, botResponse]);
468
+ localStorage.setItem("all-chats", chatContainer.innerHTML);
469
+
470
+ // Copy to clipboard functionality
471
+ const copyIcons = document.querySelectorAll(".copy-icon");
472
+ copyIcons.forEach(copyIcon => {
473
+ copyIcon.addEventListener("click", () => {
474
+ const textToCopy = copyIcon.previousElementSibling.textContent;
475
+ navigator.clipboard.writeText(textToCopy);
476
+ copyIcon.textContent = "Copied";
477
+ copyIcon.classList.add("copied-text"); // Add the class for smaller text
478
+
479
+ setTimeout(() => {
480
+ copyIcon.textContent = "content_copy";
481
+ }, 1000);
482
+ });
483
+ });
484
+ }
485
+
486
+ // Event listener for sending messages
487
+ const handleOutgoingChat = () => {
488
+ const userMessage = chatInput.value.trim();
489
+ if (!userMessage) return;
490
+
491
+ chatInput.value = "";
492
+ chatInput.style.height = `${initialInputHeight}px`;
493
+
494
+ showResponse(userMessage);
495
+ }
496
+
497
+ // Event listeners
498
+ sendButton.addEventListener("click", handleOutgoingChat);
499
+
500
+ deleteButton.addEventListener("click", () => {
501
+ localStorage.removeItem("all-chats");
502
+ loadDataFromLocalStorage();
503
+ });
504
+
505
+ themeButton.addEventListener("click", () => {
506
+ document.body.classList.toggle("light-mode");
507
+ localStorage.setItem("themeColor", themeButton.innerText);
508
+ themeButton.innerText = document.body.classList.contains("light-mode") ? "dark_mode" : "light_mode";
509
+ });
510
+
511
+ // Initial input height calculation
512
+ const initialInputHeight = chatInput.scrollHeight;
513
+
514
+ chatInput.addEventListener("input", () => {
515
+ chatInput.style.height = `${initialInputHeight}px`;
516
+ chatInput.style.height = `${chatInput.scrollHeight}px`;
517
+ });
518
+
519
+ chatInput.addEventListener("keydown", (e) => {
520
+ if (e.key === "Enter" && !e.shiftKey && window.innerWidth > 800) {
521
+ e.preventDefault();
522
+ handleOutgoingChat();
523
+ }
524
+ });
525
+
526
+ // Load data from localStorage on page load
527
+ loadDataFromLocalStorage();
528
+ </script>
529
+ </body>
530
+ </html>
531
+
532
+
533
+