Update static/index.html
Browse files- static/index.html +280 -175
static/index.html
CHANGED
@@ -1,185 +1,290 @@
|
|
1 |
<!DOCTYPE html>
|
2 |
-
<html
|
3 |
<head>
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
</head>
|
97 |
<body>
|
98 |
-
|
99 |
-
<div class="
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
</div>
|
117 |
-
|
118 |
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
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 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
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>
|