Spaces:
Running
Running
Update index.html
Browse files- index.html +55 -37
index.html
CHANGED
|
@@ -1174,45 +1174,63 @@ function textArtifacts(text, topicStr) {
|
|
| 1174 |
}
|
| 1175 |
async function runEvaluation() {
|
| 1176 |
const note = analysisNote('Evaluador analizando intervenciones\u2026');
|
| 1177 |
-
const
|
| 1178 |
-
const
|
| 1179 |
-
|
| 1180 |
-
|
| 1181 |
-
|
| 1182 |
-
|
| 1183 |
-
|
| 1184 |
-
|
| 1185 |
-
|
| 1186 |
-
|
| 1187 |
-
|
| 1188 |
-
|
| 1189 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1190 |
const blocks = [];
|
| 1191 |
-
const
|
| 1192 |
-
|
| 1193 |
-
|
| 1194 |
-
const
|
| 1195 |
-
|
| 1196 |
-
|
| 1197 |
-
|
| 1198 |
-
|
| 1199 |
-
|
| 1200 |
-
|
| 1201 |
-
|
| 1202 |
-
|
| 1203 |
-
|
| 1204 |
-
|
| 1205 |
-
|
| 1206 |
-
let multi = 0;
|
| 1207 |
-
CRITERIA.forEach(([key]) => {
|
| 1208 |
-
const lm = new RegExp(key + ':\\s*([^\\n]*)').exec(blk);
|
| 1209 |
-
if (lm && (lm[1].match(/\d+/g) || []).length > 1) multi++;
|
| 1210 |
-
});
|
| 1211 |
-
const invalid = multi >= 2;
|
| 1212 |
-
blocks.push({ name, scores, comment: comment.trim(), total, invalid });
|
| 1213 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1214 |
const grab = k => {
|
| 1215 |
-
const mm = new RegExp(k + ':\\s*([\\s\\S]*?)(?=\\n(?:RELACIONES|CONTRADICCIONES|FALACIAS|SIN_JUSTIFICAR):|$)').exec(
|
| 1216 |
const v = mm ? mm[1].trim() : '';
|
| 1217 |
return /^NINGUNA/i.test(v) ? '' : v;
|
| 1218 |
};
|
|
@@ -1224,7 +1242,7 @@ async function runEvaluation() {
|
|
| 1224 |
};
|
| 1225 |
const usable = blocks.filter(blockUsable);
|
| 1226 |
doneNote(note, usable.length ? `Evaluaci\u00f3n completada (${usable.length} agentes).` : 'Evaluaci\u00f3n no disponible: salida del modelo no utilizable.');
|
| 1227 |
-
return { blocks, relations, extra, raw:
|
| 1228 |
}
|
| 1229 |
|
| 1230 |
/* ================= An\u00e1lisis: mapa de argumentos ================= */
|
|
|
|
| 1174 |
}
|
| 1175 |
async function runEvaluation() {
|
| 1176 |
const note = analysisNote('Evaluador analizando intervenciones\u2026');
|
| 1177 |
+
const sysBase = 'Eres un evaluador de debates. Punt\u00faas con criterio y explicas cada puntuaci\u00f3n: premias rigor, evidencia y honestidad intelectual, no solo al m\u00e1s convincente.';
|
| 1178 |
+
const fmt =
|
| 1179 |
+
'Responde EXACTAMENTE con este formato (una l\u00ednea por criterio):\n' +
|
| 1180 |
+
'AGENTE: <nombre>\nARGUMENTOS: <0-10>\nCOHERENCIA: <0-10>\nDETECCION: <0-10>\nEVIDENCIA: <0-10>\nINCERTIDUMBRE: <0-10>\nCONCLUSION: <0-10>\nCOMENTARIO: <una frase>\n\n' +
|
| 1181 |
+
'Ejemplo (valores inventados):\nAGENTE: Demo\nARGUMENTOS: 7\nCOHERENCIA: 8\nDETECCION: 5\nEVIDENCIA: 6\nINCERTIDUMBRE: 7\nCONCLUSION: 6\nCOMENTARIO: Argumenta bien pero aporta poca evidencia.';
|
| 1182 |
+
const parseBlocks = (answer) => {
|
| 1183 |
+
const out = [];
|
| 1184 |
+
const re = /AGENTE:\s*([^\n]+)\n([\s\S]*?)(?=\nAGENTE:|$)/g;
|
| 1185 |
+
let m;
|
| 1186 |
+
while ((m = re.exec(answer)) !== null) {
|
| 1187 |
+
const name = m[1].trim().replace(/\*+/g, '');
|
| 1188 |
+
if (!agents.some(a => a.name.toLowerCase() === name.toLowerCase())) continue;
|
| 1189 |
+
const blk = m[2];
|
| 1190 |
+
const scores = {};
|
| 1191 |
+
CRITERIA.forEach(([key]) => {
|
| 1192 |
+
const mm = new RegExp(key + ':\\s*(\\d{1,2})').exec(blk);
|
| 1193 |
+
scores[key] = mm ? Math.min(10, parseInt(mm[1])) : null;
|
| 1194 |
+
});
|
| 1195 |
+
const comment = (/COMENTARIO:\s*([^\n]+)/.exec(blk) || [])[1] || '';
|
| 1196 |
+
const present = Object.values(scores).filter(v => v !== null);
|
| 1197 |
+
const total = present.length ? Math.round((present.reduce((a, b) => a + b, 0) / present.length) * 10) : null;
|
| 1198 |
+
let multi = 0;
|
| 1199 |
+
CRITERIA.forEach(([key]) => {
|
| 1200 |
+
const lm = new RegExp(key + ':\\s*([^\\n]*)').exec(blk);
|
| 1201 |
+
if (lm && (lm[1].match(/\d+/g) || []).length > 1) multi++;
|
| 1202 |
+
});
|
| 1203 |
+
out.push({ name, scores, comment: comment.trim(), total, invalid: multi >= 2 });
|
| 1204 |
+
}
|
| 1205 |
+
return out;
|
| 1206 |
+
};
|
| 1207 |
+
// Un bloque por agente: salidas cortas y estructuradas, m\u00e1s fiables en modelos peque\u00f1os
|
| 1208 |
const blocks = [];
|
| 1209 |
+
for (const a of agents) {
|
| 1210 |
+
const own = transcript.filter(t => t.name === a.name).map(t => `[${t.role || 'turno'}]: ${t.text}`).join('\n');
|
| 1211 |
+
if (!own) continue;
|
| 1212 |
+
const ask = (viewChars) => llmSimple(sysBase,
|
| 1213 |
+
`Tema: ${topic}\n\nIntervenciones de ${a.name}:\n${own.slice(0, viewChars)}\n\n` +
|
| 1214 |
+
`Punt\u00faa SOLO a ${a.name} de 0 a 10 seg\u00fan sus intervenciones. ${fmt}`, 260);
|
| 1215 |
+
let r = await ask(1500);
|
| 1216 |
+
let got = parseBlocks(r.answer).filter(b => b.name.toLowerCase() === a.name.toLowerCase());
|
| 1217 |
+
if (!got.some(blockUsable)) {
|
| 1218 |
+
r = await ask(700);
|
| 1219 |
+
got = parseBlocks(r.answer).filter(b => b.name.toLowerCase() === a.name.toLowerCase());
|
| 1220 |
+
}
|
| 1221 |
+
if (got.length) blocks.push(got[0]);
|
| 1222 |
+
else blocks.push({ name: a.name, scores: {}, comment: '', total: null, invalid: true });
|
| 1223 |
+
if (stopRequested) break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1224 |
}
|
| 1225 |
+
// Relaciones y detecciones: llamada corta aparte; NINGUNA si no hay base clara en el texto
|
| 1226 |
+
const view = transcriptText(3000);
|
| 1227 |
+
const r2 = await llmSimple(sysBase,
|
| 1228 |
+
`Tema: ${topic}\n\nDebate:\n${view}\n\n` +
|
| 1229 |
+
'Responde solo con estas l\u00edneas; escribe NINGUNA si no hay base clara en el texto:\n' +
|
| 1230 |
+
'RELACIONES: <qui\u00e9n apoya o contradice a qui\u00e9n, ej: Ada apoya a Bruno; o NINGUNA>\n' +
|
| 1231 |
+
'CONTRADICCIONES: <o NINGUNA>\nFALACIAS: <o NINGUNA>\nSIN_JUSTIFICAR: <o NINGUNA>', 220);
|
| 1232 |
const grab = k => {
|
| 1233 |
+
const mm = new RegExp(k + ':\\s*([\\s\\S]*?)(?=\\n(?:RELACIONES|CONTRADICCIONES|FALACIAS|SIN_JUSTIFICAR):|$)').exec(r2.answer);
|
| 1234 |
const v = mm ? mm[1].trim() : '';
|
| 1235 |
return /^NINGUNA/i.test(v) ? '' : v;
|
| 1236 |
};
|
|
|
|
| 1242 |
};
|
| 1243 |
const usable = blocks.filter(blockUsable);
|
| 1244 |
doneNote(note, usable.length ? `Evaluaci\u00f3n completada (${usable.length} agentes).` : 'Evaluaci\u00f3n no disponible: salida del modelo no utilizable.');
|
| 1245 |
+
return { blocks, relations, extra, raw: r2.answer, unavailable: usable.length === 0 };
|
| 1246 |
}
|
| 1247 |
|
| 1248 |
/* ================= An\u00e1lisis: mapa de argumentos ================= */
|