Aichatbot12321 commited on
Commit
97acbd6
·
verified ·
1 Parent(s): 5e4346f

Update main.js

Browse files
Files changed (1) hide show
  1. main.js +5 -2
main.js CHANGED
@@ -501,7 +501,8 @@ async function checkHtmlError(r) {
501
  async function callGeminiText(sysText, usrText, override = null) {
502
  if (isProcessing) throw new Error("Processing..."); isProcessing = true; track('t'); window.currentAbortController = new AbortController();
503
  try {
504
- const r = await fetch("/api/gemini-text", { method: "POST", headers: {"Content-Type":"application/json"}, body: JSON.stringify({ systemPrompt: sysText, userPrompt: usrText, providerOverride: override }), signal: window.currentAbortController.signal });
 
505
  const d = await checkHtmlError(r); if(!r.ok) throw new Error(d.error || "All API keys failed.");
506
  isProcessing = false; window.currentAbortController = null; return d;
507
  } catch(e) { isProcessing = false; window.currentAbortController = null; throw e; }
@@ -510,7 +511,9 @@ async function callGeminiText(sysText, usrText, override = null) {
510
  async function callGeminiVision(imgData, aiQuery, override = null) {
511
  if (isProcessing) throw new Error("Processing..."); isProcessing = true; track('v'); window.currentAbortController = new AbortController();
512
  try {
513
- const r = await fetch("/api/gemini-vision", { method: "POST", headers: {"Content-Type":"application/json"}, body: JSON.stringify({ imageBase64: imgData, userPrompt: aiQuery, providerOverride: override }), signal: window.currentAbortController.signal });
 
 
514
  const d = await checkHtmlError(r); if(!r.ok) throw new Error(d.error);
515
  isProcessing = false; window.currentAbortController = null; return d;
516
  } catch(e) { isProcessing = false; window.currentAbortController = null; throw e; }
 
501
  async function callGeminiText(sysText, usrText, override = null) {
502
  if (isProcessing) throw new Error("Processing..."); isProcessing = true; track('t'); window.currentAbortController = new AbortController();
503
  try {
504
+ // Changed endpoint from /api/gemini-text to /api/other
505
+ const r = await fetch("/api/other", { method: "POST", headers: {"Content-Type":"application/json"}, body: JSON.stringify({ systemPrompt: sysText, userPrompt: usrText, providerOverride: override }), signal: window.currentAbortController.signal });
506
  const d = await checkHtmlError(r); if(!r.ok) throw new Error(d.error || "All API keys failed.");
507
  isProcessing = false; window.currentAbortController = null; return d;
508
  } catch(e) { isProcessing = false; window.currentAbortController = null; throw e; }
 
511
  async function callGeminiVision(imgData, aiQuery, override = null) {
512
  if (isProcessing) throw new Error("Processing..."); isProcessing = true; track('v'); window.currentAbortController = new AbortController();
513
  try {
514
+ // Changed endpoint from /api/gemini-vision to /api/other
515
+ // Note: Passing imgData as an array to handle the multi-image Book requests seamlessly
516
+ const r = await fetch("/api/other", { method: "POST", headers: {"Content-Type":"application/json"}, body: JSON.stringify({ imageBase64Array: Array.isArray(imgData) ? imgData : [imgData], userPrompt: aiQuery, providerOverride: override }), signal: window.currentAbortController.signal });
517
  const d = await checkHtmlError(r); if(!r.ok) throw new Error(d.error);
518
  isProcessing = false; window.currentAbortController = null; return d;
519
  } catch(e) { isProcessing = false; window.currentAbortController = null; throw e; }