Ashrafb commited on
Commit
e2f91f5
1 Parent(s): d551a10

Update static/index.html

Browse files
Files changed (1) hide show
  1. static/index.html +280 -175
static/index.html CHANGED
@@ -1,185 +1,290 @@
1
  <!DOCTYPE html>
2
- <html lang="en">
3
  <head>
4
- <meta charset="UTF-8">
5
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
- <link rel="stylesheet" href="style.css">
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
- <link rel="preconnect" href="https://fonts.googleapis.com">
10
- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
11
- <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300&display=swap" rel="stylesheet">
12
- <title>Chatbot</title>
13
- <style>
14
- *{
15
- padding: 0;
16
- margin: 0;
17
- font-family: 'Poppins', sans-serif;
18
- box-sizing: border-box;
19
- }
20
-
21
- body{
22
- width: 100%;
23
- height: 100vh;
24
- background-color: #33343f;
25
- }
26
-
27
- .chat{
28
- display: flex;
29
- gap: 20px;
30
- padding: 25px;
31
- color: #fff;
32
- font-size: 15px;
33
- font-weight: 300;
34
- }
35
-
36
- .chat img{
37
- width: 35px;
38
- height: 35px;
39
- }
40
-
41
- .response{
42
- background-color: #494b59;
43
- }
44
-
45
- .messagebar{
46
- position: fixed;
47
- bottom: 0;
48
- height: 5rem;
49
- width: 100%;
50
- display: flex;
51
- align-items: center;
52
- justify-content: center;
53
- border-top: 1px solid #494b59;
54
- background-color: #33343f;
55
- }
56
-
57
- .messagebar .bar-wrapper{
58
- background-color: #494b59;
59
- border-radius: 5px;
60
- width: 60vw;
61
- padding: 10px;
62
- display: flex;
63
- align-items: center;
64
- justify-content: space-between;
65
- }
66
-
67
- .bar-wrapper input{
68
- width: 100%;
69
- padding: 5px;
70
- border: none;
71
- outline: none;
72
- font-size: 14px;
73
- background: none;
74
- color: #ccc;
75
- }
76
-
77
- .bar-wrapper input::placeholder{
78
- color: #ccc;
79
- }
80
-
81
- .messagebar button{
82
- display: flex;
83
- align-items: center;
84
- justify-content: center;
85
- background: none;
86
- border: none;
87
- color: #fff;
88
- cursor: pointer;
89
- }
90
-
91
- .message-box{
92
- height: calc(100vh - 5rem);
93
- overflow-y: auto;
94
- }
95
- </style>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
  </head>
97
  <body>
98
- <div class="chatbox-wrapper">
99
- <div class="message-box">
100
- <div class="chat response">
101
- <img src="img/chatbot.jpg">
102
- <span>Hello there! <br>
103
- How can I help you today.
104
- </span>
105
- </div>
106
- </div>
107
- <div class="messagebar">
108
- <div class="bar-wrapper">
109
- <input type="text" placeholder="Enter your message...">
110
- <button>
111
- <span class="material-symbols-rounded">
112
- send
113
- </span>
114
- </button>
115
- </div>
 
 
 
 
 
 
 
 
 
 
 
116
  </div>
117
- </div>
118
 
119
- <script>
120
- const messageBar = document.querySelector(".bar-wrapper input");
121
- const sendBtn = document.querySelector(".bar-wrapper button");
122
- const messageBox = document.querySelector(".message-box");
123
-
124
- sendBtn.onclick = async function () {
125
- if (messageBar.value.length > 0) {
126
- const UserTypedMessage = messageBar.value;
127
- messageBar.value = "";
128
-
129
- let message =
130
- `<div class="chat message">
131
- <img src="img/user.jpg">
132
- <span>
133
- ${UserTypedMessage}
134
- </span>
135
- </div>`;
136
-
137
- let response =
138
- `<div class="chat response">
139
- <img src="img/chatbot.jpg">
140
- <span class="new">...
141
- </span>
142
- </div>`;
143
-
144
- messageBox.insertAdjacentHTML("beforeend", message);
145
- messageBox.insertAdjacentHTML("beforeend", response);
146
-
147
- const responseElement = document.querySelector(".response .new");
148
-
149
- const requestOptions = {
150
- method: "POST",
151
- headers: {
152
- "Content-Type": "application/x-www-form-urlencoded"
153
- },
154
- body: new URLSearchParams({
155
- prompt: UserTypedMessage,
156
- history: "[]", // Assuming no history for now
157
- })
158
- };
159
-
160
- try {
161
- const res = await fetch("/generate/", requestOptions);
162
- const reader = res.body.getReader();
163
- const decoder = new TextDecoder();
164
- let partialResponse = "";
165
 
166
- while (true) {
167
- const { value, done } = await reader.read();
168
- if (done) break;
169
- const chunk = decoder.decode(value);
170
- if (chunk.includes("[DONE]")) break;
171
- partialResponse += chunk;
172
- responseElement.innerText = partialResponse;
173
- }
174
 
175
- responseElement.classList.remove("new");
176
- } catch (error) {
177
- console.error("Error:", error);
178
- responseElement.innerText = "Oops! An error occurred. Please try again.";
179
- responseElement.classList.remove("new");
180
- }
181
- }
182
- };
183
- </script>
184
  </body>
