Update app.js
Browse files
app.js
CHANGED
@@ -21,23 +21,61 @@ const results = [];
|
|
21 |
document.getElementById('loading').style.display = "none";
|
22 |
});
|
23 |
|
24 |
-
|
25 |
-
|
26 |
-
|
|
|
|
|
27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
const res = await fetch("https://openrouter.ai/api/v1/chat/completions", {
|
29 |
method: "POST",
|
30 |
headers: {
|
31 |
"Authorization": "Bearer " + "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",
|
32 |
"Content-Type": "application/json",
|
33 |
-
"HTTP-Referer": "https://huggingface.co/spaces/studycode129/Free_Web_LLM_Tester"
|
34 |
},
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
const data = await res.json();
|
43 |
const output = data.choices?.[0]?.message?.content || JSON.stringify(data);
|
|
|
21 |
document.getElementById('loading').style.display = "none";
|
22 |
});
|
23 |
|
24 |
+
async function send() {
|
25 |
+
const model = document.getElementById("model").value;
|
26 |
+
const prompt = document.getElementById("prompt").value;
|
27 |
+
const loadingEl = document.getElementById("loading");
|
28 |
+
const outputEl = document.getElementById("responseOutput");
|
29 |
|
30 |
+
outputEl.textContent = "";
|
31 |
+
loadingEl.style.display = "block";
|
32 |
+
|
33 |
+
let responseText = "";
|
34 |
+
|
35 |
+
if (model.includes("gemma")) {
|
36 |
+
responseText = await callGemma(prompt);
|
37 |
+
} else if (model.includes("deepseek")) {
|
38 |
+
responseText = await callDeepSeek(prompt); // This uses DeepSeek's own API
|
39 |
+
}
|
40 |
+
|
41 |
+
loadingEl.style.display = "none";
|
42 |
+
outputEl.textContent = responseText;
|
43 |
+
}
|
44 |
+
|
45 |
+
|
46 |
+
|
47 |
+
async function callGemma(prompt) {
|
48 |
const res = await fetch("https://openrouter.ai/api/v1/chat/completions", {
|
49 |
method: "POST",
|
50 |
headers: {
|
51 |
"Authorization": "Bearer " + "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",
|
52 |
"Content-Type": "application/json",
|
53 |
+
/*"HTTP-Referer": "https://huggingface.co/spaces/studycode129/Free_Web_LLM_Tester"*/
|
54 |
},
|
55 |
+
body: JSON.stringify({ inputs: prompt })
|
56 |
+
});
|
57 |
+
|
58 |
+
const result = await response.json();
|
59 |
+
return result[0]?.generated_text || "No response";
|
60 |
+
}
|
61 |
+
|
62 |
+
|
63 |
+
async function callDeepSeek(prompt) {
|
64 |
+
const response = await fetch("https://api.deepseek.com/v1/chat/completions", {
|
65 |
+
method: "POST",
|
66 |
+
headers: {
|
67 |
+
"Authorization": "Bearer" + "sk-13b9eb0edb6c4c7d908b14a2a196f122",
|
68 |
+
"Content-Type": "application/json"
|
69 |
+
},
|
70 |
+
body: JSON.stringify({
|
71 |
+
messages: [{ role: "user", content: prompt }]
|
72 |
+
})
|
73 |
+
});
|
74 |
+
|
75 |
+
const result = await response.json();
|
76 |
+
return result.choices?.[0]?.message?.content || "No response";
|
77 |
+
}
|
78 |
+
|
79 |
|
80 |
const data = await res.json();
|
81 |
const output = data.choices?.[0]?.message?.content || JSON.stringify(data);
|