Update static/script.js
Browse files- static/script.js +57 -15
static/script.js
CHANGED
|
@@ -1,3 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
// === Theme Toggle ===
|
| 2 |
const themeToggle = document.getElementById("themeToggle");
|
| 3 |
const toggleConfig = document.getElementById("toggleConfig");
|
|
@@ -11,9 +58,7 @@ function setInitialTheme() {
|
|
| 11 |
} else if (savedTheme === "light") {
|
| 12 |
html.classList.remove("dark");
|
| 13 |
} else {
|
| 14 |
-
const prefersDark = window.matchMedia(
|
| 15 |
-
"(prefers-color-scheme: dark)",
|
| 16 |
-
).matches;
|
| 17 |
if (prefersDark) html.classList.add("dark");
|
| 18 |
else html.classList.remove("dark");
|
| 19 |
}
|
|
@@ -35,9 +80,9 @@ const chatForm = document.getElementById("chatForm");
|
|
| 35 |
const userInput = document.getElementById("userInput");
|
| 36 |
const chatContainer = document.getElementById("chatContainer");
|
| 37 |
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
|
| 42 |
function appendMessage(role, text) {
|
| 43 |
const div = document.createElement("div");
|
|
@@ -59,16 +104,16 @@ chatForm.addEventListener("submit", async (e) => {
|
|
| 59 |
|
| 60 |
const settings = {
|
| 61 |
models: {
|
| 62 |
-
"LLM-A": modelA.value,
|
| 63 |
-
"LLM-B": modelB.value,
|
| 64 |
-
"LLM-C": modelC.value,
|
| 65 |
-
}
|
| 66 |
};
|
| 67 |
|
| 68 |
const response = await fetch("/chat", {
|
| 69 |
method: "POST",
|
| 70 |
headers: { "Content-Type": "application/json" },
|
| 71 |
-
body: JSON.stringify({ prompt, settings })
|
| 72 |
});
|
| 73 |
|
| 74 |
chatContainer.lastChild.remove(); // remove 'Thinking...'
|
|
@@ -77,9 +122,6 @@ chatForm.addEventListener("submit", async (e) => {
|
|
| 77 |
const data = await response.json();
|
| 78 |
appendMessage("bot", data.response);
|
| 79 |
} else {
|
| 80 |
-
appendMessage(
|
| 81 |
-
"bot",
|
| 82 |
-
"An error occurred. Please check your model selections.",
|
| 83 |
-
);
|
| 84 |
}
|
| 85 |
});
|
|
|
|
| 1 |
+
// === Global Model List ===
|
| 2 |
+
const MODEL_LIST = [
|
| 3 |
+
{ id: "deepseek/deepseek-chat-v3-0324:free", name: "DeepSeek Chat v3" },
|
| 4 |
+
{ id: "google/gemini-2.0-flash-exp:free", name: "Gemini 2.0 Flash" },
|
| 5 |
+
{ id: "meta-llama/llama-4-maverick:free", name: "LLaMA 4 Maverick" },
|
| 6 |
+
{ id: "microsoft/mai-ds-r1:free", name: "MAI DS R1" },
|
| 7 |
+
{ id: "meta-llama/llama-4-scout:free", name: "LLaMA 4 Scout" },
|
| 8 |
+
{ id: "google/gemma-3-27b-it:free", name: "Gemma 3 27B" },
|
| 9 |
+
{ id: "qwen/qwq-32b:free", name: "Qwen QWQ 32B" },
|
| 10 |
+
{ id: "qwen/qwen2.5-vl-72b-instruct:free", name: "Qwen2.5 VL 72B" },
|
| 11 |
+
{ id: "qwen/qwen-2.5-72b-instruct:free", name: "Qwen 2.5 72B" },
|
| 12 |
+
{ id: "google/gemini-2.5-pro-exp-03-25:free", name: "Gemini 2.5 Pro" },
|
| 13 |
+
{ id: "deepseek/deepseek-r1:free", name: "DeepSeek R1" }
|
| 14 |
+
];
|
| 15 |
+
|
| 16 |
+
// === Populate Custom Dropdowns ===
|
| 17 |
+
function createDropdown(dropdownId) {
|
| 18 |
+
const dropdown = document.getElementById(dropdownId);
|
| 19 |
+
const selected = dropdown.querySelector(".selected");
|
| 20 |
+
const options = dropdown.querySelector(".options");
|
| 21 |
+
|
| 22 |
+
MODEL_LIST.forEach(model => {
|
| 23 |
+
const option = document.createElement("div");
|
| 24 |
+
option.className = "p-2 hover:bg-visual_green rounded cursor-pointer";
|
| 25 |
+
option.textContent = model.name;
|
| 26 |
+
option.dataset.value = model.id;
|
| 27 |
+
options.appendChild(option);
|
| 28 |
+
|
| 29 |
+
option.addEventListener("click", (e) => {
|
| 30 |
+
e.stopPropagation();
|
| 31 |
+
selected.textContent = model.name;
|
| 32 |
+
dropdown.dataset.value = model.id;
|
| 33 |
+
options.classList.add("hidden");
|
| 34 |
+
});
|
| 35 |
+
});
|
| 36 |
+
|
| 37 |
+
selected.addEventListener("click", (e) => {
|
| 38 |
+
e.stopPropagation();
|
| 39 |
+
options.classList.toggle("hidden");
|
| 40 |
+
});
|
| 41 |
+
|
| 42 |
+
// Close dropdowns if clicking outside
|
| 43 |
+
document.addEventListener("click", () => {
|
| 44 |
+
options.classList.add("hidden");
|
| 45 |
+
});
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
// === Theme Toggle ===
|
| 49 |
const themeToggle = document.getElementById("themeToggle");
|
| 50 |
const toggleConfig = document.getElementById("toggleConfig");
|
|
|
|
| 58 |
} else if (savedTheme === "light") {
|
| 59 |
html.classList.remove("dark");
|
| 60 |
} else {
|
| 61 |
+
const prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
|
|
|
|
|
| 62 |
if (prefersDark) html.classList.add("dark");
|
| 63 |
else html.classList.remove("dark");
|
| 64 |
}
|
|
|
|
| 80 |
const userInput = document.getElementById("userInput");
|
| 81 |
const chatContainer = document.getElementById("chatContainer");
|
| 82 |
|
| 83 |
+
createDropdown("modelA");
|
| 84 |
+
createDropdown("modelB");
|
| 85 |
+
createDropdown("modelC");
|
| 86 |
|
| 87 |
function appendMessage(role, text) {
|
| 88 |
const div = document.createElement("div");
|
|
|
|
| 104 |
|
| 105 |
const settings = {
|
| 106 |
models: {
|
| 107 |
+
"LLM-A": document.getElementById("modelA").dataset.value,
|
| 108 |
+
"LLM-B": document.getElementById("modelB").dataset.value,
|
| 109 |
+
"LLM-C": document.getElementById("modelC").dataset.value,
|
| 110 |
+
}
|
| 111 |
};
|
| 112 |
|
| 113 |
const response = await fetch("/chat", {
|
| 114 |
method: "POST",
|
| 115 |
headers: { "Content-Type": "application/json" },
|
| 116 |
+
body: JSON.stringify({ prompt, settings })
|
| 117 |
});
|
| 118 |
|
| 119 |
chatContainer.lastChild.remove(); // remove 'Thinking...'
|
|
|
|
| 122 |
const data = await response.json();
|
| 123 |
appendMessage("bot", data.response);
|
| 124 |
} else {
|
| 125 |
+
appendMessage("bot", "An error occurred. Please check your model selections.");
|
|
|
|
|
|
|
|
|
|
| 126 |
}
|
| 127 |
});
|