Update index.html
Browse files- index.html +35 -10
index.html
CHANGED
|
@@ -106,9 +106,9 @@ details.think .t{white-space:pre-wrap;border-left:3px solid var(--border);paddin
|
|
| 106 |
border-radius:12px;background:var(--surface);box-shadow:0 2px 6px rgba(0,0,0,.3)}
|
| 107 |
#settings.open{display:block}
|
| 108 |
#settings label{display:block;font-size:12px;color:var(--muted);margin:10px 0 4px}
|
| 109 |
-
#settings input,#settings textarea{width:100%;background:var(--input);color:var(--text);
|
| 110 |
border:1px solid var(--border);border-radius:8px;padding:9px 12px;font-size:14px;font-family:inherit;outline:none}
|
| 111 |
-
#settings input:focus,#settings textarea:focus{border-color:var(--accent)}
|
| 112 |
#settings textarea{min-height:150px;font-family:ui-monospace,"SF Mono",Menlo,monospace;font-size:12px}
|
| 113 |
#settings .row{display:flex;gap:10px;flex-wrap:wrap}
|
| 114 |
#settings .row>div{flex:1;min-width:120px}
|
|
@@ -219,6 +219,7 @@ footer a{color:var(--accent);text-decoration:none}
|
|
| 219 |
<div><label>Máx. tokens por turno</label><input id="set-maxtokens" type="number" step="32" min="64"></div>
|
| 220 |
<div><label>Temperatura</label><input id="set-temp" type="number" step="0.05" min="0" max="2"></div>
|
| 221 |
<div><label>Rondas</label><input id="set-rounds" type="number" step="1" min="1" max="20"></div>
|
|
|
|
| 222 |
</div>
|
| 223 |
<label>Agentes (JSON: name, emoji, color, system)</label>
|
| 224 |
<textarea id="set-agents" spellcheck="false"></textarea>
|
|
@@ -286,6 +287,7 @@ const CONFIG = {
|
|
| 286 |
temperature: parseFloat(params.get('temp')) || 0.7,
|
| 287 |
rounds: parseInt(params.get('rounds')) || 2,
|
| 288 |
autoload: params.get('autoload') !== 'false',
|
|
|
|
| 289 |
};
|
| 290 |
if (params.get('theme') === 'light') document.body.classList.add('light');
|
| 291 |
const AGENTS_KEY = 'mad_agents';
|
|
@@ -642,7 +644,20 @@ async function agentTurn(agent) {
|
|
| 642 |
setStatus('Listo');
|
| 643 |
}
|
| 644 |
|
| 645 |
-
let resume = { round: 1,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 646 |
|
| 647 |
async function runDebate() {
|
| 648 |
running = true;
|
|
@@ -653,14 +668,19 @@ async function runDebate() {
|
|
| 653 |
try {
|
| 654 |
for (let r = resume.round; r <= CONFIG.rounds && !stopRequested; r++) {
|
| 655 |
setStatus(`Ronda ${r}/${CONFIG.rounds}`);
|
| 656 |
-
|
| 657 |
-
|
| 658 |
-
|
| 659 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 660 |
}
|
| 661 |
-
if (!stopRequested) resume = { round: r + 1,
|
| 662 |
}
|
| 663 |
-
if (!stopRequested) resume = { round: 1,
|
| 664 |
} finally {
|
| 665 |
running = false;
|
| 666 |
stopBtn.style.display = 'none';
|
|
@@ -679,7 +699,7 @@ startBtn.addEventListener('click', () => {
|
|
| 679 |
topic = newTopic;
|
| 680 |
transcript = [];
|
| 681 |
chatEl.innerHTML = '';
|
| 682 |
-
resume = { round: 1,
|
| 683 |
const m = addMsg(null, true);
|
| 684 |
m.body.textContent = newTopic;
|
| 685 |
transcript.push({ name: null, text: 'Tema propuesto: ' + newTopic });
|
|
@@ -690,6 +710,9 @@ startBtn.addEventListener('click', () => {
|
|
| 690 |
runDebate();
|
| 691 |
});
|
| 692 |
stopBtn.addEventListener('click', () => { stopRequested = true; setStatus('Deteniendo\u2026'); });
|
|
|
|
|
|
|
|
|
|
| 693 |
|
| 694 |
// --- Settings ---
|
| 695 |
const settingsPanel = document.getElementById('settings');
|
|
@@ -701,6 +724,7 @@ document.getElementById('settings-btn').addEventListener('click', () => {
|
|
| 701 |
document.getElementById('set-maxtokens').value = CONFIG.maxTokens;
|
| 702 |
document.getElementById('set-temp').value = CONFIG.temperature;
|
| 703 |
document.getElementById('set-rounds').value = CONFIG.rounds;
|
|
|
|
| 704 |
document.getElementById('set-agents').value = JSON.stringify(agents, null, 2);
|
| 705 |
}
|
| 706 |
settingsPanel.classList.toggle('open');
|
|
@@ -714,6 +738,7 @@ document.getElementById('apply-settings').addEventListener('click', async () =>
|
|
| 714 |
CONFIG.maxTokens = parseInt(document.getElementById('set-maxtokens').value) || CONFIG.maxTokens;
|
| 715 |
CONFIG.temperature = parseFloat(document.getElementById('set-temp').value) || CONFIG.temperature;
|
| 716 |
CONFIG.rounds = parseInt(document.getElementById('set-rounds').value) || CONFIG.rounds;
|
|
|
|
| 717 |
const newCtx = parseInt(document.getElementById('set-ctx').value) || CONFIG.nCtx;
|
| 718 |
const newRepo = document.getElementById('set-repo').value.trim();
|
| 719 |
const newFile = document.getElementById('set-file').value.trim();
|
|
|
|
| 106 |
border-radius:12px;background:var(--surface);box-shadow:0 2px 6px rgba(0,0,0,.3)}
|
| 107 |
#settings.open{display:block}
|
| 108 |
#settings label{display:block;font-size:12px;color:var(--muted);margin:10px 0 4px}
|
| 109 |
+
#settings input,#settings textarea,#settings select{width:100%;background:var(--input);color:var(--text);
|
| 110 |
border:1px solid var(--border);border-radius:8px;padding:9px 12px;font-size:14px;font-family:inherit;outline:none}
|
| 111 |
+
#settings input:focus,#settings textarea:focus,#settings select:focus{border-color:var(--accent)}
|
| 112 |
#settings textarea{min-height:150px;font-family:ui-monospace,"SF Mono",Menlo,monospace;font-size:12px}
|
| 113 |
#settings .row{display:flex;gap:10px;flex-wrap:wrap}
|
| 114 |
#settings .row>div{flex:1;min-width:120px}
|
|
|
|
| 219 |
<div><label>Máx. tokens por turno</label><input id="set-maxtokens" type="number" step="32" min="64"></div>
|
| 220 |
<div><label>Temperatura</label><input id="set-temp" type="number" step="0.05" min="0" max="2"></div>
|
| 221 |
<div><label>Rondas</label><input id="set-rounds" type="number" step="1" min="1" max="20"></div>
|
| 222 |
+
<div><label>Orden de turnos</label><select id="set-order"><option value="seq">Secuencial</option><option value="rand">Aleatorio por ronda</option></select></div>
|
| 223 |
</div>
|
| 224 |
<label>Agentes (JSON: name, emoji, color, system)</label>
|
| 225 |
<textarea id="set-agents" spellcheck="false"></textarea>
|
|
|
|
| 287 |
temperature: parseFloat(params.get('temp')) || 0.7,
|
| 288 |
rounds: parseInt(params.get('rounds')) || 2,
|
| 289 |
autoload: params.get('autoload') !== 'false',
|
| 290 |
+
order: params.get('order') === 'rand' ? 'rand' : 'seq',
|
| 291 |
};
|
| 292 |
if (params.get('theme') === 'light') document.body.classList.add('light');
|
| 293 |
const AGENTS_KEY = 'mad_agents';
|
|
|
|
| 644 |
setStatus('Listo');
|
| 645 |
}
|
| 646 |
|
| 647 |
+
let resume = { round: 1, order: null, pos: 0 };
|
| 648 |
+
|
| 649 |
+
function shuffled(n) {
|
| 650 |
+
const a = [...Array(n).keys()];
|
| 651 |
+
for (let i = a.length - 1; i > 0; i--) {
|
| 652 |
+
const j = Math.floor(Math.random() * (i + 1));
|
| 653 |
+
[a[i], a[j]] = [a[j], a[i]];
|
| 654 |
+
}
|
| 655 |
+
return a;
|
| 656 |
+
}
|
| 657 |
+
function validOrder(o, n) {
|
| 658 |
+
return Array.isArray(o) && o.length === n && new Set(o).size === n &&
|
| 659 |
+
o.every(v => Number.isInteger(v) && v >= 0 && v < n);
|
| 660 |
+
}
|
| 661 |
|
| 662 |
async function runDebate() {
|
| 663 |
running = true;
|
|
|
|
| 668 |
try {
|
| 669 |
for (let r = resume.round; r <= CONFIG.rounds && !stopRequested; r++) {
|
| 670 |
setStatus(`Ronda ${r}/${CONFIG.rounds}`);
|
| 671 |
+
let order;
|
| 672 |
+
if (r === resume.round && validOrder(resume.order, agents.length)) order = resume.order;
|
| 673 |
+
else order = CONFIG.order === 'rand' ? shuffled(agents.length) : [...Array(agents.length).keys()];
|
| 674 |
+
let startPos = (r === resume.round) ? resume.pos : 0;
|
| 675 |
+
if (startPos >= order.length) startPos = 0;
|
| 676 |
+
for (let p = startPos; p < order.length; p++) {
|
| 677 |
+
if (stopRequested) { resume = { round: r, order, pos: p }; break; }
|
| 678 |
+
await agentTurn(agents[order[p]]);
|
| 679 |
+
if (stopRequested) { resume = { round: r, order, pos: p }; break; }
|
| 680 |
}
|
| 681 |
+
if (!stopRequested) resume = { round: r + 1, order: null, pos: 0 };
|
| 682 |
}
|
| 683 |
+
if (!stopRequested) resume = { round: 1, order: null, pos: 0 };
|
| 684 |
} finally {
|
| 685 |
running = false;
|
| 686 |
stopBtn.style.display = 'none';
|
|
|
|
| 699 |
topic = newTopic;
|
| 700 |
transcript = [];
|
| 701 |
chatEl.innerHTML = '';
|
| 702 |
+
resume = { round: 1, order: null, pos: 0 };
|
| 703 |
const m = addMsg(null, true);
|
| 704 |
m.body.textContent = newTopic;
|
| 705 |
transcript.push({ name: null, text: 'Tema propuesto: ' + newTopic });
|
|
|
|
| 710 |
runDebate();
|
| 711 |
});
|
| 712 |
stopBtn.addEventListener('click', () => { stopRequested = true; setStatus('Deteniendo\u2026'); });
|
| 713 |
+
topicEl.addEventListener('keydown', e => {
|
| 714 |
+
if (e.key === 'Enter') { e.preventDefault(); startBtn.click(); }
|
| 715 |
+
});
|
| 716 |
|
| 717 |
// --- Settings ---
|
| 718 |
const settingsPanel = document.getElementById('settings');
|
|
|
|
| 724 |
document.getElementById('set-maxtokens').value = CONFIG.maxTokens;
|
| 725 |
document.getElementById('set-temp').value = CONFIG.temperature;
|
| 726 |
document.getElementById('set-rounds').value = CONFIG.rounds;
|
| 727 |
+
document.getElementById('set-order').value = CONFIG.order;
|
| 728 |
document.getElementById('set-agents').value = JSON.stringify(agents, null, 2);
|
| 729 |
}
|
| 730 |
settingsPanel.classList.toggle('open');
|
|
|
|
| 738 |
CONFIG.maxTokens = parseInt(document.getElementById('set-maxtokens').value) || CONFIG.maxTokens;
|
| 739 |
CONFIG.temperature = parseFloat(document.getElementById('set-temp').value) || CONFIG.temperature;
|
| 740 |
CONFIG.rounds = parseInt(document.getElementById('set-rounds').value) || CONFIG.rounds;
|
| 741 |
+
CONFIG.order = document.getElementById('set-order').value === 'rand' ? 'rand' : 'seq';
|
| 742 |
const newCtx = parseInt(document.getElementById('set-ctx').value) || CONFIG.nCtx;
|
| 743 |
const newRepo = document.getElementById('set-repo').value.trim();
|
| 744 |
const newFile = document.getElementById('set-file').value.trim();
|