rocca commited on
Commit
860213a
·
verified ·
1 Parent(s): 8164d28

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +18 -18
index.html CHANGED
@@ -81,6 +81,8 @@
81
  <script>serverOriginEl.value = localStorage.serverOrigin || '';</script>
82
  <input id="modelNameEl" placeholder="Model name (huggingface repo)" style="width:300px;" oninput="localStorage.modelName=this.value">
83
  <script>modelNameEl.value = localStorage.modelName || 'OpenGVLab/InternVL2-40B-AWQ';</script>
 
 
84
  </div>
85
 
86
  <button id="imageLoader"><b>1. Select test images</b></button>
@@ -338,29 +340,27 @@
338
  imageUrl = await resizeDataUrl({ dataUrl: imageUrl, maxWidth: maxImageSize, maxHeight: maxImageSize });
339
  console.log(`original size: ${originalImageSize}, new size: ${imageUrl.length}`);
340
 
 
 
 
 
 
 
 
 
 
 
 
341
  let startTime = Date.now();
342
  let result = await fetch(`${serverOrigin.trim().replace(/\/$/, "")}/v1/chat/completions`, {
343
- headers: { "content-type": "application/json" },
 
 
 
344
  body: JSON.stringify({
345
  model: modelName.trim(),
346
  stream: false,
347
- messages: [
348
- {
349
- role: "system",
350
- content: systemPrompt,
351
- },
352
- {
353
- role: "user",
354
- content: [
355
- { "type": "text", "text": prompt.trim() },
356
- { "type": "image_url", "image_url": { "url": imageUrl } },
357
- ],
358
- },
359
- {
360
- role: "assistant",
361
- content: (prefix || "").trim(),
362
- },
363
- ]
364
  }),
365
  method: "POST",
366
  }).then(r => r.json()).catch(e => console.error("Error computing caption:", e));
 
81
  <script>serverOriginEl.value = localStorage.serverOrigin || '';</script>
82
  <input id="modelNameEl" placeholder="Model name (huggingface repo)" style="width:300px;" oninput="localStorage.modelName=this.value">
83
  <script>modelNameEl.value = localStorage.modelName || 'OpenGVLab/InternVL2-40B-AWQ';</script>
84
+ <input id="apiKeyEl" placeholder="API key (optional)" style="width:300px;" oninput="localStorage.apiKey=this.value">
85
+ <script>apiKeyEl.value = localStorage.apiKey || '';</script>
86
  </div>
87
 
88
  <button id="imageLoader"><b>1. Select test images</b></button>
 
340
  imageUrl = await resizeDataUrl({ dataUrl: imageUrl, maxWidth: maxImageSize, maxHeight: maxImageSize });
341
  console.log(`original size: ${originalImageSize}, new size: ${imageUrl.length}`);
342
 
343
+ let messages = [];
344
+ if(systemPrompt.trim()) messages.push({ role:"system", content:systemPrompt.trim() });
345
+ messages.push({
346
+ role: "user",
347
+ content: [
348
+ { "type": "text", "text": prompt.trim() },
349
+ { "type": "image_url", "image_url": { "url": imageUrl } },
350
+ ],
351
+ });
352
+ if(prefix.trim()) messages.push({ role:"assistant", content:prefix.trim() });
353
+
354
  let startTime = Date.now();
355
  let result = await fetch(`${serverOrigin.trim().replace(/\/$/, "")}/v1/chat/completions`, {
356
+ headers: {
357
+ "content-type": "application/json"
358
+ "Authorization": `Bearer ${apiKeyEl.value}`,
359
+ },
360
  body: JSON.stringify({
361
  model: modelName.trim(),
362
  stream: false,
363
+ messages,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
364
  }),
365
  method: "POST",
366
  }).then(r => r.json()).catch(e => console.error("Error computing caption:", e));