File size: 3,076 Bytes
c04e9aa
608081c
c04e9aa
 
 
7f7d5bf
 
 
 
c04e9aa
 
608081c
7f7d5bf
 
 
c04e9aa
 
 
7f7d5bf
 
 
c04e9aa
 
cbdf969
 
 
 
 
c04e9aa
cbdf969
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c04e9aa
 
 
f164c51
c04e9aa
cbdf969
c04e9aa
cbdf969
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c04e9aa
 
 
7f7d5bf
 
c04e9aa
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
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();
    }