Spaces:
Running
Running
Update index.html
Browse files- index.html +28 -18
index.html
CHANGED
|
@@ -561,7 +561,6 @@ let analysis = null; // {consensus, votes, conclusion, evaluation, relat
|
|
| 561 |
let analysisToken = 0;
|
| 562 |
let currentLibId = null;
|
| 563 |
let debateFinished = false;
|
| 564 |
-
let reviewUsed = false;
|
| 565 |
|
| 566 |
function esc(s) { const d = document.createElement('div'); d.textContent = s; return d.innerHTML; }
|
| 567 |
function shade(hex, amt) {
|
|
@@ -946,10 +945,32 @@ async function agentTurn(agent, role, instr) {
|
|
| 946 |
el.classList.remove('streaming');
|
| 947 |
if (r.stopped) { el.remove(); return false; }
|
| 948 |
let answer = r.answer.replace(/^\s*(?:\*\*)?[A-Za-z\u00c0-\u024f]+:\s*/, '').trim();
|
| 949 |
-
|
| 950 |
-
let reviewReq = null;
|
| 951 |
const mRev = /SOLICITO REVISION:\s*(.+?)$/im.exec(answer);
|
| 952 |
-
if (mRev) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 953 |
const changed = /^cambio de postura/i.test(answer);
|
| 954 |
body.innerHTML = (typeof marked !== 'undefined') ? marked.parse(answer) : esc(answer).replace(/\n/g, '<br>');
|
| 955 |
if (changed) {
|
|
@@ -962,10 +983,10 @@ async function agentTurn(agent, role, instr) {
|
|
| 962 |
bumpStats(agent.name, r.tokens, r.ms);
|
| 963 |
if (reviewReq && (stats.reviews || 0) < 2) {
|
| 964 |
stats.reviews = (stats.reviews || 0) + 1;
|
| 965 |
-
const other = agents.find(a => a.name !== agent.name);
|
| 966 |
if (other) {
|
| 967 |
-
addSysNote(`${agent.name}
|
| 968 |
-
await agentTurn(other, 'Revisor', `
|
| 969 |
}
|
| 970 |
}
|
| 971 |
return true;
|
|
@@ -1047,16 +1068,6 @@ async function runDebate() {
|
|
| 1047 |
if (stopRequested) { resume = { round: r, stepIdx: s, steps }; break; }
|
| 1048 |
const ok = await agentTurn(agents[steps[s].idx], steps[s].role, steps[s].instr);
|
| 1049 |
if (!ok) { if (stopRequested) resume = { round: r, stepIdx: s, steps }; break; }
|
| 1050 |
-
if (!stopRequested && !reviewUsed) {
|
| 1051 |
-
const lastT = transcript[transcript.length - 1];
|
| 1052 |
-
const mRev = lastT && !lastT.isUser ? /SOLICITO REVISI\u00d3?N:\s*([A-Za-z\u00c0-\u00ff][\w\u00c0-\u00ff]*)\s*[-\u2014]\s*(.{5,200})/.exec(lastT.text) : null;
|
| 1053 |
-
const target = mRev ? agents.find(a => a.name.toLowerCase() === mRev[1].toLowerCase()) : null;
|
| 1054 |
-
if (target && target.name !== lastT.name) {
|
| 1055 |
-
reviewUsed = true;
|
| 1056 |
-
addSysNote(`${lastT.name} pidi\u00f3 revisi\u00f3n a ${target.name}: ${mRev[2].slice(0, 120)}`);
|
| 1057 |
-
await agentTurn(target, steps[s].role, `${lastT.name} te pide revisar este punto: ${mRev[2].slice(0, 200)}. Responde brevemente.`);
|
| 1058 |
-
}
|
| 1059 |
-
}
|
| 1060 |
}
|
| 1061 |
if (!stopRequested) resume = { round: r + 1, stepIdx: 0, steps: null };
|
| 1062 |
else break;
|
|
@@ -1678,7 +1689,6 @@ function startFresh(newTopic) {
|
|
| 1678 |
analysisToken++;
|
| 1679 |
analysis = null;
|
| 1680 |
currentLibId = null;
|
| 1681 |
-
reviewUsed = false;
|
| 1682 |
debateFinished = false;
|
| 1683 |
$('analysis-out').innerHTML = '';
|
| 1684 |
$('analysis-empty').classList.remove('hidden');
|
|
|
|
| 561 |
let analysisToken = 0;
|
| 562 |
let currentLibId = null;
|
| 563 |
let debateFinished = false;
|
|
|
|
| 564 |
|
| 565 |
function esc(s) { const d = document.createElement('div'); d.textContent = s; return d.innerHTML; }
|
| 566 |
function shade(hex, amt) {
|
|
|
|
| 945 |
el.classList.remove('streaming');
|
| 946 |
if (r.stopped) { el.remove(); return false; }
|
| 947 |
let answer = r.answer.replace(/^\s*(?:\*\*)?[A-Za-z\u00c0-\u024f]+:\s*/, '').trim();
|
| 948 |
+
let reviewReq = null, reviewTarget = null;
|
|
|
|
| 949 |
const mRev = /SOLICITO REVISION:\s*(.+?)$/im.exec(answer);
|
| 950 |
+
if (mRev) {
|
| 951 |
+
let req = mRev[1].trim();
|
| 952 |
+
answer = answer.replace(/SOLICITO REVISION:[\s\S]*$/im, '').trim();
|
| 953 |
+
const mName = /^([A-Za-z\u00c0-\u00ff][\w\u00c0-\u00ff]*)\s*[-\u2014:]\s*(.+)$/.exec(req);
|
| 954 |
+
if (mName) {
|
| 955 |
+
const t = agents.find(a => a.name.toLowerCase() === mName[1].toLowerCase() && a.name !== agent.name);
|
| 956 |
+
if (t) { reviewTarget = t; req = mName[2].trim(); }
|
| 957 |
+
}
|
| 958 |
+
const echoish = /tema propuesto|debate hasta ahora/i.test(req) || (topic && req.toLowerCase().includes(topic.toLowerCase().slice(0, 30)));
|
| 959 |
+
if (req.length >= 12 && !echoish) reviewReq = req.slice(0, 200);
|
| 960 |
+
}
|
| 961 |
+
if (!answer) {
|
| 962 |
+
el.remove();
|
| 963 |
+
if (reviewReq && (stats.reviews || 0) < 2) {
|
| 964 |
+
stats.reviews = (stats.reviews || 0) + 1;
|
| 965 |
+
const other = reviewTarget || agents.find(a => a.name !== agent.name);
|
| 966 |
+
if (other) {
|
| 967 |
+
addSysNote(`${agent.name} pidi\u00f3 revisi\u00f3n a ${other.name}: ${reviewReq}`);
|
| 968 |
+
await agentTurn(other, 'Revisor', `${agent.name} pidi\u00f3 que comprobaras esto: \u00ab${reviewReq}\u00bb. Revisa el razonamiento y responde si es correcto.`);
|
| 969 |
+
}
|
| 970 |
+
}
|
| 971 |
+
setStatus('Listo');
|
| 972 |
+
return true;
|
| 973 |
+
}
|
| 974 |
const changed = /^cambio de postura/i.test(answer);
|
| 975 |
body.innerHTML = (typeof marked !== 'undefined') ? marked.parse(answer) : esc(answer).replace(/\n/g, '<br>');
|
| 976 |
if (changed) {
|
|
|
|
| 983 |
bumpStats(agent.name, r.tokens, r.ms);
|
| 984 |
if (reviewReq && (stats.reviews || 0) < 2) {
|
| 985 |
stats.reviews = (stats.reviews || 0) + 1;
|
| 986 |
+
const other = reviewTarget || agents.find(a => a.name !== agent.name);
|
| 987 |
if (other) {
|
| 988 |
+
addSysNote(`${agent.name} pidi\u00f3 revisi\u00f3n a ${other.name}: ${reviewReq}`);
|
| 989 |
+
await agentTurn(other, 'Revisor', `${agent.name} pidi\u00f3 que comprobaras esto: «${reviewReq}». Revisa el razonamiento y responde si es correcto.`);
|
| 990 |
}
|
| 991 |
}
|
| 992 |
return true;
|
|
|
|
| 1068 |
if (stopRequested) { resume = { round: r, stepIdx: s, steps }; break; }
|
| 1069 |
const ok = await agentTurn(agents[steps[s].idx], steps[s].role, steps[s].instr);
|
| 1070 |
if (!ok) { if (stopRequested) resume = { round: r, stepIdx: s, steps }; break; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1071 |
}
|
| 1072 |
if (!stopRequested) resume = { round: r + 1, stepIdx: 0, steps: null };
|
| 1073 |
else break;
|
|
|
|
| 1689 |
analysisToken++;
|
| 1690 |
analysis = null;
|
| 1691 |
currentLibId = null;
|
|
|
|
| 1692 |
debateFinished = false;
|
| 1693 |
$('analysis-out').innerHTML = '';
|
| 1694 |
$('analysis-empty').classList.remove('hidden');
|