const results = []; document.getElementById('fileUpload').addEventListener('change', async function () { const file = this.files[0]; if (!file) return; // Show selected file name document.getElementById('fileName').textContent = `Selected file: ${file.name}`; const text = await file.text(); const prompts = text.split(/\r?\n/).filter(Boolean); // Show loading animation document.getElementById('loading').style.display = "block"; for (const prompt of prompts) { await send(prompt); } // Hide loading animation document.getElementById('loading').style.display = "none"; }); async function send() { const model = document.getElementById("model").value; const prompt = document.getElementById("prompt").value; const loadingEl = document.getElementById("loading"); const outputEl = document.getElementById("responseOutput"); outputEl.textContent = ""; loadingEl.style.display = "block"; let responseText = ""; if (model.includes("gemma")) { responseText = await callGemma(prompt); } else if (model.includes("deepseek")) { responseText = await callDeepSeek(prompt); // This uses DeepSeek's own API } loadingEl.style.display = "none"; outputEl.textContent = responseText; } async function callGemma(prompt) { const res = await fetch("https://openrouter.ai/api/v1/chat/completions", { method: "POST", headers: { "Authorization": "Bearer " + "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", "Content-Type": "application/json", /*"HTTP-Referer": "https://huggingface.co/spaces/studycode129/Free_Web_LLM_Tester"*/ }, body: JSON.stringify({ inputs: prompt }) }); const result = await response.json(); return result[0]?.generated_text || "No response"; } async function callDeepSeek(prompt) { const response = await fetch("https://api.deepseek.com/v1/chat/completions", { method: "POST", headers: { "Authorization": "Bearer" + "sk-13b9eb0edb6c4c7d908b14a2a196f122", "Content-Type": "application/json" }, body: JSON.stringify({ messages: [{ role: "user", content: prompt }] }) }); const result = await response.json(); return result.choices?.[0]?.message?.content || "No response"; } const data = await res.json(); const output = data.choices?.[0]?.message?.content || JSON.stringify(data); document.getElementById('responseOutput').textContent = modelReply; results.push({ model, prompt, output }); } function downloadCSV() { let csv = "Model,Prompt,Output\n"; results.forEach(row => { csv += `"${row.model}","${row.prompt.replace(/\n/g, " ")}","${row.output.replace(/\n/g, " ")}"\n`; }); const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' }); const link = document.createElement("a"); link.href = URL.createObjectURL(blob); link.download = "llm_test_results.csv"; link.click(); }