Spaces:
Running
Running
Update index.html
Browse files- index.html +228 -132
index.html
CHANGED
|
@@ -68,6 +68,7 @@
|
|
| 68 |
<button
|
| 69 |
id="continueButton"
|
| 70 |
class="auth-continue"
|
|
|
|
| 71 |
>
|
| 72 |
Continue
|
| 73 |
</button>
|
|
@@ -123,6 +124,7 @@
|
|
| 123 |
<button
|
| 124 |
id="pickerClose"
|
| 125 |
class="picker-close"
|
|
|
|
| 126 |
>
|
| 127 |
×
|
| 128 |
</button>
|
|
@@ -188,6 +190,7 @@
|
|
| 188 |
<button
|
| 189 |
id="closeSidebar"
|
| 190 |
class="brand-close"
|
|
|
|
| 191 |
>
|
| 192 |
×
|
| 193 |
</button>
|
|
@@ -200,6 +203,7 @@
|
|
| 200 |
<button
|
| 201 |
id="newChat"
|
| 202 |
class="new-chat"
|
|
|
|
| 203 |
>
|
| 204 |
|
| 205 |
<span class="new-plus">
|
|
@@ -253,6 +257,7 @@
|
|
| 253 |
<button
|
| 254 |
id="subjectSidebarButton"
|
| 255 |
class="side-setting"
|
|
|
|
| 256 |
>
|
| 257 |
|
| 258 |
<span class="side-setting-icon">
|
|
@@ -285,6 +290,7 @@
|
|
| 285 |
<button
|
| 286 |
id="modeSidebarButton"
|
| 287 |
class="side-setting"
|
|
|
|
| 288 |
>
|
| 289 |
|
| 290 |
<span class="side-setting-icon">
|
|
@@ -317,6 +323,7 @@
|
|
| 317 |
<button
|
| 318 |
id="modelSidebarButton"
|
| 319 |
class="side-setting"
|
|
|
|
| 320 |
>
|
| 321 |
|
| 322 |
<span class="side-setting-icon">
|
|
@@ -422,6 +429,7 @@
|
|
| 422 |
<button
|
| 423 |
id="themeButton"
|
| 424 |
class="theme-button"
|
|
|
|
| 425 |
>
|
| 426 |
☼
|
| 427 |
</button>
|
|
@@ -462,6 +470,7 @@
|
|
| 462 |
<button
|
| 463 |
id="signOutButton"
|
| 464 |
class="signout-button"
|
|
|
|
| 465 |
>
|
| 466 |
↪
|
| 467 |
</button>
|
|
@@ -489,6 +498,7 @@
|
|
| 489 |
<button
|
| 490 |
id="menuButton"
|
| 491 |
class="menu-button"
|
|
|
|
| 492 |
>
|
| 493 |
☰
|
| 494 |
</button>
|
|
@@ -508,6 +518,7 @@
|
|
| 508 |
<button
|
| 509 |
id="breadcrumbSubject"
|
| 510 |
class="breadcrumb-subject"
|
|
|
|
| 511 |
>
|
| 512 |
Math
|
| 513 |
</button>
|
|
@@ -521,6 +532,7 @@
|
|
| 521 |
<button
|
| 522 |
id="focusButton"
|
| 523 |
class="focus-button"
|
|
|
|
| 524 |
>
|
| 525 |
|
| 526 |
<span class="focus-dot">
|
|
@@ -536,6 +548,7 @@
|
|
| 536 |
<button
|
| 537 |
id="moonButton"
|
| 538 |
class="moon-button"
|
|
|
|
| 539 |
>
|
| 540 |
☾
|
| 541 |
</button>
|
|
@@ -695,6 +708,7 @@
|
|
| 695 |
<button
|
| 696 |
id="subjectPickerButton"
|
| 697 |
class="focus-picker"
|
|
|
|
| 698 |
>
|
| 699 |
|
| 700 |
<span class="focus-picker-icon">
|
|
@@ -727,6 +741,7 @@
|
|
| 727 |
<button
|
| 728 |
id="modePickerButton"
|
| 729 |
class="focus-picker"
|
|
|
|
| 730 |
>
|
| 731 |
|
| 732 |
<span class="focus-picker-icon">
|
|
@@ -818,6 +833,7 @@
|
|
| 818 |
<button
|
| 819 |
id="sendButton"
|
| 820 |
class="send-button"
|
|
|
|
| 821 |
>
|
| 822 |
◇
|
| 823 |
</button>
|
|
@@ -905,23 +921,65 @@
|
|
| 905 |
|
| 906 |
|
| 907 |
|
| 908 |
-
<script
|
| 909 |
|
| 910 |
|
| 911 |
-
|
| 912 |
-
|
| 913 |
-
|
| 914 |
-
|
| 915 |
-
|
| 916 |
-
"https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.8.1";
|
| 917 |
|
|
|
|
|
|
|
| 918 |
|
| 919 |
-
|
| 920 |
-
|
|
|
|
| 921 |
|
| 922 |
|
| 923 |
-
|
| 924 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 925 |
|
| 926 |
|
| 927 |
|
|
@@ -1101,7 +1159,7 @@ const SUBJECTS = [
|
|
| 1101 |
|
| 1102 |
|
| 1103 |
/* ================================
|
| 1104 |
-
|
| 1105 |
================================ */
|
| 1106 |
|
| 1107 |
const MODES = [
|
|
@@ -1184,7 +1242,7 @@ const MODES = [
|
|
| 1184 |
|
| 1185 |
|
| 1186 |
/* ================================
|
| 1187 |
-
|
| 1188 |
================================ */
|
| 1189 |
|
| 1190 |
const MODEL_OPTIONS = [
|
|
@@ -1216,7 +1274,7 @@ const MODEL_OPTIONS = [
|
|
| 1216 |
"Balanced",
|
| 1217 |
|
| 1218 |
description:
|
| 1219 |
-
"SmolLM2 360M ·
|
| 1220 |
},
|
| 1221 |
|
| 1222 |
|
|
@@ -1240,7 +1298,7 @@ const MODEL_OPTIONS = [
|
|
| 1240 |
|
| 1241 |
|
| 1242 |
/* ================================
|
| 1243 |
-
MODE
|
| 1244 |
================================ */
|
| 1245 |
|
| 1246 |
const MODE_DATA = {
|
|
@@ -1445,6 +1503,12 @@ const profileInput =
|
|
| 1445 |
);
|
| 1446 |
|
| 1447 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1448 |
const workspace =
|
| 1449 |
document.getElementById(
|
| 1450 |
"workspace"
|
|
@@ -1543,7 +1607,7 @@ const pickerOptions =
|
|
| 1543 |
|
| 1544 |
|
| 1545 |
/* ================================
|
| 1546 |
-
|
| 1547 |
================================ */
|
| 1548 |
|
| 1549 |
function scrollToBottom(
|
|
@@ -1686,7 +1750,7 @@ function subjectShortName() {
|
|
| 1686 |
|
| 1687 |
|
| 1688 |
/* ================================
|
| 1689 |
-
|
| 1690 |
================================ */
|
| 1691 |
|
| 1692 |
function continueProfile() {
|
|
@@ -1738,6 +1802,12 @@ function continueProfile() {
|
|
| 1738 |
.toUpperCase();
|
| 1739 |
|
| 1740 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1741 |
authOverlay.style.display =
|
| 1742 |
"none";
|
| 1743 |
|
|
@@ -1771,27 +1841,35 @@ function continueProfile() {
|
|
| 1771 |
newChat();
|
| 1772 |
|
| 1773 |
|
| 1774 |
-
|
| 1775 |
-
.
|
| 1776 |
-
|
|
|
|
| 1777 |
|
| 1778 |
-
|
| 1779 |
-
|
| 1780 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1781 |
);
|
| 1782 |
|
| 1783 |
-
}
|
|
|
|
| 1784 |
);
|
| 1785 |
|
| 1786 |
}
|
| 1787 |
|
| 1788 |
|
| 1789 |
|
| 1790 |
-
|
| 1791 |
-
.getElementById(
|
| 1792 |
-
"continueButton"
|
| 1793 |
-
)
|
| 1794 |
-
.addEventListener(
|
| 1795 |
"click",
|
| 1796 |
continueProfile
|
| 1797 |
);
|
|
@@ -1807,6 +1885,8 @@ profileInput.addEventListener(
|
|
| 1807 |
"Enter"
|
| 1808 |
) {
|
| 1809 |
|
|
|
|
|
|
|
| 1810 |
continueProfile();
|
| 1811 |
|
| 1812 |
}
|
|
@@ -1816,6 +1896,10 @@ profileInput.addEventListener(
|
|
| 1816 |
|
| 1817 |
|
| 1818 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1819 |
document
|
| 1820 |
.getElementById(
|
| 1821 |
"signOutButton"
|
|
@@ -1850,6 +1934,9 @@ document
|
|
| 1850 |
authOverlay.style.display =
|
| 1851 |
"flex";
|
| 1852 |
|
|
|
|
|
|
|
|
|
|
| 1853 |
}
|
| 1854 |
);
|
| 1855 |
|
|
@@ -1949,6 +2036,10 @@ function renderChatList() {
|
|
| 1949 |
);
|
| 1950 |
|
| 1951 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1952 |
button.className =
|
| 1953 |
"saved-chat"
|
| 1954 |
+
|
|
@@ -2066,7 +2157,7 @@ function getOrCreateChat(
|
|
| 2066 |
|
| 2067 |
|
| 2068 |
/* ================================
|
| 2069 |
-
OPEN
|
| 2070 |
================================ */
|
| 2071 |
|
| 2072 |
async function openChat(
|
|
@@ -2189,7 +2280,8 @@ async function openChat(
|
|
| 2189 |
item.content,
|
| 2190 |
item.mode
|
| 2191 |
||
|
| 2192 |
-
mode
|
|
|
|
| 2193 |
);
|
| 2194 |
|
| 2195 |
}
|
|
@@ -2327,7 +2419,7 @@ document
|
|
| 2327 |
|
| 2328 |
|
| 2329 |
/* ================================
|
| 2330 |
-
|
| 2331 |
================================ */
|
| 2332 |
|
| 2333 |
function openPicker(
|
|
@@ -2374,7 +2466,7 @@ function openPicker(
|
|
| 2374 |
}
|
| 2375 |
|
| 2376 |
|
| 2377 |
-
if (
|
| 2378 |
type
|
| 2379 |
===
|
| 2380 |
"mode"
|
|
@@ -2398,7 +2490,7 @@ function openPicker(
|
|
| 2398 |
}
|
| 2399 |
|
| 2400 |
|
| 2401 |
-
if (
|
| 2402 |
type
|
| 2403 |
===
|
| 2404 |
"model"
|
|
@@ -2409,7 +2501,7 @@ function openPicker(
|
|
| 2409 |
|
| 2410 |
|
| 2411 |
pickerSubtitle.textContent =
|
| 2412 |
-
"Larger models
|
| 2413 |
|
| 2414 |
|
| 2415 |
items =
|
|
@@ -2442,6 +2534,10 @@ function openPicker(
|
|
| 2442 |
);
|
| 2443 |
|
| 2444 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2445 |
button.className =
|
| 2446 |
"picker-option"
|
| 2447 |
+
|
|
@@ -2545,8 +2641,12 @@ function openPicker(
|
|
| 2545 |
"click",
|
| 2546 |
async () => {
|
| 2547 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2548 |
if (
|
| 2549 |
-
|
| 2550 |
===
|
| 2551 |
"subject"
|
| 2552 |
) {
|
|
@@ -2557,11 +2657,14 @@ function openPicker(
|
|
| 2557 |
|
| 2558 |
updateAllUI();
|
| 2559 |
|
|
|
|
|
|
|
|
|
|
| 2560 |
}
|
| 2561 |
|
| 2562 |
|
| 2563 |
else if (
|
| 2564 |
-
|
| 2565 |
===
|
| 2566 |
"mode"
|
| 2567 |
) {
|
|
@@ -2576,11 +2679,14 @@ function openPicker(
|
|
| 2576 |
|
| 2577 |
updateAllUI();
|
| 2578 |
|
|
|
|
|
|
|
|
|
|
| 2579 |
}
|
| 2580 |
|
| 2581 |
|
| 2582 |
else if (
|
| 2583 |
-
|
| 2584 |
===
|
| 2585 |
"model"
|
| 2586 |
) {
|
|
@@ -2592,14 +2698,8 @@ function openPicker(
|
|
| 2592 |
value
|
| 2593 |
);
|
| 2594 |
|
| 2595 |
-
|
| 2596 |
-
return;
|
| 2597 |
-
|
| 2598 |
}
|
| 2599 |
|
| 2600 |
-
|
| 2601 |
-
closePicker();
|
| 2602 |
-
|
| 2603 |
}
|
| 2604 |
);
|
| 2605 |
|
|
@@ -2636,7 +2736,6 @@ function closePicker() {
|
|
| 2636 |
}
|
| 2637 |
|
| 2638 |
|
| 2639 |
-
|
| 2640 |
document
|
| 2641 |
.getElementById(
|
| 2642 |
"pickerClose"
|
|
@@ -2880,6 +2979,10 @@ function renderSuggestions() {
|
|
| 2880 |
);
|
| 2881 |
|
| 2882 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2883 |
button.className =
|
| 2884 |
"suggestion";
|
| 2885 |
|
|
@@ -2925,6 +3028,9 @@ function renderSuggestions() {
|
|
| 2925 |
messageInput.focus();
|
| 2926 |
|
| 2927 |
|
|
|
|
|
|
|
|
|
|
| 2928 |
updateSendState();
|
| 2929 |
|
| 2930 |
}
|
|
@@ -2943,7 +3049,7 @@ function renderSuggestions() {
|
|
| 2943 |
|
| 2944 |
|
| 2945 |
/* ================================
|
| 2946 |
-
|
| 2947 |
================================ */
|
| 2948 |
|
| 2949 |
async function releaseModel() {
|
|
@@ -2990,11 +3096,6 @@ async function releaseModel() {
|
|
| 2990 |
}
|
| 2991 |
|
| 2992 |
|
| 2993 |
-
|
| 2994 |
-
/* ================================
|
| 2995 |
-
SELECT MODEL
|
| 2996 |
-
================================ */
|
| 2997 |
-
|
| 2998 |
async function chooseModel(
|
| 2999 |
key
|
| 3000 |
) {
|
|
@@ -3073,7 +3174,7 @@ async function chooseModel(
|
|
| 3073 |
|
| 3074 |
|
| 3075 |
/* ================================
|
| 3076 |
-
|
| 3077 |
================================ */
|
| 3078 |
|
| 3079 |
function updateProgress(
|
|
@@ -3109,12 +3210,8 @@ function updateProgress(
|
|
| 3109 |
}
|
| 3110 |
|
| 3111 |
|
| 3112 |
-
|
| 3113 |
-
/* ================================
|
| 3114 |
-
LOAD ATTEMPT
|
| 3115 |
-
================================ */
|
| 3116 |
-
|
| 3117 |
async function loadAttempt(
|
|
|
|
| 3118 |
options,
|
| 3119 |
runtimeName
|
| 3120 |
) {
|
|
@@ -3127,11 +3224,11 @@ async function loadAttempt(
|
|
| 3127 |
runtimeName;
|
| 3128 |
|
| 3129 |
|
| 3130 |
-
return await
|
| 3131 |
|
| 3132 |
"text-generation",
|
| 3133 |
|
| 3134 |
-
|
| 3135 |
|
| 3136 |
{
|
| 3137 |
|
|
@@ -3180,11 +3277,6 @@ async function loadAttempt(
|
|
| 3180 |
}
|
| 3181 |
|
| 3182 |
|
| 3183 |
-
|
| 3184 |
-
/* ================================
|
| 3185 |
-
LOAD AI
|
| 3186 |
-
================================ */
|
| 3187 |
-
|
| 3188 |
async function loadAI() {
|
| 3189 |
|
| 3190 |
if (
|
|
@@ -3205,6 +3297,10 @@ async function loadAI() {
|
|
| 3205 |
}
|
| 3206 |
|
| 3207 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3208 |
loadingPromise =
|
| 3209 |
(
|
| 3210 |
async () => {
|
|
@@ -3229,18 +3325,17 @@ async function loadAI() {
|
|
| 3229 |
"Preparing FYRStudyGPT…";
|
| 3230 |
|
| 3231 |
|
| 3232 |
-
|
| 3233 |
-
|
|
|
|
|
|
|
|
|
|
| 3234 |
|
| 3235 |
|
| 3236 |
const attempts =
|
| 3237 |
[];
|
| 3238 |
|
| 3239 |
|
| 3240 |
-
/*
|
| 3241 |
-
First try GPU if available.
|
| 3242 |
-
*/
|
| 3243 |
-
|
| 3244 |
if (
|
| 3245 |
"gpu"
|
| 3246 |
in
|
|
@@ -3269,10 +3364,6 @@ async function loadAI() {
|
|
| 3269 |
}
|
| 3270 |
|
| 3271 |
|
| 3272 |
-
/*
|
| 3273 |
-
CPU fallback.
|
| 3274 |
-
*/
|
| 3275 |
-
|
| 3276 |
attempts.push({
|
| 3277 |
|
| 3278 |
name:
|
|
@@ -3317,6 +3408,7 @@ async function loadAI() {
|
|
| 3317 |
|
| 3318 |
generator =
|
| 3319 |
await loadAttempt(
|
|
|
|
| 3320 |
attempt.options,
|
| 3321 |
attempt.name
|
| 3322 |
);
|
|
@@ -3469,7 +3561,7 @@ async function loadAI() {
|
|
| 3469 |
|
| 3470 |
|
| 3471 |
/* ================================
|
| 3472 |
-
|
| 3473 |
================================ */
|
| 3474 |
|
| 3475 |
function systemPrompt() {
|
|
@@ -3497,11 +3589,6 @@ If you are uncertain, say so clearly.`;
|
|
| 3497 |
}
|
| 3498 |
|
| 3499 |
|
| 3500 |
-
|
| 3501 |
-
/* ================================
|
| 3502 |
-
BUILD PROMPT
|
| 3503 |
-
================================ */
|
| 3504 |
-
|
| 3505 |
function createPrompt(
|
| 3506 |
text
|
| 3507 |
) {
|
|
@@ -3663,7 +3750,7 @@ Explain the reasoning instead of only giving the final answer.`;
|
|
| 3663 |
|
| 3664 |
|
| 3665 |
/* ================================
|
| 3666 |
-
|
| 3667 |
================================ */
|
| 3668 |
|
| 3669 |
function extractOutput(
|
|
@@ -3719,11 +3806,6 @@ function extractOutput(
|
|
| 3719 |
}
|
| 3720 |
|
| 3721 |
|
| 3722 |
-
|
| 3723 |
-
/* ================================
|
| 3724 |
-
GENERATE ANSWER
|
| 3725 |
-
================================ */
|
| 3726 |
-
|
| 3727 |
async function generateAnswer(
|
| 3728 |
prompt
|
| 3729 |
) {
|
|
@@ -3759,10 +3841,6 @@ async function generateAnswer(
|
|
| 3759 |
];
|
| 3760 |
|
| 3761 |
|
| 3762 |
-
/*
|
| 3763 |
-
Try chat format first.
|
| 3764 |
-
*/
|
| 3765 |
-
|
| 3766 |
try {
|
| 3767 |
|
| 3768 |
const result =
|
|
@@ -3814,10 +3892,6 @@ async function generateAnswer(
|
|
| 3814 |
}
|
| 3815 |
|
| 3816 |
|
| 3817 |
-
/*
|
| 3818 |
-
Plain text fallback.
|
| 3819 |
-
*/
|
| 3820 |
-
|
| 3821 |
const fallbackPrompt =
|
| 3822 |
systemPrompt()
|
| 3823 |
+
|
|
@@ -3865,7 +3939,7 @@ async function generateAnswer(
|
|
| 3865 |
|
| 3866 |
|
| 3867 |
/* ================================
|
| 3868 |
-
|
| 3869 |
================================ */
|
| 3870 |
|
| 3871 |
function addMessage(
|
|
@@ -4024,15 +4098,11 @@ function parseFlashcards(
|
|
| 4024 |
}
|
| 4025 |
|
| 4026 |
|
| 4027 |
-
|
| 4028 |
-
/* ================================
|
| 4029 |
-
RENDER RESPONSE
|
| 4030 |
-
================================ */
|
| 4031 |
-
|
| 4032 |
function renderAIResponse(
|
| 4033 |
bubble,
|
| 4034 |
text,
|
| 4035 |
-
responseMode
|
|
|
|
| 4036 |
) {
|
| 4037 |
|
| 4038 |
if (
|
|
@@ -4070,6 +4140,10 @@ function renderAIResponse(
|
|
| 4070 |
);
|
| 4071 |
|
| 4072 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4073 |
card.className =
|
| 4074 |
"flashcard";
|
| 4075 |
|
|
@@ -4145,6 +4219,9 @@ function renderAIResponse(
|
|
| 4145 |
:
|
| 4146 |
"Tap to reveal";
|
| 4147 |
|
|
|
|
|
|
|
|
|
|
| 4148 |
}
|
| 4149 |
);
|
| 4150 |
|
|
@@ -4157,7 +4234,13 @@ function renderAIResponse(
|
|
| 4157 |
);
|
| 4158 |
|
| 4159 |
|
| 4160 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4161 |
|
| 4162 |
|
| 4163 |
return;
|
|
@@ -4223,14 +4306,20 @@ function renderAIResponse(
|
|
| 4223 |
}
|
| 4224 |
|
| 4225 |
|
| 4226 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4227 |
|
| 4228 |
}
|
| 4229 |
|
| 4230 |
|
| 4231 |
|
| 4232 |
/* ================================
|
| 4233 |
-
SEND
|
| 4234 |
================================ */
|
| 4235 |
|
| 4236 |
async function sendMessage() {
|
|
@@ -4241,6 +4330,8 @@ async function sendMessage() {
|
|
| 4241 |
|
| 4242 |
if (
|
| 4243 |
!text
|
|
|
|
|
|
|
| 4244 |
) {
|
| 4245 |
|
| 4246 |
return;
|
|
@@ -4295,11 +4386,8 @@ async function sendMessage() {
|
|
| 4295 |
saveChats();
|
| 4296 |
|
| 4297 |
|
| 4298 |
-
|
| 4299 |
/*
|
| 4300 |
-
Hide subject / mode /
|
| 4301 |
-
suggestion controls after
|
| 4302 |
-
first message.
|
| 4303 |
*/
|
| 4304 |
|
| 4305 |
document.body
|
|
@@ -4319,8 +4407,7 @@ async function sendMessage() {
|
|
| 4319 |
"";
|
| 4320 |
|
| 4321 |
|
| 4322 |
-
|
| 4323 |
-
"auto";
|
| 4324 |
|
| 4325 |
|
| 4326 |
updateSendState();
|
|
@@ -4345,7 +4432,6 @@ async function sendMessage() {
|
|
| 4345 |
scrollToBottom();
|
| 4346 |
|
| 4347 |
|
| 4348 |
-
|
| 4349 |
const responseBubble =
|
| 4350 |
addMessage(
|
| 4351 |
|
|
@@ -4503,9 +4589,26 @@ async function sendMessage() {
|
|
| 4503 |
|
| 4504 |
|
| 4505 |
/* ================================
|
| 4506 |
-
|
| 4507 |
================================ */
|
| 4508 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4509 |
function updateSendState() {
|
| 4510 |
|
| 4511 |
sendButton
|
|
@@ -4529,17 +4632,7 @@ messageInput.addEventListener(
|
|
| 4529 |
"input",
|
| 4530 |
() => {
|
| 4531 |
|
| 4532 |
-
|
| 4533 |
-
"auto";
|
| 4534 |
-
|
| 4535 |
-
|
| 4536 |
-
messageInput.style.height =
|
| 4537 |
-
Math.min(
|
| 4538 |
-
messageInput.scrollHeight,
|
| 4539 |
-
150
|
| 4540 |
-
)
|
| 4541 |
-
+
|
| 4542 |
-
"px";
|
| 4543 |
|
| 4544 |
|
| 4545 |
updateSendState();
|
|
@@ -4667,7 +4760,7 @@ document
|
|
| 4667 |
|
| 4668 |
|
| 4669 |
/* ================================
|
| 4670 |
-
|
| 4671 |
================================ */
|
| 4672 |
|
| 4673 |
document
|
|
@@ -4771,8 +4864,10 @@ document.addEventListener(
|
|
| 4771 |
|
| 4772 |
const tag =
|
| 4773 |
event.target
|
| 4774 |
-
.tagName
|
| 4775 |
-
.toLowerCase()
|
|
|
|
|
|
|
| 4776 |
|
| 4777 |
|
| 4778 |
if (
|
|
@@ -4780,21 +4875,15 @@ document.addEventListener(
|
|
| 4780 |
.toLowerCase()
|
| 4781 |
===
|
| 4782 |
"n"
|
| 4783 |
-
|
| 4784 |
&&
|
| 4785 |
-
|
| 4786 |
tag
|
| 4787 |
!==
|
| 4788 |
"input"
|
| 4789 |
-
|
| 4790 |
&&
|
| 4791 |
-
|
| 4792 |
tag
|
| 4793 |
!==
|
| 4794 |
"textarea"
|
| 4795 |
-
|
| 4796 |
&&
|
| 4797 |
-
|
| 4798 |
!pickerBackdrop
|
| 4799 |
.classList
|
| 4800 |
.contains(
|
|
@@ -4815,6 +4904,13 @@ document.addEventListener(
|
|
| 4815 |
|
| 4816 |
closePicker();
|
| 4817 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4818 |
}
|
| 4819 |
|
| 4820 |
}
|
|
|
|
| 68 |
<button
|
| 69 |
id="continueButton"
|
| 70 |
class="auth-continue"
|
| 71 |
+
type="button"
|
| 72 |
>
|
| 73 |
Continue
|
| 74 |
</button>
|
|
|
|
| 124 |
<button
|
| 125 |
id="pickerClose"
|
| 126 |
class="picker-close"
|
| 127 |
+
type="button"
|
| 128 |
>
|
| 129 |
×
|
| 130 |
</button>
|
|
|
|
| 190 |
<button
|
| 191 |
id="closeSidebar"
|
| 192 |
class="brand-close"
|
| 193 |
+
type="button"
|
| 194 |
>
|
| 195 |
×
|
| 196 |
</button>
|
|
|
|
| 203 |
<button
|
| 204 |
id="newChat"
|
| 205 |
class="new-chat"
|
| 206 |
+
type="button"
|
| 207 |
>
|
| 208 |
|
| 209 |
<span class="new-plus">
|
|
|
|
| 257 |
<button
|
| 258 |
id="subjectSidebarButton"
|
| 259 |
class="side-setting"
|
| 260 |
+
type="button"
|
| 261 |
>
|
| 262 |
|
| 263 |
<span class="side-setting-icon">
|
|
|
|
| 290 |
<button
|
| 291 |
id="modeSidebarButton"
|
| 292 |
class="side-setting"
|
| 293 |
+
type="button"
|
| 294 |
>
|
| 295 |
|
| 296 |
<span class="side-setting-icon">
|
|
|
|
| 323 |
<button
|
| 324 |
id="modelSidebarButton"
|
| 325 |
class="side-setting"
|
| 326 |
+
type="button"
|
| 327 |
>
|
| 328 |
|
| 329 |
<span class="side-setting-icon">
|
|
|
|
| 429 |
<button
|
| 430 |
id="themeButton"
|
| 431 |
class="theme-button"
|
| 432 |
+
type="button"
|
| 433 |
>
|
| 434 |
☼
|
| 435 |
</button>
|
|
|
|
| 470 |
<button
|
| 471 |
id="signOutButton"
|
| 472 |
class="signout-button"
|
| 473 |
+
type="button"
|
| 474 |
>
|
| 475 |
↪
|
| 476 |
</button>
|
|
|
|
| 498 |
<button
|
| 499 |
id="menuButton"
|
| 500 |
class="menu-button"
|
| 501 |
+
type="button"
|
| 502 |
>
|
| 503 |
☰
|
| 504 |
</button>
|
|
|
|
| 518 |
<button
|
| 519 |
id="breadcrumbSubject"
|
| 520 |
class="breadcrumb-subject"
|
| 521 |
+
type="button"
|
| 522 |
>
|
| 523 |
Math
|
| 524 |
</button>
|
|
|
|
| 532 |
<button
|
| 533 |
id="focusButton"
|
| 534 |
class="focus-button"
|
| 535 |
+
type="button"
|
| 536 |
>
|
| 537 |
|
| 538 |
<span class="focus-dot">
|
|
|
|
| 548 |
<button
|
| 549 |
id="moonButton"
|
| 550 |
class="moon-button"
|
| 551 |
+
type="button"
|
| 552 |
>
|
| 553 |
☾
|
| 554 |
</button>
|
|
|
|
| 708 |
<button
|
| 709 |
id="subjectPickerButton"
|
| 710 |
class="focus-picker"
|
| 711 |
+
type="button"
|
| 712 |
>
|
| 713 |
|
| 714 |
<span class="focus-picker-icon">
|
|
|
|
| 741 |
<button
|
| 742 |
id="modePickerButton"
|
| 743 |
class="focus-picker"
|
| 744 |
+
type="button"
|
| 745 |
>
|
| 746 |
|
| 747 |
<span class="focus-picker-icon">
|
|
|
|
| 833 |
<button
|
| 834 |
id="sendButton"
|
| 835 |
class="send-button"
|
| 836 |
+
type="button"
|
| 837 |
>
|
| 838 |
◇
|
| 839 |
</button>
|
|
|
|
| 921 |
|
| 922 |
|
| 923 |
|
| 924 |
+
<script>
|
| 925 |
|
| 926 |
|
| 927 |
+
/*
|
| 928 |
+
IMPORTANT FIX:
|
| 929 |
+
|
| 930 |
+
The page no longer imports Transformers.js
|
| 931 |
+
before the login buttons are created.
|
|
|
|
| 932 |
|
| 933 |
+
The AI library is downloaded later, only when
|
| 934 |
+
FYRStudyGPT actually needs it.
|
| 935 |
|
| 936 |
+
Therefore login still works even if Hugging Face
|
| 937 |
+
or the AI model has a loading problem.
|
| 938 |
+
*/
|
| 939 |
|
| 940 |
|
| 941 |
+
let transformersPipeline =
|
| 942 |
+
null;
|
| 943 |
+
|
| 944 |
+
|
| 945 |
+
let transformersEnv =
|
| 946 |
+
null;
|
| 947 |
+
|
| 948 |
+
|
| 949 |
+
|
| 950 |
+
async function ensureTransformers() {
|
| 951 |
+
|
| 952 |
+
if (
|
| 953 |
+
transformersPipeline
|
| 954 |
+
) {
|
| 955 |
+
|
| 956 |
+
return;
|
| 957 |
+
|
| 958 |
+
}
|
| 959 |
+
|
| 960 |
+
|
| 961 |
+
const transformers =
|
| 962 |
+
await import(
|
| 963 |
+
"https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.8.1"
|
| 964 |
+
);
|
| 965 |
+
|
| 966 |
+
|
| 967 |
+
transformersPipeline =
|
| 968 |
+
transformers.pipeline;
|
| 969 |
+
|
| 970 |
+
|
| 971 |
+
transformersEnv =
|
| 972 |
+
transformers.env;
|
| 973 |
+
|
| 974 |
+
|
| 975 |
+
transformersEnv.allowLocalModels =
|
| 976 |
+
false;
|
| 977 |
+
|
| 978 |
+
|
| 979 |
+
transformersEnv.useBrowserCache =
|
| 980 |
+
true;
|
| 981 |
+
|
| 982 |
+
}
|
| 983 |
|
| 984 |
|
| 985 |
|
|
|
|
| 1159 |
|
| 1160 |
|
| 1161 |
/* ================================
|
| 1162 |
+
MODES
|
| 1163 |
================================ */
|
| 1164 |
|
| 1165 |
const MODES = [
|
|
|
|
| 1242 |
|
| 1243 |
|
| 1244 |
/* ================================
|
| 1245 |
+
MODELS FOR PICKER
|
| 1246 |
================================ */
|
| 1247 |
|
| 1248 |
const MODEL_OPTIONS = [
|
|
|
|
| 1274 |
"Balanced",
|
| 1275 |
|
| 1276 |
description:
|
| 1277 |
+
"SmolLM2 360M · stronger answers"
|
| 1278 |
},
|
| 1279 |
|
| 1280 |
|
|
|
|
| 1298 |
|
| 1299 |
|
| 1300 |
/* ================================
|
| 1301 |
+
MODE UI
|
| 1302 |
================================ */
|
| 1303 |
|
| 1304 |
const MODE_DATA = {
|
|
|
|
| 1503 |
);
|
| 1504 |
|
| 1505 |
|
| 1506 |
+
const continueButton =
|
| 1507 |
+
document.getElementById(
|
| 1508 |
+
"continueButton"
|
| 1509 |
+
);
|
| 1510 |
+
|
| 1511 |
+
|
| 1512 |
const workspace =
|
| 1513 |
document.getElementById(
|
| 1514 |
"workspace"
|
|
|
|
| 1607 |
|
| 1608 |
|
| 1609 |
/* ================================
|
| 1610 |
+
SCROLL
|
| 1611 |
================================ */
|
| 1612 |
|
| 1613 |
function scrollToBottom(
|
|
|
|
| 1750 |
|
| 1751 |
|
| 1752 |
/* ================================
|
| 1753 |
+
LOGIN
|
| 1754 |
================================ */
|
| 1755 |
|
| 1756 |
function continueProfile() {
|
|
|
|
| 1802 |
.toUpperCase();
|
| 1803 |
|
| 1804 |
|
| 1805 |
+
/*
|
| 1806 |
+
LOGIN HAPPENS IMMEDIATELY HERE.
|
| 1807 |
+
|
| 1808 |
+
It does NOT wait for the AI.
|
| 1809 |
+
*/
|
| 1810 |
+
|
| 1811 |
authOverlay.style.display =
|
| 1812 |
"none";
|
| 1813 |
|
|
|
|
| 1841 |
newChat();
|
| 1842 |
|
| 1843 |
|
| 1844 |
+
/*
|
| 1845 |
+
AI loads AFTER login.
|
| 1846 |
+
Failure here will not block login.
|
| 1847 |
+
*/
|
| 1848 |
|
| 1849 |
+
setTimeout(
|
| 1850 |
+
() => {
|
| 1851 |
+
|
| 1852 |
+
loadAI()
|
| 1853 |
+
.catch(
|
| 1854 |
+
error => {
|
| 1855 |
+
|
| 1856 |
+
console.warn(
|
| 1857 |
+
"AI background loading failed:",
|
| 1858 |
+
error
|
| 1859 |
+
);
|
| 1860 |
+
|
| 1861 |
+
}
|
| 1862 |
);
|
| 1863 |
|
| 1864 |
+
},
|
| 1865 |
+
50
|
| 1866 |
);
|
| 1867 |
|
| 1868 |
}
|
| 1869 |
|
| 1870 |
|
| 1871 |
|
| 1872 |
+
continueButton.addEventListener(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1873 |
"click",
|
| 1874 |
continueProfile
|
| 1875 |
);
|
|
|
|
| 1885 |
"Enter"
|
| 1886 |
) {
|
| 1887 |
|
| 1888 |
+
event.preventDefault();
|
| 1889 |
+
|
| 1890 |
continueProfile();
|
| 1891 |
|
| 1892 |
}
|
|
|
|
| 1896 |
|
| 1897 |
|
| 1898 |
|
| 1899 |
+
/* ================================
|
| 1900 |
+
SIGN OUT
|
| 1901 |
+
================================ */
|
| 1902 |
+
|
| 1903 |
document
|
| 1904 |
.getElementById(
|
| 1905 |
"signOutButton"
|
|
|
|
| 1934 |
authOverlay.style.display =
|
| 1935 |
"flex";
|
| 1936 |
|
| 1937 |
+
|
| 1938 |
+
profileInput.focus();
|
| 1939 |
+
|
| 1940 |
}
|
| 1941 |
);
|
| 1942 |
|
|
|
|
| 2036 |
);
|
| 2037 |
|
| 2038 |
|
| 2039 |
+
button.type =
|
| 2040 |
+
"button";
|
| 2041 |
+
|
| 2042 |
+
|
| 2043 |
button.className =
|
| 2044 |
"saved-chat"
|
| 2045 |
+
|
|
|
|
| 2157 |
|
| 2158 |
|
| 2159 |
/* ================================
|
| 2160 |
+
OPEN CHAT
|
| 2161 |
================================ */
|
| 2162 |
|
| 2163 |
async function openChat(
|
|
|
|
| 2280 |
item.content,
|
| 2281 |
item.mode
|
| 2282 |
||
|
| 2283 |
+
mode,
|
| 2284 |
+
false
|
| 2285 |
);
|
| 2286 |
|
| 2287 |
}
|
|
|
|
| 2419 |
|
| 2420 |
|
| 2421 |
/* ================================
|
| 2422 |
+
PICKERS
|
| 2423 |
================================ */
|
| 2424 |
|
| 2425 |
function openPicker(
|
|
|
|
| 2466 |
}
|
| 2467 |
|
| 2468 |
|
| 2469 |
+
else if (
|
| 2470 |
type
|
| 2471 |
===
|
| 2472 |
"mode"
|
|
|
|
| 2490 |
}
|
| 2491 |
|
| 2492 |
|
| 2493 |
+
else if (
|
| 2494 |
type
|
| 2495 |
===
|
| 2496 |
"model"
|
|
|
|
| 2501 |
|
| 2502 |
|
| 2503 |
pickerSubtitle.textContent =
|
| 2504 |
+
"Larger models may give stronger answers but take longer to load.";
|
| 2505 |
|
| 2506 |
|
| 2507 |
items =
|
|
|
|
| 2534 |
);
|
| 2535 |
|
| 2536 |
|
| 2537 |
+
button.type =
|
| 2538 |
+
"button";
|
| 2539 |
+
|
| 2540 |
+
|
| 2541 |
button.className =
|
| 2542 |
"picker-option"
|
| 2543 |
+
|
|
|
|
| 2641 |
"click",
|
| 2642 |
async () => {
|
| 2643 |
|
| 2644 |
+
const pickerType =
|
| 2645 |
+
activePicker;
|
| 2646 |
+
|
| 2647 |
+
|
| 2648 |
if (
|
| 2649 |
+
pickerType
|
| 2650 |
===
|
| 2651 |
"subject"
|
| 2652 |
) {
|
|
|
|
| 2657 |
|
| 2658 |
updateAllUI();
|
| 2659 |
|
| 2660 |
+
|
| 2661 |
+
closePicker();
|
| 2662 |
+
|
| 2663 |
}
|
| 2664 |
|
| 2665 |
|
| 2666 |
else if (
|
| 2667 |
+
pickerType
|
| 2668 |
===
|
| 2669 |
"mode"
|
| 2670 |
) {
|
|
|
|
| 2679 |
|
| 2680 |
updateAllUI();
|
| 2681 |
|
| 2682 |
+
|
| 2683 |
+
closePicker();
|
| 2684 |
+
|
| 2685 |
}
|
| 2686 |
|
| 2687 |
|
| 2688 |
else if (
|
| 2689 |
+
pickerType
|
| 2690 |
===
|
| 2691 |
"model"
|
| 2692 |
) {
|
|
|
|
| 2698 |
value
|
| 2699 |
);
|
| 2700 |
|
|
|
|
|
|
|
|
|
|
| 2701 |
}
|
| 2702 |
|
|
|
|
|
|
|
|
|
|
| 2703 |
}
|
| 2704 |
);
|
| 2705 |
|
|
|
|
| 2736 |
}
|
| 2737 |
|
| 2738 |
|
|
|
|
| 2739 |
document
|
| 2740 |
.getElementById(
|
| 2741 |
"pickerClose"
|
|
|
|
| 2979 |
);
|
| 2980 |
|
| 2981 |
|
| 2982 |
+
button.type =
|
| 2983 |
+
"button";
|
| 2984 |
+
|
| 2985 |
+
|
| 2986 |
button.className =
|
| 2987 |
"suggestion";
|
| 2988 |
|
|
|
|
| 3028 |
messageInput.focus();
|
| 3029 |
|
| 3030 |
|
| 3031 |
+
resizeInput();
|
| 3032 |
+
|
| 3033 |
+
|
| 3034 |
updateSendState();
|
| 3035 |
|
| 3036 |
}
|
|
|
|
| 3049 |
|
| 3050 |
|
| 3051 |
/* ================================
|
| 3052 |
+
MODEL
|
| 3053 |
================================ */
|
| 3054 |
|
| 3055 |
async function releaseModel() {
|
|
|
|
| 3096 |
}
|
| 3097 |
|
| 3098 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3099 |
async function chooseModel(
|
| 3100 |
key
|
| 3101 |
) {
|
|
|
|
| 3174 |
|
| 3175 |
|
| 3176 |
/* ================================
|
| 3177 |
+
LOADING
|
| 3178 |
================================ */
|
| 3179 |
|
| 3180 |
function updateProgress(
|
|
|
|
| 3210 |
}
|
| 3211 |
|
| 3212 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3213 |
async function loadAttempt(
|
| 3214 |
+
model,
|
| 3215 |
options,
|
| 3216 |
runtimeName
|
| 3217 |
) {
|
|
|
|
| 3224 |
runtimeName;
|
| 3225 |
|
| 3226 |
|
| 3227 |
+
return await transformersPipeline(
|
| 3228 |
|
| 3229 |
"text-generation",
|
| 3230 |
|
| 3231 |
+
model.id,
|
| 3232 |
|
| 3233 |
{
|
| 3234 |
|
|
|
|
| 3277 |
}
|
| 3278 |
|
| 3279 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3280 |
async function loadAI() {
|
| 3281 |
|
| 3282 |
if (
|
|
|
|
| 3297 |
}
|
| 3298 |
|
| 3299 |
|
| 3300 |
+
const model =
|
| 3301 |
+
getModel();
|
| 3302 |
+
|
| 3303 |
+
|
| 3304 |
loadingPromise =
|
| 3305 |
(
|
| 3306 |
async () => {
|
|
|
|
| 3325 |
"Preparing FYRStudyGPT…";
|
| 3326 |
|
| 3327 |
|
| 3328 |
+
/*
|
| 3329 |
+
Load Transformers.js only now.
|
| 3330 |
+
*/
|
| 3331 |
+
|
| 3332 |
+
await ensureTransformers();
|
| 3333 |
|
| 3334 |
|
| 3335 |
const attempts =
|
| 3336 |
[];
|
| 3337 |
|
| 3338 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3339 |
if (
|
| 3340 |
"gpu"
|
| 3341 |
in
|
|
|
|
| 3364 |
}
|
| 3365 |
|
| 3366 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3367 |
attempts.push({
|
| 3368 |
|
| 3369 |
name:
|
|
|
|
| 3408 |
|
| 3409 |
generator =
|
| 3410 |
await loadAttempt(
|
| 3411 |
+
model,
|
| 3412 |
attempt.options,
|
| 3413 |
attempt.name
|
| 3414 |
);
|
|
|
|
| 3561 |
|
| 3562 |
|
| 3563 |
/* ================================
|
| 3564 |
+
AI PROMPT
|
| 3565 |
================================ */
|
| 3566 |
|
| 3567 |
function systemPrompt() {
|
|
|
|
| 3589 |
}
|
| 3590 |
|
| 3591 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3592 |
function createPrompt(
|
| 3593 |
text
|
| 3594 |
) {
|
|
|
|
| 3750 |
|
| 3751 |
|
| 3752 |
/* ================================
|
| 3753 |
+
OUTPUT
|
| 3754 |
================================ */
|
| 3755 |
|
| 3756 |
function extractOutput(
|
|
|
|
| 3806 |
}
|
| 3807 |
|
| 3808 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3809 |
async function generateAnswer(
|
| 3810 |
prompt
|
| 3811 |
) {
|
|
|
|
| 3841 |
];
|
| 3842 |
|
| 3843 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3844 |
try {
|
| 3845 |
|
| 3846 |
const result =
|
|
|
|
| 3892 |
}
|
| 3893 |
|
| 3894 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3895 |
const fallbackPrompt =
|
| 3896 |
systemPrompt()
|
| 3897 |
+
|
|
|
|
| 3939 |
|
| 3940 |
|
| 3941 |
/* ================================
|
| 3942 |
+
MESSAGE UI
|
| 3943 |
================================ */
|
| 3944 |
|
| 3945 |
function addMessage(
|
|
|
|
| 4098 |
}
|
| 4099 |
|
| 4100 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4101 |
function renderAIResponse(
|
| 4102 |
bubble,
|
| 4103 |
text,
|
| 4104 |
+
responseMode,
|
| 4105 |
+
autoScroll = true
|
| 4106 |
) {
|
| 4107 |
|
| 4108 |
if (
|
|
|
|
| 4140 |
);
|
| 4141 |
|
| 4142 |
|
| 4143 |
+
card.type =
|
| 4144 |
+
"button";
|
| 4145 |
+
|
| 4146 |
+
|
| 4147 |
card.className =
|
| 4148 |
"flashcard";
|
| 4149 |
|
|
|
|
| 4219 |
:
|
| 4220 |
"Tap to reveal";
|
| 4221 |
|
| 4222 |
+
|
| 4223 |
+
scrollToBottom();
|
| 4224 |
+
|
| 4225 |
}
|
| 4226 |
);
|
| 4227 |
|
|
|
|
| 4234 |
);
|
| 4235 |
|
| 4236 |
|
| 4237 |
+
if (
|
| 4238 |
+
autoScroll
|
| 4239 |
+
) {
|
| 4240 |
+
|
| 4241 |
+
scrollToBottom();
|
| 4242 |
+
|
| 4243 |
+
}
|
| 4244 |
|
| 4245 |
|
| 4246 |
return;
|
|
|
|
| 4306 |
}
|
| 4307 |
|
| 4308 |
|
| 4309 |
+
if (
|
| 4310 |
+
autoScroll
|
| 4311 |
+
) {
|
| 4312 |
+
|
| 4313 |
+
scrollToBottom();
|
| 4314 |
+
|
| 4315 |
+
}
|
| 4316 |
|
| 4317 |
}
|
| 4318 |
|
| 4319 |
|
| 4320 |
|
| 4321 |
/* ================================
|
| 4322 |
+
SEND
|
| 4323 |
================================ */
|
| 4324 |
|
| 4325 |
async function sendMessage() {
|
|
|
|
| 4330 |
|
| 4331 |
if (
|
| 4332 |
!text
|
| 4333 |
+
||
|
| 4334 |
+
sendButton.disabled
|
| 4335 |
) {
|
| 4336 |
|
| 4337 |
return;
|
|
|
|
| 4386 |
saveChats();
|
| 4387 |
|
| 4388 |
|
|
|
|
| 4389 |
/*
|
| 4390 |
+
Hide subject / mode / suggestions.
|
|
|
|
|
|
|
| 4391 |
*/
|
| 4392 |
|
| 4393 |
document.body
|
|
|
|
| 4407 |
"";
|
| 4408 |
|
| 4409 |
|
| 4410 |
+
resizeInput();
|
|
|
|
| 4411 |
|
| 4412 |
|
| 4413 |
updateSendState();
|
|
|
|
| 4432 |
scrollToBottom();
|
| 4433 |
|
| 4434 |
|
|
|
|
| 4435 |
const responseBubble =
|
| 4436 |
addMessage(
|
| 4437 |
|
|
|
|
| 4589 |
|
| 4590 |
|
| 4591 |
/* ================================
|
| 4592 |
+
TEXTAREA
|
| 4593 |
================================ */
|
| 4594 |
|
| 4595 |
+
function resizeInput() {
|
| 4596 |
+
|
| 4597 |
+
messageInput.style.height =
|
| 4598 |
+
"auto";
|
| 4599 |
+
|
| 4600 |
+
|
| 4601 |
+
messageInput.style.height =
|
| 4602 |
+
Math.min(
|
| 4603 |
+
messageInput.scrollHeight,
|
| 4604 |
+
150
|
| 4605 |
+
)
|
| 4606 |
+
+
|
| 4607 |
+
"px";
|
| 4608 |
+
|
| 4609 |
+
}
|
| 4610 |
+
|
| 4611 |
+
|
| 4612 |
function updateSendState() {
|
| 4613 |
|
| 4614 |
sendButton
|
|
|
|
| 4632 |
"input",
|
| 4633 |
() => {
|
| 4634 |
|
| 4635 |
+
resizeInput();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4636 |
|
| 4637 |
|
| 4638 |
updateSendState();
|
|
|
|
| 4760 |
|
| 4761 |
|
| 4762 |
/* ================================
|
| 4763 |
+
SIDEBAR
|
| 4764 |
================================ */
|
| 4765 |
|
| 4766 |
document
|
|
|
|
| 4864 |
|
| 4865 |
const tag =
|
| 4866 |
event.target
|
| 4867 |
+
?.tagName
|
| 4868 |
+
?.toLowerCase()
|
| 4869 |
+
||
|
| 4870 |
+
"";
|
| 4871 |
|
| 4872 |
|
| 4873 |
if (
|
|
|
|
| 4875 |
.toLowerCase()
|
| 4876 |
===
|
| 4877 |
"n"
|
|
|
|
| 4878 |
&&
|
|
|
|
| 4879 |
tag
|
| 4880 |
!==
|
| 4881 |
"input"
|
|
|
|
| 4882 |
&&
|
|
|
|
| 4883 |
tag
|
| 4884 |
!==
|
| 4885 |
"textarea"
|
|
|
|
| 4886 |
&&
|
|
|
|
| 4887 |
!pickerBackdrop
|
| 4888 |
.classList
|
| 4889 |
.contains(
|
|
|
|
| 4904 |
|
| 4905 |
closePicker();
|
| 4906 |
|
| 4907 |
+
|
| 4908 |
+
document.body
|
| 4909 |
+
.classList
|
| 4910 |
+
.remove(
|
| 4911 |
+
"sidebar-open"
|
| 4912 |
+
);
|
| 4913 |
+
|
| 4914 |
}
|
| 4915 |
|
| 4916 |
}
|