studycode129 commited on
Commit
3c65d2b
·
verified ·
1 Parent(s): 30b2090

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +29 -38
index.html CHANGED
@@ -143,53 +143,44 @@
143
 
144
  <script>
145
  const results = [];
146
- const key = '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'; // replace this with your actual key
147
 
148
  document.getElementById('fileUpload').addEventListener('change', async function () {
149
- const file = this.files[0];
150
- const fileNameDisplay = document.getElementById('fileName');
151
- fileNameDisplay.textContent = file ? file.name : 'No file selected';
152
- if (!file) return;
153
 
154
- const text = await file.text();
155
- const prompts = text.split(/\r?\n/).filter(Boolean);
156
- document.getElementById('loading').style.display = 'block';
157
 
158
- for (const prompt of prompts) {
159
- await send(prompt);
160
- }
 
 
 
 
 
 
 
 
161
 
162
- document.getElementById('loading').style.display = 'none';
163
- });
164
 
165
  async function send(overridePrompt) {
166
- const model = document.getElementById("model").value;
167
- const prompt = overridePrompt || document.getElementById("prompt").value;
168
- if (!prompt) return;
169
-
170
- document.getElementById('loading').style.display = 'block';
171
-
172
- const res = await fetch("https://openrouter.ai/api/v1/chat/completions", {
173
- method: "POST",
174
- headers: {
175
- "Authorization": "Bearer " + key,
176
- "Content-Type": "application/json",
177
- "HTTP-Referer": "https://huggingface.co/spaces/studycode129/Free_Web_LLM_Tester"
178
- },
179
- body: JSON.stringify({
180
- model,
181
- messages: [{ role: "user", content: prompt }],
182
- temperature: 0.7
183
- })
184
- });
185
 
186
- const data = await res.json();
187
- const output = data.choices?.[0]?.message?.content || JSON.stringify(data);
188
- document.getElementById("response").textContent = output;
 
 
189
 
190
- results.push({ model, prompt, output });
191
- document.getElementById('loading').style.display = 'none';
192
- }
 
 
 
193
 
194
  function downloadCSV() {
195
  let csv = "Model,Prompt,Output\n";
 
143
 
144
  <script>
145
  const results = [];
146
+ // const key = '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'; // replace this with your actual key
147
 
148
  document.getElementById('fileUpload').addEventListener('change', async function () {
149
+ const file = this.files[0];
150
+ if (!file) return;
 
 
151
 
152
+ // Show file name preview
153
+ document.getElementById("fileName").textContent = `📂 Selected: ${file.name}`;
 
154
 
155
+ const text = await file.text();
156
+ const prompts = text.split(/\r?\n/).filter(Boolean);
157
+
158
+ document.getElementById("loading").style.display = "block"; // show loading
159
+
160
+ for (const prompt of prompts) {
161
+ await send(prompt);
162
+ }
163
+
164
+ document.getElementById("loading").style.display = "none"; // hide loading
165
+ });
166
 
 
 
167
 
168
  async function send(overridePrompt) {
169
+ const model = document.getElementById("model").value;
170
+ const prompt = overridePrompt || document.getElementById("prompt").value;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171
 
172
+ const res = await fetch("/api/send", { // 👈 no localhost needed, Hugging Face serves it
173
+ method: "POST",
174
+ headers: { "Content-Type": "application/json" },
175
+ body: JSON.stringify({ model, prompt })
176
+ });
177
 
178
+ const data = await res.json();
179
+ const output = data.choices?.[0]?.message?.content || JSON.stringify(data);
180
+ document.getElementById("response").textContent = output;
181
+
182
+ results.push({ model, prompt, output });
183
+ }
184
 
185
  function downloadCSV() {
186
  let csv = "Model,Prompt,Output\n";