Spaces:
Paused
Paused
Update templates/think.html
Browse files- templates/think.html +317 -369
templates/think.html
CHANGED
|
@@ -1,370 +1,318 @@
|
|
| 1 |
-
<!DOCTYPE html>
|
| 2 |
-
<html lang="en">
|
| 3 |
-
|
| 4 |
-
<head>
|
| 5 |
-
<meta charset="UTF-8">
|
| 6 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 7 |
-
<title>Think | TaskBot v1+ AI</title>
|
| 8 |
-
<script src="https://kit.fontawesome.com/cda0e70b18.js" crossorigin="anonymous"></script>
|
| 9 |
-
<link rel="Icon" href="TaskBot logo.png">
|
| 10 |
-
<link rel="manifest" href="/static/manifest.json">
|
| 11 |
-
</head>
|
| 12 |
-
|
| 13 |
-
<style>
|
| 14 |
-
body {
|
| 15 |
-
background-color: #2f2f2f;
|
| 16 |
-
font-family: Arial, sans-serif;
|
| 17 |
-
color: white;
|
| 18 |
-
margin: 0;
|
| 19 |
-
padding: 20px;
|
| 20 |
-
background: url("{{ url_for('static', filename='images/black bg.jpeg') }}");
|
| 21 |
-
background-size: cover;
|
| 22 |
-
background-repeat: no-repeat;
|
| 23 |
-
background-size: cover;
|
| 24 |
-
background-attachment: fixed;
|
| 25 |
-
background-position: center center;
|
| 26 |
-
}
|
| 27 |
-
|
| 28 |
-
nav {
|
| 29 |
-
background-color: #444;
|
| 30 |
-
padding: 5px;
|
| 31 |
-
border-radius: 5px;
|
| 32 |
-
width: 100%;
|
| 33 |
-
height: auto;
|
| 34 |
-
top: 0;
|
| 35 |
-
}
|
| 36 |
-
|
| 37 |
-
.sticky {
|
| 38 |
-
position: absolute;
|
| 39 |
-
top: 20px;
|
| 40 |
-
right: 20px;
|
| 41 |
-
z-index: 1000;
|
| 42 |
-
}
|
| 43 |
-
|
| 44 |
-
.sticky2 {
|
| 45 |
-
position: absolute;
|
| 46 |
-
top: 20px;
|
| 47 |
-
right: 80px;
|
| 48 |
-
z-index: 1000;
|
| 49 |
-
}
|
| 50 |
-
|
| 51 |
-
.sticky3 {
|
| 52 |
-
position: absolute;
|
| 53 |
-
top: 20px;
|
| 54 |
-
right: 140px;
|
| 55 |
-
z-index: 1000;
|
| 56 |
-
}
|
| 57 |
-
|
| 58 |
-
/* Dropdown Styles */
|
| 59 |
-
.dropdown {
|
| 60 |
-
position: relative;
|
| 61 |
-
display: inline-block;
|
| 62 |
-
}
|
| 63 |
-
|
| 64 |
-
.btn {
|
| 65 |
-
background-color: transparent;
|
| 66 |
-
color: white;
|
| 67 |
-
border: none;
|
| 68 |
-
cursor: pointer;
|
| 69 |
-
}
|
| 70 |
-
|
| 71 |
-
.btn:hover {
|
| 72 |
-
background-color: #494949;
|
| 73 |
-
}
|
| 74 |
-
|
| 75 |
-
.dropdown-content {
|
| 76 |
-
display: none;
|
| 77 |
-
position: absolute;
|
| 78 |
-
right: 0;
|
| 79 |
-
background-color: transparent;
|
| 80 |
-
backdrop-filter: blur(5px);
|
| 81 |
-
border: 1px solid black;
|
| 82 |
-
min-width: 160px;
|
| 83 |
-
box-shadow: 0px 8px 16px rgba(0, 0, 0, 0.2);
|
| 84 |
-
z-index: 1;
|
| 85 |
-
text-align: center;
|
| 86 |
-
}
|
| 87 |
-
|
| 88 |
-
.dropdown-content h3 {
|
| 89 |
-
margin: 5px 0;
|
| 90 |
-
color: white;
|
| 91 |
-
text-align: center;
|
| 92 |
-
}
|
| 93 |
-
|
| 94 |
-
.dropdown-content a {
|
| 95 |
-
color: white;
|
| 96 |
-
padding: 12px 16px;
|
| 97 |
-
text-decoration: none;
|
| 98 |
-
display: block;
|
| 99 |
-
border-top: 1px solid transparent;
|
| 100 |
-
}
|
| 101 |
-
|
| 102 |
-
.dropdown-content a:hover {
|
| 103 |
-
background-color: #bebebe;
|
| 104 |
-
}
|
| 105 |
-
|
| 106 |
-
.dropdown:hover .dropdown-content {
|
| 107 |
-
display: block;
|
| 108 |
-
}
|
| 109 |
-
|
| 110 |
-
main {
|
| 111 |
-
display: flex;
|
| 112 |
-
flex-direction: column;
|
| 113 |
-
align-items: center;
|
| 114 |
-
justify-content: center;
|
| 115 |
-
height: calc(100vh - 100px);
|
| 116 |
-
/* adjust if header height changes */
|
| 117 |
-
text-align: center;
|
| 118 |
-
}
|
| 119 |
-
|
| 120 |
-
/* Input and Button Styles */
|
| 121 |
-
#question {
|
| 122 |
-
padding: 10px;
|
| 123 |
-
font-size: 16px;
|
| 124 |
-
border-radius: 5px;
|
| 125 |
-
border: 1px solid #ccc;
|
| 126 |
-
margin-right: 10px;
|
| 127 |
-
}
|
| 128 |
-
|
| 129 |
-
.ai,
|
| 130 |
-
.user {
|
| 131 |
-
background-color: transparent;
|
| 132 |
-
backdrop-filter: blur(5px);
|
| 133 |
-
padding: 10px;
|
| 134 |
-
padding-right: 10px;
|
| 135 |
-
border-radius: 5px;
|
| 136 |
-
border: solid #ccc;
|
| 137 |
-
margin: 10px;
|
| 138 |
-
text-align: center;
|
| 139 |
-
justify-content: right;
|
| 140 |
-
width: 40%;
|
| 141 |
-
color: rgb(227, 227, 227)
|
| 142 |
-
}
|
| 143 |
-
|
| 144 |
-
.text1 {
|
| 145 |
-
display: flex;
|
| 146 |
-
justify-content: right;
|
| 147 |
-
align-items: center;
|
| 148 |
-
margin: 10px;
|
| 149 |
-
}
|
| 150 |
-
|
| 151 |
-
.text2 {
|
| 152 |
-
display: flex;
|
| 153 |
-
justify-content: left;
|
| 154 |
-
align-items: center;
|
| 155 |
-
margin: 10px;
|
| 156 |
-
}
|
| 157 |
-
|
| 158 |
-
.chat-input-container {
|
| 159 |
-
display: flex;
|
| 160 |
-
align-items: center;
|
| 161 |
-
justify-content: center;
|
| 162 |
-
margin-top: 20px;
|
| 163 |
-
}
|
| 164 |
-
|
| 165 |
-
#sendButton {
|
| 166 |
-
margin-left: 10px;
|
| 167 |
-
padding: 10px 20px;
|
| 168 |
-
border: none;
|
| 169 |
-
border-radius: 5px;
|
| 170 |
-
background-color: #fff;
|
| 171 |
-
cursor: pointer;
|
| 172 |
-
transition: background-color 0.3s;
|
| 173 |
-
}
|
| 174 |
-
|
| 175 |
-
#sendButton:hover {
|
| 176 |
-
background-color: #e0e0e0;
|
| 177 |
-
}
|
| 178 |
-
|
| 179 |
-
.inputWrapper {
|
| 180 |
-
flex-direction: column;
|
| 181 |
-
align-items: center;
|
| 182 |
-
justify-content: center;
|
| 183 |
-
position: fixed;
|
| 184 |
-
bottom: 20px;
|
| 185 |
-
left: 50%;
|
| 186 |
-
transform: translateX(-50%);
|
| 187 |
-
display: flex;
|
| 188 |
-
gap: 10px;
|
| 189 |
-
z-index: 1000;
|
| 190 |
-
}
|
| 191 |
-
|
| 192 |
-
.inputWrapper input {
|
| 193 |
-
width: 100%;
|
| 194 |
-
padding: 10px;
|
| 195 |
-
}
|
| 196 |
-
|
| 197 |
-
.tools button {
|
| 198 |
-
font-size: 18px;
|
| 199 |
-
padding: 10px 20px;
|
| 200 |
-
border-radius: 50px;
|
| 201 |
-
cursor: pointer;
|
| 202 |
-
}
|
| 203 |
-
|
| 204 |
-
#welcomeMessage {
|
| 205 |
-
text-align: center;
|
| 206 |
-
margin-top: 20%;
|
| 207 |
-
}
|
| 208 |
-
|
| 209 |
-
.tools-content {
|
| 210 |
-
display: none;
|
| 211 |
-
|
| 212 |
-
}
|
| 213 |
-
|
| 214 |
-
.tools:hover {
|
| 215 |
-
.tools-content {
|
| 216 |
-
display: block
|
| 217 |
-
}
|
| 218 |
-
}
|
| 219 |
-
</style>
|
| 220 |
-
|
| 221 |
-
<body>
|
| 222 |
-
<H1 id="welcomeMessage">Hello 👋, what can I help with?</H1>
|
| 223 |
-
<div id="chatArea">
|
| 224 |
-
<div class="text1">
|
| 225 |
-
<div class="user" style="display: none;"></div>
|
| 226 |
-
</div>
|
| 227 |
-
<div class="text2">
|
| 228 |
-
<div class="ai" style="display: none;"></div>
|
| 229 |
-
</div>
|
| 230 |
-
</div>
|
| 231 |
-
|
| 232 |
-
<main>
|
| 233 |
-
<div class="inputWrapper">
|
| 234 |
-
<input type="text" id="userInput" placeholder="Type your message here..."
|
| 235 |
-
style="width: 200px;color: white; backdrop-filter: blur(100px);background-color: transparent; border-radius: 50px;border: 1px solid #ccc;margin-right: 10px;margin-left: 10px;">
|
| 236 |
-
<div
|
| 237 |
-
style="display: flex; flex-direction: row; gap: 10px; margin-top: 10px; width: 100%; justify-content: center;">
|
| 238 |
-
<div class="tools">
|
| 239 |
-
<div class="tools-content">
|
| 240 |
-
<a href="/write"><button
|
| 241 |
-
style="color: greenyellow;background-color: black;">Write</button></a><br>
|
| 242 |
-
<a href="/summarize"><button
|
| 243 |
-
style="color: greenyellow;background-color: black;">Summarize</button></a><br>
|
| 244 |
-
<a href="/translate"><button
|
| 245 |
-
style="color: greenyellow;background-color: black;">Translate</button></a><br>
|
| 246 |
-
<a href="/imagine"><button
|
| 247 |
-
style="color: greenyellow;background-color: black;">Imagine</button></a><br>
|
| 248 |
-
</div>
|
| 249 |
-
<button style="background-color: black;">
|
| 250 |
-
<i class="fa-solid fa-sliders fa-2xl" style="color: #63E6BE;"></i>
|
| 251 |
-
</button>
|
| 252 |
-
</div>
|
| 253 |
-
<button id="sendButton" onclick="answer()"
|
| 254 |
-
style="font-weight: bold; background-color: black; color: greenyellow">↑</button>
|
| 255 |
-
</div>
|
| 256 |
-
</div>
|
| 257 |
-
</main>
|
| 258 |
-
|
| 259 |
-
<script>
|
| 260 |
-
|
| 261 |
-
async function answer() {
|
| 262 |
-
document.getElementById("sendButton").disabled = true
|
| 263 |
-
const welcomeMessage = document.getElementById('welcomeMessage');
|
| 264 |
-
welcomeMessage.style.display = 'none'; // Hide the welcome message
|
| 265 |
-
const userInput = document.getElementById('userInput').value;
|
| 266 |
-
if (userInput.trim() === '') return;
|
| 267 |
-
// Create wrapper for text1 (User message)
|
| 268 |
-
const text1 = document.createElement('div');
|
| 269 |
-
text1.className = 'text1';
|
| 270 |
-
const userMessage = document.createElement('div');
|
| 271 |
-
userMessage.className = 'user';
|
| 272 |
-
userMessage.textContent = userInput;
|
| 273 |
-
text1.appendChild(userMessage);
|
| 274 |
-
// Append user message to the chat area
|
| 275 |
-
document.getElementById('chatArea').appendChild(text1);
|
| 276 |
-
// Clear input
|
| 277 |
-
document.getElementById('userInput').value = '';
|
| 278 |
-
const question = userInput; // Use the already retrieved value
|
| 279 |
-
// Send a POST request to the /ask route
|
| 280 |
-
const response = await fetch("/think", {
|
| 281 |
-
method: "POST",
|
| 282 |
-
headers: {
|
| 283 |
-
"Content-Type": "application/x-www-form-urlencoded"
|
| 284 |
-
},
|
| 285 |
-
body: new URLSearchParams({ question: question })
|
| 286 |
-
});
|
| 287 |
-
const data = await response.json();
|
| 288 |
-
// Create wrapper for text2 (AI response)
|
| 289 |
-
const text2 = document.createElement('div');
|
| 290 |
-
text2.className = 'text2';
|
| 291 |
-
const aiResponse = document.createElement('div');
|
| 292 |
-
aiResponse.className = 'ai';
|
| 293 |
-
if (data.answer) {
|
| 294 |
-
aiResponse.textContent = data.answer;
|
| 295 |
-
} else if (data.error) {
|
| 296 |
-
aiResponse.textContent = "Error: " + data.error;
|
| 297 |
-
}
|
| 298 |
-
text2.appendChild(aiResponse);
|
| 299 |
-
// Append AI response to the chat area
|
| 300 |
-
document.getElementById('chatArea').appendChild(text2);
|
| 301 |
-
document.getElementById("sendButton").disabled = false
|
| 302 |
-
}
|
| 303 |
-
if ("serviceWorker" in navigator) {
|
| 304 |
-
navigator.serviceWorker
|
| 305 |
-
.register("/static/service-worker.js")
|
| 306 |
-
.then(() => console.log("Service Worker Registered"))
|
| 307 |
-
.catch((err) => console.error("SW registration failed:", err));
|
| 308 |
-
}
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
document.getElementById("drop-down-h3-warnings").style.color = "black"
|
| 319 |
-
document.getElementById("btn").style.color = "black"
|
| 320 |
-
document.querySelectorAll(".user").forEach(element => {
|
| 321 |
-
element.style.color = "black"
|
| 322 |
-
});
|
| 323 |
-
document.querySelectorAll(".ai").forEach(element => {
|
| 324 |
-
element.style.color = "black"
|
| 325 |
-
})
|
| 326 |
-
document.querySelectorAll(".dropdown-content a").forEach(element => {
|
| 327 |
-
element.style.color = "black"
|
| 328 |
-
})
|
| 329 |
-
document.getElementById("i_class").style.color = "black";
|
| 330 |
-
document.querySelectorAll(".dropdown-content p").forEach(element => {
|
| 331 |
-
element.style.color = "black"
|
| 332 |
-
})
|
| 333 |
-
document.getElementById("i_class_2").style.color = "black";
|
| 334 |
-
document.getElementsByTagName("h2")[0].style.color = "black";
|
| 335 |
-
} else {
|
| 336 |
-
document.getElementsByTagName("body")[0].style.backgroundColor = "black";
|
| 337 |
-
document.getElementById("theme").textContent = "Theme: 🌙 (Dark)";
|
| 338 |
-
document.getElementById("welcomeMessage").style.color = "white";
|
| 339 |
-
document.getElementsByTagName("body")[0].style.backgroundImage = "url({{ url_for('static', filename='images/black bg.jpeg') }})";
|
| 340 |
-
document.getElementById("drop-down-h3-menu").style.color = "white"
|
| 341 |
-
document.getElementById("drop-down-h3-settings").style.color = "white"
|
| 342 |
-
document.getElementById("drop-down-h3-warnings").style.color = "white"
|
| 343 |
-
document.querySelectorAll(".user").forEach(elements => {
|
| 344 |
-
elements.style.color = "white"
|
| 345 |
-
})
|
| 346 |
-
document.querySelectorAll(".ai").forEach(elements => {
|
| 347 |
-
elements.style.color = "white"
|
| 348 |
-
})
|
| 349 |
-
document.getElementById("btn").style.color = "white"
|
| 350 |
-
document.querySelectorAll(".dropdown-content a").forEach(element => {
|
| 351 |
-
element.style.color = "white"
|
| 352 |
-
})
|
| 353 |
-
document.getElementById("i_class").style.color = "white";
|
| 354 |
-
document.querySelectorAll(".dropdown-content p").forEach(element => {
|
| 355 |
-
element.style.color = "white"
|
| 356 |
-
})
|
| 357 |
-
document.getElementById("i_class_2").style.color = "white";
|
| 358 |
-
document.getElementsByTagName("h2")[0].style.color = "white";
|
| 359 |
-
}
|
| 360 |
-
})
|
| 361 |
-
document.getElementById("userInput").addEventListener("keypress", () => {
|
| 362 |
-
if (event.key === "Enter") {
|
| 363 |
-
sendButton.click()
|
| 364 |
-
}
|
| 365 |
-
})
|
| 366 |
-
</script>
|
| 367 |
-
|
| 368 |
-
</body>
|
| 369 |
-
|
| 370 |
</html>
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
|
| 4 |
+
<head>
|
| 5 |
+
<meta charset="UTF-8">
|
| 6 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 7 |
+
<title>Think | TaskBot v1+ AI</title>
|
| 8 |
+
<script src="https://kit.fontawesome.com/cda0e70b18.js" crossorigin="anonymous"></script>
|
| 9 |
+
<link rel="Icon" href="TaskBot logo.png">
|
| 10 |
+
<link rel="manifest" href="/static/manifest.json">
|
| 11 |
+
</head>
|
| 12 |
+
|
| 13 |
+
<style>
|
| 14 |
+
body {
|
| 15 |
+
background-color: #2f2f2f;
|
| 16 |
+
font-family: Arial, sans-serif;
|
| 17 |
+
color: white;
|
| 18 |
+
margin: 0;
|
| 19 |
+
padding: 20px;
|
| 20 |
+
background: url("{{ url_for('static', filename='images/black bg.jpeg') }}");
|
| 21 |
+
background-size: cover;
|
| 22 |
+
background-repeat: no-repeat;
|
| 23 |
+
background-size: cover;
|
| 24 |
+
background-attachment: fixed;
|
| 25 |
+
background-position: center center;
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
nav {
|
| 29 |
+
background-color: #444;
|
| 30 |
+
padding: 5px;
|
| 31 |
+
border-radius: 5px;
|
| 32 |
+
width: 100%;
|
| 33 |
+
height: auto;
|
| 34 |
+
top: 0;
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
.sticky {
|
| 38 |
+
position: absolute;
|
| 39 |
+
top: 20px;
|
| 40 |
+
right: 20px;
|
| 41 |
+
z-index: 1000;
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
.sticky2 {
|
| 45 |
+
position: absolute;
|
| 46 |
+
top: 20px;
|
| 47 |
+
right: 80px;
|
| 48 |
+
z-index: 1000;
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
.sticky3 {
|
| 52 |
+
position: absolute;
|
| 53 |
+
top: 20px;
|
| 54 |
+
right: 140px;
|
| 55 |
+
z-index: 1000;
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
/* Dropdown Styles */
|
| 59 |
+
.dropdown {
|
| 60 |
+
position: relative;
|
| 61 |
+
display: inline-block;
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
.btn {
|
| 65 |
+
background-color: transparent;
|
| 66 |
+
color: white;
|
| 67 |
+
border: none;
|
| 68 |
+
cursor: pointer;
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
.btn:hover {
|
| 72 |
+
background-color: #494949;
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
.dropdown-content {
|
| 76 |
+
display: none;
|
| 77 |
+
position: absolute;
|
| 78 |
+
right: 0;
|
| 79 |
+
background-color: transparent;
|
| 80 |
+
backdrop-filter: blur(5px);
|
| 81 |
+
border: 1px solid black;
|
| 82 |
+
min-width: 160px;
|
| 83 |
+
box-shadow: 0px 8px 16px rgba(0, 0, 0, 0.2);
|
| 84 |
+
z-index: 1;
|
| 85 |
+
text-align: center;
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
.dropdown-content h3 {
|
| 89 |
+
margin: 5px 0;
|
| 90 |
+
color: white;
|
| 91 |
+
text-align: center;
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
.dropdown-content a {
|
| 95 |
+
color: white;
|
| 96 |
+
padding: 12px 16px;
|
| 97 |
+
text-decoration: none;
|
| 98 |
+
display: block;
|
| 99 |
+
border-top: 1px solid transparent;
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
.dropdown-content a:hover {
|
| 103 |
+
background-color: #bebebe;
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
.dropdown:hover .dropdown-content {
|
| 107 |
+
display: block;
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
main {
|
| 111 |
+
display: flex;
|
| 112 |
+
flex-direction: column;
|
| 113 |
+
align-items: center;
|
| 114 |
+
justify-content: center;
|
| 115 |
+
height: calc(100vh - 100px);
|
| 116 |
+
/* adjust if header height changes */
|
| 117 |
+
text-align: center;
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
/* Input and Button Styles */
|
| 121 |
+
#question {
|
| 122 |
+
padding: 10px;
|
| 123 |
+
font-size: 16px;
|
| 124 |
+
border-radius: 5px;
|
| 125 |
+
border: 1px solid #ccc;
|
| 126 |
+
margin-right: 10px;
|
| 127 |
+
}
|
| 128 |
+
|
| 129 |
+
.ai,
|
| 130 |
+
.user {
|
| 131 |
+
background-color: transparent;
|
| 132 |
+
backdrop-filter: blur(5px);
|
| 133 |
+
padding: 10px;
|
| 134 |
+
padding-right: 10px;
|
| 135 |
+
border-radius: 5px;
|
| 136 |
+
border: solid #ccc;
|
| 137 |
+
margin: 10px;
|
| 138 |
+
text-align: center;
|
| 139 |
+
justify-content: right;
|
| 140 |
+
width: 40%;
|
| 141 |
+
color: rgb(227, 227, 227)
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
.text1 {
|
| 145 |
+
display: flex;
|
| 146 |
+
justify-content: right;
|
| 147 |
+
align-items: center;
|
| 148 |
+
margin: 10px;
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
.text2 {
|
| 152 |
+
display: flex;
|
| 153 |
+
justify-content: left;
|
| 154 |
+
align-items: center;
|
| 155 |
+
margin: 10px;
|
| 156 |
+
}
|
| 157 |
+
|
| 158 |
+
.chat-input-container {
|
| 159 |
+
display: flex;
|
| 160 |
+
align-items: center;
|
| 161 |
+
justify-content: center;
|
| 162 |
+
margin-top: 20px;
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
#sendButton {
|
| 166 |
+
margin-left: 10px;
|
| 167 |
+
padding: 10px 20px;
|
| 168 |
+
border: none;
|
| 169 |
+
border-radius: 5px;
|
| 170 |
+
background-color: #fff;
|
| 171 |
+
cursor: pointer;
|
| 172 |
+
transition: background-color 0.3s;
|
| 173 |
+
}
|
| 174 |
+
|
| 175 |
+
#sendButton:hover {
|
| 176 |
+
background-color: #e0e0e0;
|
| 177 |
+
}
|
| 178 |
+
|
| 179 |
+
.inputWrapper {
|
| 180 |
+
flex-direction: column;
|
| 181 |
+
align-items: center;
|
| 182 |
+
justify-content: center;
|
| 183 |
+
position: fixed;
|
| 184 |
+
bottom: 20px;
|
| 185 |
+
left: 50%;
|
| 186 |
+
transform: translateX(-50%);
|
| 187 |
+
display: flex;
|
| 188 |
+
gap: 10px;
|
| 189 |
+
z-index: 1000;
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
.inputWrapper input {
|
| 193 |
+
width: 100%;
|
| 194 |
+
padding: 10px;
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
+
.tools button {
|
| 198 |
+
font-size: 18px;
|
| 199 |
+
padding: 10px 20px;
|
| 200 |
+
border-radius: 50px;
|
| 201 |
+
cursor: pointer;
|
| 202 |
+
}
|
| 203 |
+
|
| 204 |
+
#welcomeMessage {
|
| 205 |
+
text-align: center;
|
| 206 |
+
margin-top: 20%;
|
| 207 |
+
}
|
| 208 |
+
|
| 209 |
+
.tools-content {
|
| 210 |
+
display: none;
|
| 211 |
+
|
| 212 |
+
}
|
| 213 |
+
|
| 214 |
+
.tools:hover {
|
| 215 |
+
.tools-content {
|
| 216 |
+
display: block
|
| 217 |
+
}
|
| 218 |
+
}
|
| 219 |
+
</style>
|
| 220 |
+
|
| 221 |
+
<body>
|
| 222 |
+
<H1 id="welcomeMessage">Hello 👋, what can I help with?</H1>
|
| 223 |
+
<div id="chatArea">
|
| 224 |
+
<div class="text1">
|
| 225 |
+
<div class="user" style="display: none;"></div>
|
| 226 |
+
</div>
|
| 227 |
+
<div class="text2">
|
| 228 |
+
<div class="ai" style="display: none;"></div>
|
| 229 |
+
</div>
|
| 230 |
+
</div>
|
| 231 |
+
|
| 232 |
+
<main>
|
| 233 |
+
<div class="inputWrapper">
|
| 234 |
+
<input type="text" id="userInput" placeholder="Type your message here..."
|
| 235 |
+
style="width: 200px;color: white; backdrop-filter: blur(100px);background-color: transparent; border-radius: 50px;border: 1px solid #ccc;margin-right: 10px;margin-left: 10px;">
|
| 236 |
+
<div
|
| 237 |
+
style="display: flex; flex-direction: row; gap: 10px; margin-top: 10px; width: 100%; justify-content: center;">
|
| 238 |
+
<div class="tools">
|
| 239 |
+
<div class="tools-content">
|
| 240 |
+
<a href="/write"><button
|
| 241 |
+
style="color: greenyellow;background-color: black;">Write</button></a><br>
|
| 242 |
+
<a href="/summarize"><button
|
| 243 |
+
style="color: greenyellow;background-color: black;">Summarize</button></a><br>
|
| 244 |
+
<a href="/translate"><button
|
| 245 |
+
style="color: greenyellow;background-color: black;">Translate</button></a><br>
|
| 246 |
+
<a href="/imagine"><button
|
| 247 |
+
style="color: greenyellow;background-color: black;">Imagine</button></a><br>
|
| 248 |
+
</div>
|
| 249 |
+
<button style="background-color: black;">
|
| 250 |
+
<i class="fa-solid fa-sliders fa-2xl" style="color: #63E6BE;"></i>
|
| 251 |
+
</button>
|
| 252 |
+
</div>
|
| 253 |
+
<button id="sendButton" onclick="answer()"
|
| 254 |
+
style="font-weight: bold; background-color: black; color: greenyellow">↑</button>
|
| 255 |
+
</div>
|
| 256 |
+
</div>
|
| 257 |
+
</main>
|
| 258 |
+
|
| 259 |
+
<script>
|
| 260 |
+
|
| 261 |
+
async function answer() {
|
| 262 |
+
document.getElementById("sendButton").disabled = true
|
| 263 |
+
const welcomeMessage = document.getElementById('welcomeMessage');
|
| 264 |
+
welcomeMessage.style.display = 'none'; // Hide the welcome message
|
| 265 |
+
const userInput = document.getElementById('userInput').value;
|
| 266 |
+
if (userInput.trim() === '') return;
|
| 267 |
+
// Create wrapper for text1 (User message)
|
| 268 |
+
const text1 = document.createElement('div');
|
| 269 |
+
text1.className = 'text1';
|
| 270 |
+
const userMessage = document.createElement('div');
|
| 271 |
+
userMessage.className = 'user';
|
| 272 |
+
userMessage.textContent = userInput;
|
| 273 |
+
text1.appendChild(userMessage);
|
| 274 |
+
// Append user message to the chat area
|
| 275 |
+
document.getElementById('chatArea').appendChild(text1);
|
| 276 |
+
// Clear input
|
| 277 |
+
document.getElementById('userInput').value = '';
|
| 278 |
+
const question = userInput; // Use the already retrieved value
|
| 279 |
+
// Send a POST request to the /ask route
|
| 280 |
+
const response = await fetch("/think", {
|
| 281 |
+
method: "POST",
|
| 282 |
+
headers: {
|
| 283 |
+
"Content-Type": "application/x-www-form-urlencoded"
|
| 284 |
+
},
|
| 285 |
+
body: new URLSearchParams({ question: question })
|
| 286 |
+
});
|
| 287 |
+
const data = await response.json();
|
| 288 |
+
// Create wrapper for text2 (AI response)
|
| 289 |
+
const text2 = document.createElement('div');
|
| 290 |
+
text2.className = 'text2';
|
| 291 |
+
const aiResponse = document.createElement('div');
|
| 292 |
+
aiResponse.className = 'ai';
|
| 293 |
+
if (data.answer) {
|
| 294 |
+
aiResponse.textContent = data.answer;
|
| 295 |
+
} else if (data.error) {
|
| 296 |
+
aiResponse.textContent = "Error: " + data.error;
|
| 297 |
+
}
|
| 298 |
+
text2.appendChild(aiResponse);
|
| 299 |
+
// Append AI response to the chat area
|
| 300 |
+
document.getElementById('chatArea').appendChild(text2);
|
| 301 |
+
document.getElementById("sendButton").disabled = false
|
| 302 |
+
}
|
| 303 |
+
if ("serviceWorker" in navigator) {
|
| 304 |
+
navigator.serviceWorker
|
| 305 |
+
.register("/static/service-worker.js")
|
| 306 |
+
.then(() => console.log("Service Worker Registered"))
|
| 307 |
+
.catch((err) => console.error("SW registration failed:", err));
|
| 308 |
+
}
|
| 309 |
+
document.getElementById("userInput").addEventListener("keypress", () => {
|
| 310 |
+
if (event.key === "Enter") {
|
| 311 |
+
sendButton.click()
|
| 312 |
+
}
|
| 313 |
+
})
|
| 314 |
+
</script>
|
| 315 |
+
|
| 316 |
+
</body>
|
| 317 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 318 |
</html>
|