185
  </html>
 
1
  <!DOCTYPE html>
2
+ <html>
3
  <head>
4
+ <title>Chatbot</title>
5
+ <link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
6
+ <script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
7
+ <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
8
+ <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
9
+ <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.5.0/css/all.css" integrity="sha384-B4dIYHKNBt8Bc12p+WXckhzcICo0wtJAoU8YZTY5qE0Id1GSseTk6S+L3BlXeVIU" crossorigin="anonymous">
10
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
11
+ <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='style.css')}}"/>
12
+ <style>
13
+ body,html{
14
+ height: 100%;
15
+ margin: 0;
16
+ background: rgb(44, 47, 59);
17
+ background: -webkit-linear-gradient(to right, rgb(40, 59, 34), rgb(54, 60, 70), rgb(32, 32, 43));
18
+ background: linear-gradient(to right, rgb(38, 51, 61), rgb(50, 55, 65), rgb(33, 33, 78));
19
+ }
20
+ .chat{
21
+ margin-top: auto;
22
+ margin-bottom: auto;
23
+ }
24
+ .card{
25
+ height: 500px;
26
+ border-radius: 15px !important;
27
+ background-color: rgba(0,0,0,0.4) !important;
28
+ }
29
+ .contacts_body{
30
+ padding: 0.75rem 0 !important;
31
+ overflow-y: auto;
32
+ white-space: nowrap;
33
+ }
34
+ .msg_card_body{
35
+ overflow-y: auto;
36
+ }
37
+ .card-header{
38
+ border-radius: 15px 15px 0 0 !important;
39
+ border-bottom: 0 !important;
40
+ }
41
+ .card-footer{
42
+ border-radius: 0 0 15px 15px !important;
43
+ border-top: 0 !important;
44
+ }
45
+ .container{
46
+ align-content: center;
47
+ }
48
+ .search{
49
+ border-radius: 15px 0 0 15px !important;
50
+ background-color: rgba(0,0,0,0.3) !important;
51
+ border:0 !important;
52
+ color:white !important;
53
+ }
54
+ .search:focus{
55
+ box-shadow:none !important;
56
+ outline:0px !important;
57
+ }
58
+ .type_msg{
59
+ background-color: rgba(0,0,0,0.3) !important;
60
+ border:0 !important;
61
+ color:white !important;
62
+ height: 60px !important;
63
+ overflow-y: auto;
64
+ }
65
+ .type_msg:focus{
66
+ box-shadow:none !important;
67
+ outline:0px !important;
68
+ }
69
+ .attach_btn{
70
+ border-radius: 15px 0 0 15px !important;
71
+ background-color: rgba(0,0,0,0.3) !important;
72
+ border:0 !important;
73
+ color: white !important;
74
+ cursor: pointer;
75
+ }
76
+ .send_btn{
77
+ border-radius: 0 15px 15px 0 !important;
78
+ background-color: rgba(0,0,0,0.3) !important;
79
+ border:0 !important;
80
+ color: white !important;
81
+ cursor: pointer;
82
+ }
83
+ .search_btn{
84
+ border-radius: 0 15px 15px 0 !important;
85
+ background-color: rgba(0,0,0,0.3) !important;
86
+ border:0 !important;
87
+ color: white !important;
88
+ cursor: pointer;
89
+ }
90
+ .contacts{
91
+ list-style: none;
92
+ padding: 0;
93
+ }
94
+ .contacts li{
95
+ width: 100% !important;
96
+ padding: 5px 10px;
97
+ margin-bottom: 15px !important;
98
+ }
99
+ .active{
100
+ background-color: rgba(0,0,0,0.3);
101
+ }
102
+ .user_img{
103
+ height: 70px;
104
+ width: 70px;
105
+ border:1.5px solid #f5f6fa;
106
+ }
107
+ .user_img_msg{
108
+ height: 40px;
109
+ width: 40px;
110
+ border:1.5px solid #f5f6fa;
111
+ }
112
+ .img_cont{
113
+ position: relative;
114
+ height: 70px;
115
+ width: 70px;
116
+ }
117
+ .img_cont_msg{
118
+ height: 40px;
119
+ width: 40px;
120
+ }
121
+ .online_icon{
122
+ position: absolute;
123
+ height: 15px;
124
+ width:15px;
125
+ background-color: #4cd137;
126
+ border-radius: 50%;
127
+ bottom: 0.2em;
128
+ right: 0.4em;
129
+ border:1.5px solid white;
130
+ }
131
+ .offline{
132
+ background-color: #c23616 !important;
133
+ }
134
+ .user_info{
135
+ margin-top: auto;
136
+ margin-bottom: auto;
137
+ margin-left: 15px;
138
+ }
139
+ .user_info span{
140
+ font-size: 20px;
141
+ color: white;
142
+ }
143
+ .user_info p{
144
+ font-size: 10px;
145
+ color: rgba(255,255,255,0.6);
146
+ }
147
+ .video_cam{
148
+ margin-left: 50px;
149
+ margin-top: 5px;
150
+ }
151
+ .video_cam span{
152
+ color: white;
153
+ font-size: 20px;
154
+ cursor: pointer;
155
+ margin-right: 20px;
156
+ }
157
+ .msg_cotainer{
158
+ margin-top: auto;
159
+ margin-bottom: auto;
160
+ margin-left: 10px;
161
+ border-radius: 25px;
162
+ background-color: rgb(82, 172, 255);
163
+ padding: 10px;
164
+ position: relative;
165
+ }
166
+ .msg_cotainer_send{
167
+ margin-top: auto;
168
+ margin-bottom: auto;
169
+ margin-right: 10px;
170
+ border-radius: 25px;
171
+ background-color: #58cc71;
172
+ padding: 10px;
173
+ position: relative;
174
+ }
175
+ .msg_time{
176
+ position: absolute;
177
+ left: 0;
178
+ bottom: -15px;
179
+ color: rgba(255,255,255,0.5);
180
+ font-size: 10px;
181
+ }
182
+ .msg_time_send{
183
+ position: absolute;
184
+ right:0;
185
+ bottom: -15px;
186
+ color: rgba(255,255,255,0.5);
187
+ font-size: 10px;
188
+ }
189
+ .msg_head{
190
+ position: relative;
191
+ }
192
+ #action_menu_btn{
193
+ position: absolute;
194
+ right: 10px;
195
+ top: 10px;
196
+ color: white;
197
+ cursor: pointer;
198
+ font-size: 20px;
199
+ }
200
+ .action_menu{
201
+ z-index: 1;
202
+ position: absolute;
203
+ padding: 15px 0;
204
+ background-color: rgba(0,0,0,0.5);
205
+ color: white;
206
+ border-radius: 15px;
207
+ top: 30px;
208
+ right: 15px;
209
+ display: none;
210
+ }
211
+ .action_menu ul{
212
+ list-style: none;
213
+ padding: 0;
214
+ margin: 0;
215
+ }
216
+ .action_menu ul li{
217
+ width: 100%;
218
+ padding: 10px 15px;
219
+ margin-bottom: 5px;
220
+ }
221
+ .action_menu ul li i{
222
+ padding-right: 10px;
223
+ }
224
+ .action_menu ul li:hover{
225
+ cursor: pointer;
226
+ background-color: rgba(0,0,0,0.2);
227
+ }
228
+ @media(max-width: 576px){
229
+ .contacts_card{
230
+ margin-bottom: 15px !important;
231
+ }
232
+ }
233
+ </style>
234
  </head>
