Spaces:
Running
Running
Update main.js
Browse files
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 |
-
|
|
|
|
| 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 |
-
|
|
|
|
|
|
|
| 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; }
|