Spaces:
Running
Running
UI honesta: canario de generación tras carga + detener debate al primer error (evita bucle de errores)
Browse files- index.html +15 -4
index.html
CHANGED
|
@@ -328,6 +328,7 @@ const subtitleEl = document.getElementById('subtitle');
|
|
| 328 |
|
| 329 |
let wllama = null;
|
| 330 |
let running = false;
|
|
|
|
| 331 |
let stopRequested = false;
|
| 332 |
let inflight = null;
|
| 333 |
function raceStop(p) {
|
|
@@ -559,8 +560,15 @@ async function loadModel(repo, file) {
|
|
| 559 |
}
|
| 560 |
},
|
| 561 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 562 |
setProgress(100);
|
| 563 |
-
setStatus(`Modelo listo. ${agents.length} agentes: ${agents.map(a => a.name).join(', ')}.`);
|
| 564 |
startBtn.disabled = false;
|
| 565 |
startBtn.textContent = 'Iniciar debate';
|
| 566 |
topicEl.focus();
|
|
@@ -716,7 +724,7 @@ async function agentTurn(agent) {
|
|
| 716 |
body.textContent = 'Error: ' + (e?.message || e);
|
| 717 |
el.classList.remove('streaming');
|
| 718 |
markActive(null);
|
| 719 |
-
return;
|
| 720 |
}
|
| 721 |
el.classList.remove('streaming');
|
| 722 |
if (inflight) { const s0 = inflight; Promise.resolve(s0.next ? s0.next() : null).catch(() => {}).finally(() => { if (inflight === s0) inflight = null; }); inflight = null; }
|
|
@@ -749,6 +757,7 @@ function validOrder(o, n) {
|
|
| 749 |
async function runDebate() {
|
| 750 |
running = true;
|
| 751 |
stopRequested = false;
|
|
|
|
| 752 |
startBtn.style.display = 'none';
|
| 753 |
stopBtn.style.display = 'inline-block';
|
| 754 |
topicEl.disabled = true;
|
|
@@ -762,9 +771,11 @@ async function runDebate() {
|
|
| 762 |
if (startPos >= order.length) startPos = 0;
|
| 763 |
for (let p = startPos; p < order.length; p++) {
|
| 764 |
if (stopRequested) { resume = { round: r, order, pos: p }; break; }
|
| 765 |
-
await agentTurn(agents[order[p]]);
|
|
|
|
| 766 |
if (stopRequested) { resume = { round: r, order, pos: p }; break; }
|
| 767 |
}
|
|
|
|
| 768 |
if (!stopRequested) resume = { round: r + 1, order: null, pos: 0 };
|
| 769 |
}
|
| 770 |
if (!stopRequested) resume = { round: 1, order: null, pos: 0 };
|
|
@@ -775,7 +786,7 @@ async function runDebate() {
|
|
| 775 |
startBtn.textContent = 'Continuar debate';
|
| 776 |
startBtn.disabled = false;
|
| 777 |
topicEl.disabled = false;
|
| 778 |
-
setStatus(stopRequested ? 'Detenido. Puedes continuar o cambiar de tema.' : 'Debate terminado. Puedes continuar.');
|
| 779 |
}
|
| 780 |
}
|
| 781 |
|
|
|
|
| 328 |
|
| 329 |
let wllama = null;
|
| 330 |
let running = false;
|
| 331 |
+
let genError = false;
|
| 332 |
let stopRequested = false;
|
| 333 |
let inflight = null;
|
| 334 |
function raceStop(p) {
|
|
|
|
| 560 |
}
|
| 561 |
},
|
| 562 |
});
|
| 563 |
+
// Canario: una generación mínima confirma que el modelo puede generar, no solo cargar.
|
| 564 |
+
setStatus('Verificando generaci\u00f3n\u2026');
|
| 565 |
+
try {
|
| 566 |
+
await wllama.createCompletion({ prompt: '<|im_start|>user\nhola<|im_end|>\n<|im_start|>assistant\n', max_tokens: 2, temperature: 0 });
|
| 567 |
+
} catch (e2) {
|
| 568 |
+
throw new Error('El modelo carg\u00f3 pero NO puede generar en este navegador/motor: ' + (e2?.message || e2));
|
| 569 |
+
}
|
| 570 |
setProgress(100);
|
| 571 |
+
setStatus(`Modelo listo y verificado. ${agents.length} agentes: ${agents.map(a => a.name).join(', ')}.`);
|
| 572 |
startBtn.disabled = false;
|
| 573 |
startBtn.textContent = 'Iniciar debate';
|
| 574 |
topicEl.focus();
|
|
|
|
| 724 |
body.textContent = 'Error: ' + (e?.message || e);
|
| 725 |
el.classList.remove('streaming');
|
| 726 |
markActive(null);
|
| 727 |
+
return false;
|
| 728 |
}
|
| 729 |
el.classList.remove('streaming');
|
| 730 |
if (inflight) { const s0 = inflight; Promise.resolve(s0.next ? s0.next() : null).catch(() => {}).finally(() => { if (inflight === s0) inflight = null; }); inflight = null; }
|
|
|
|
| 757 |
async function runDebate() {
|
| 758 |
running = true;
|
| 759 |
stopRequested = false;
|
| 760 |
+
genError = false;
|
| 761 |
startBtn.style.display = 'none';
|
| 762 |
stopBtn.style.display = 'inline-block';
|
| 763 |
topicEl.disabled = true;
|
|
|
|
| 771 |
if (startPos >= order.length) startPos = 0;
|
| 772 |
for (let p = startPos; p < order.length; p++) {
|
| 773 |
if (stopRequested) { resume = { round: r, order, pos: p }; break; }
|
| 774 |
+
const ok = await agentTurn(agents[order[p]]);
|
| 775 |
+
if (ok === false) { genError = true; break; }
|
| 776 |
if (stopRequested) { resume = { round: r, order, pos: p }; break; }
|
| 777 |
}
|
| 778 |
+
if (genError) break;
|
| 779 |
if (!stopRequested) resume = { round: r + 1, order: null, pos: 0 };
|
| 780 |
}
|
| 781 |
if (!stopRequested) resume = { round: 1, order: null, pos: 0 };
|
|
|
|
| 786 |
startBtn.textContent = 'Continuar debate';
|
| 787 |
startBtn.disabled = false;
|
| 788 |
topicEl.disabled = false;
|
| 789 |
+
setStatus(genError ? 'Error de generaci\u00f3n: el modelo no respondi\u00f3. Debate detenido.' : (stopRequested ? 'Detenido. Puedes continuar o cambiar de tema.' : 'Debate terminado. Puedes continuar.'));
|
| 790 |
}
|
| 791 |
}
|
| 792 |
|