235
  <body>
236
+ <div class="container-fluid h-100">
237
+ <div class="row justify-content-center h-100">
238
+ <div class="col-md-8 col-xl-6 chat">
239
+ <div class="card">
240
+ <div class="card-header msg_head">
241
+ <div class="d-flex bd-highlight">
242
+ <div class="img_cont">
243
+ <img src="https://i.ibb.co/fSNP7Rz/icons8-chatgpt-512.png" class="rounded-circle user_img">
244
+ <span class="online_icon"></span>
245
+ </div>
246
+ <div class="user_info">
247
+ <span>ChatBot</span>
248
+ <p>Ask me anything!</p>
249
+ </div>
250
+ </div>
251
+ </div>
252
+ <div id="messageFormeight" class="card-body msg_card_body">
253
+ <!-- Messages will be dynamically added here -->
254
+ </div>
255
+ <div class="card-footer">
256
+ <form id="messageArea" class="input-group" onsubmit="sendMessage(event)">
257
+ <input type="text" id="text" name="prompt" placeholder="Type your message..." autocomplete="off" class="form-control type_msg" required/>
258
+ <div class="input-group-append">
259
+ <button type="submit" id="send" class="input-group-text send_btn"><i class="fas fa-location-arrow"></i></button>
260
+ </div>
261
+ </form>
262
+ </div>
263
+ </div>
264
+ </div>
265
  </div>
266
+ </div>
267
 
268
+ <script>
269
+ async function sendMessage(event) {
270
+ event.preventDefault();
271
+ const formData = new FormData(document.getElementById('messageArea'));
272
+ const response = await fetch('/generate/', {
273
+ method: 'POST',
274
+ body: formData
275
+ });
276
+ const data = await response.json();
277
+ displayMessage(data.response, 'user');
278
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
279
 
280
+ function displayMessage(message, role) {
281
+ const msgContainer = document.getElementById('messageFormeight');
282
+ const msgDiv = document.createElement('div');
283
+ msgDiv.className = role === 'user' ? 'msg_cotainer' : 'msg_cotainer_send';
284
+ msgDiv.innerHTML = `<span class="msg">${message}</span><span class="${role === 'user' ? 'msg_time' : 'msg_time_send'}">Just now</span>`;
285
+ msgContainer.appendChild(msgDiv);
286
+ }
287
+ </script>
288
 
 
 
 
 
 
 
 
 
 
289
  </body>
290
  </html>