Ashrafb commited on
Commit
64bdc46
1 Parent(s): 56aeb34

Upload static_index (51).html

Browse files
Files changed (1) hide show
  1. static/static_index (51).html +528 -0
static/static_index (51).html ADDED
@@ -0,0 +1,528 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
342
+ </style>
343
+ </head>
344
+ <body>
345
+ <div class="chatbox-wrapper">
346
+ <div class="message-box">
347
+ <div class="chat response">
348
+ <img src="img/chatbot.jpg">
349
+ <span>Hello there! <br> How can I help you today.</span>
350
+ </div>
351
+ </div>
352
+ </div>
353
+ <!-- Chats container -->
354
+ <div class="chat-container"></div>
355
+
356
+ <!-- Typing container -->
357
+ <div class="typing-container">
358
+ <div class="typing-content">
359
+ <div class="typing-textarea">
360
+ <textarea id="chat-input" spellcheck="false" placeholder="Enter a prompt here" required></textarea>
361
+ <span id="send-btn" class="material-symbols-rounded">send</span>
362
+ </div>
363
+ <div class="typing-controls">
364
+ <span id="theme-btn" class="material-symbols-rounded">light_mode</span>
365
+ <span id="delete-btn" class="material-symbols-rounded">delete</span>
366
+
367
+ </div>
368
+ </div>
369
+ </div>
370
+
371
+ <script>
372
+ // Selecting DOM elements
373
+ const chatInput = document.querySelector("#chat-input");
374
+ const sendButton = document.querySelector("#send-btn");
375
+ const chatContainer = document.querySelector(".chat-container");
376
+ const themeButton = document.querySelector("#theme-btn");
377
+ const deleteButton = document.querySelector("#delete-btn");
378
+ const copyButton = document.querySelector("#copy-btn");
379
+
380
+ // Endpoint for fetching bot responses (replace with your actual endpoint URL)
381
+ const API_URL = "/generate/";
382
+
383
+ // Maintain chat history locally
384
+ let chatHistory = [];
385
+
386
+ // Load data from localStorage on page load
387
+ const loadDataFromLocalStorage = () => {
388
+ const themeColor = localStorage.getItem("themeColor");
389
+
390
+ document.body.classList.toggle("light-mode", themeColor === "light_mode");
391
+ themeButton.innerText = document.body.classList.contains("light-mode") ? "dark_mode" : "light_mode";
392
+
393
+ chatContainer.innerHTML = localStorage.getItem("all-chats") || '<div class="default-text"><h1>Welcome</h1><p>Start a conversation by typing a message.</p></div>';
394
+ chatContainer.scrollTo(0, chatContainer.scrollHeight);
395
+ }
396
+
397
+ // Function to create a chat message element
398
+ const createChatElement = (content, className) => {
399
+ const chatDiv = document.createElement("div");
400
+ chatDiv.classList.add("chat", className);
401
+ chatDiv.innerHTML = content;
402
+ return chatDiv;
403
+ }
404
+
405
+ // Function to fetch bot response from API
406
+ const getChatResponse = async (message) => {
407
+ try {
408
+ const response = await fetch(API_URL, {
409
+ method: "POST",
410
+ headers: {
411
+ "Content-Type": "application/x-www-form-urlencoded"
412
+ },
413
+ body: new URLSearchParams({
414
+ prompt: message,
415
+ history: "[]",
416
+ temperature: "0.9",
417
+ max_new_tokens: "512",
418
+ top_p: "0.95",
419
+ repetition_penalty: "1.0"
420
+ })
421
+ });
422
+
423
+ if (!response.ok) {
424
+ throw new Error(`HTTP error! Status: ${response.status}`);
425
+ }
426
+
427
+ const data = await response.json();
428
+ return data.response;
429
+ } catch (error) {
430
+ console.error("Error fetching data:", error);
431
+ return "Oops! Something went wrong while fetching the response.";
432
+ }
433
+ }
434
+
435
+ // Function to display user message and bot response
436
+ const showResponse = async (userMessage) => {
437
+ const userHtml = `<div class="chat-content">
438
+ <div class="chat-details">
439
+ <img src="img/user.jpg">
440
+ <p>${userMessage}</p>
441
+ </div>
442
+ </div>`;
443
+
444
+ const outgoingChatDiv = createChatElement(userHtml, "outgoing");
445
+ chatContainer.querySelector(".default-text")?.remove();
446
+ chatContainer.appendChild(outgoingChatDiv);
447
+ chatContainer.scrollTo(0, chatContainer.scrollHeight);
448
+
449
+ const botResponse = await getChatResponse(userMessage);
450
+
451
+ const botHtml = `<div class="chat-content">
452
+ <div class="chat-details">
453
+ <img src="img/chatbot.jpg">
454
+ <p contenteditable="true" class="copy-text">${botResponse}</p>
455
+ </div>
456
+ <span class="material-symbols-rounded copy-icon">content_copy</span>
457
+ </div>`;
458
+
459
+ const incomingChatDiv = createChatElement(botHtml, "incoming");
460
+ chatContainer.appendChild(incomingChatDiv);
461
+ chatContainer.scrollTo(0, chatContainer.scrollHeight);
462
+
463
+ // Update chat history
464
+ chatHistory.push([userMessage, botResponse]);
465
+ localStorage.setItem("all-chats", chatContainer.innerHTML);
466
+
467
+ // Copy to clipboard functionality
468
+ const copyIcons = document.querySelectorAll(".copy-icon");
469
+ copyIcons.forEach(copyIcon => {
470
+ copyIcon.addEventListener("click", () => {
471
+ const textToCopy = copyIcon.previousElementSibling.textContent;
472
+ navigator.clipboard.writeText(textToCopy);
473
+ copyIcon.textContent = "Copied";
474
+
475
+ setTimeout(() => {
476
+ copyIcon.textContent = "content_copy";
477
+ }, 1000);
478
+ });
479
+ });
480
+ }
481
+
482
+ // Event listener for sending messages
483
+ const handleOutgoingChat = () => {
484
+ const userMessage = chatInput.value.trim();
485
+ if (!userMessage) return;
486
+
487
+ chatInput.value = "";
488
+ chatInput.style.height = `${initialInputHeight}px`;
489
+
490
+ showResponse(userMessage);
491
+ }
492
+
493
+ // Event listeners
494
+ sendButton.addEventListener("click", handleOutgoingChat);
495
+
496
+ deleteButton.addEventListener("click", () => {
497
+ localStorage.removeItem("all-chats");
498
+ loadDataFromLocalStorage();
499
+ });
500
+
501
+ themeButton.addEventListener("click", () => {
502
+ document.body.classList.toggle("light-mode");
503
+ localStorage.setItem("themeColor", themeButton.innerText);
504
+ themeButton.innerText = document.body.classList.contains("light-mode") ? "dark_mode" : "light_mode";
505
+ });
506
+
507
+ // Initial input height calculation
508
+ const initialInputHeight = chatInput.scrollHeight;
509
+
510
+ chatInput.addEventListener("input", () => {
511
+ chatInput.style.height = `${initialInputHeight}px`;
512
+ chatInput.style.height = `${chatInput.scrollHeight}px`;
513
+ });
514
+
515
+ chatInput.addEventListener("keydown", (e) => {
516
+ if (e.key === "Enter" && !e.shiftKey && window.innerWidth > 800) {
517
+ e.preventDefault();
518
+ handleOutgoingChat();
519
+ }
520
+ });
521
+
522
+ // Load data from localStorage on page load
523
+ loadDataFromLocalStorage();
524
+ </script>
525
+ </body>
526
+ </html>
527
+
528
+