Spaces:
Running
Running
Update templates/index.html
Browse files- templates/index.html +24 -22
templates/index.html
CHANGED
|
@@ -142,7 +142,7 @@
|
|
| 142 |
const taskInput = document.getElementById('task');
|
| 143 |
const task = taskInput.value.trim();
|
| 144 |
if (!task) return alert('Escribe algo primero');
|
| 145 |
-
|
| 146 |
const output = document.getElementById('output');
|
| 147 |
output.innerHTML = `
|
| 148 |
<div style="text-align:center; color:#666; padding:30px;">
|
|
@@ -150,59 +150,61 @@
|
|
| 150 |
Procesando... (puede tardar 10–60 segundos la primera vez)
|
| 151 |
</div>
|
| 152 |
`;
|
| 153 |
-
|
| 154 |
try {
|
| 155 |
const res = await fetch('/api/mission', {
|
| 156 |
method: 'POST',
|
| 157 |
headers: { 'Content-Type': 'application/json' },
|
| 158 |
body: JSON.stringify({ task })
|
| 159 |
});
|
| 160 |
-
|
| 161 |
const data = await res.json();
|
| 162 |
-
|
| 163 |
if (!res.ok) {
|
| 164 |
output.innerHTML = `<pre style="color:red; background:#ffebee; padding:15px; border-radius:8px;">Error ${res.status}: ${JSON.stringify(data, null, 2)}</pre>`;
|
| 165 |
return;
|
| 166 |
}
|
| 167 |
-
|
| 168 |
let html = '<h3>Resultado de la misión</h3>';
|
| 169 |
-
|
| 170 |
// Razonamiento del manager
|
| 171 |
if (data.plan && data.plan.reasoning) {
|
| 172 |
html += `<p><strong>Manager pensó:</strong> ${data.plan.reasoning}</p>`;
|
| 173 |
}
|
| 174 |
-
|
| 175 |
// Resultados de agentes
|
| 176 |
if (data.results && data.results.length > 0) {
|
| 177 |
html += '<h4>Agentes que trabajaron:</h4>';
|
| 178 |
-
data.results.forEach(
|
| 179 |
-
const isError = !
|
| 180 |
html += `
|
| 181 |
<div class="agent-result ${isError ? 'error' : ''}">
|
| 182 |
-
<strong>${
|
| 183 |
-
<div>${
|
| 184 |
</div>`;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 185 |
});
|
| 186 |
} else {
|
| 187 |
html += '<p>No se delegó a ningún agente.</p>';
|
| 188 |
}
|
| 189 |
-
|
| 190 |
-
//
|
| 191 |
-
if (r.image_url) {
|
| 192 |
-
html += `
|
| 193 |
-
<div style="margin-top:15px;">
|
| 194 |
-
<img src="${r.image_url}" alt="Imagen generada" style="max-width:100%; border-radius:8px; box-shadow:0 4px 8px rgba(0,0,0,0.2);">
|
| 195 |
-
<p><small>Generada con FLUX.1-schnell</small></p>
|
| 196 |
-
</div>`;
|
| 197 |
-
}
|
| 198 |
-
// Link de descarga
|
| 199 |
if (data.file_url) {
|
| 200 |
html += `
|
| 201 |
<a href="${data.file_url}" target="_blank" class="download-btn" download>
|
| 202 |
Descargar documento generado
|
| 203 |
</a>`;
|
| 204 |
}
|
| 205 |
-
|
| 206 |
output.innerHTML = html;
|
| 207 |
} catch (err) {
|
| 208 |
output.innerHTML = `<pre style="color:red; background:#ffebee; padding:15px; border-radius:8px;">Error de conexión: ${err.message}</pre>`;
|
|
|
|
| 142 |
const taskInput = document.getElementById('task');
|
| 143 |
const task = taskInput.value.trim();
|
| 144 |
if (!task) return alert('Escribe algo primero');
|
| 145 |
+
|
| 146 |
const output = document.getElementById('output');
|
| 147 |
output.innerHTML = `
|
| 148 |
<div style="text-align:center; color:#666; padding:30px;">
|
|
|
|
| 150 |
Procesando... (puede tardar 10–60 segundos la primera vez)
|
| 151 |
</div>
|
| 152 |
`;
|
| 153 |
+
|
| 154 |
try {
|
| 155 |
const res = await fetch('/api/mission', {
|
| 156 |
method: 'POST',
|
| 157 |
headers: { 'Content-Type': 'application/json' },
|
| 158 |
body: JSON.stringify({ task })
|
| 159 |
});
|
| 160 |
+
|
| 161 |
const data = await res.json();
|
| 162 |
+
|
| 163 |
if (!res.ok) {
|
| 164 |
output.innerHTML = `<pre style="color:red; background:#ffebee; padding:15px; border-radius:8px;">Error ${res.status}: ${JSON.stringify(data, null, 2)}</pre>`;
|
| 165 |
return;
|
| 166 |
}
|
| 167 |
+
|
| 168 |
let html = '<h3>Resultado de la misión</h3>';
|
| 169 |
+
|
| 170 |
// Razonamiento del manager
|
| 171 |
if (data.plan && data.plan.reasoning) {
|
| 172 |
html += `<p><strong>Manager pensó:</strong> ${data.plan.reasoning}</p>`;
|
| 173 |
}
|
| 174 |
+
|
| 175 |
// Resultados de agentes
|
| 176 |
if (data.results && data.results.length > 0) {
|
| 177 |
html += '<h4>Agentes que trabajaron:</h4>';
|
| 178 |
+
data.results.forEach(resultado => { // ← cambiamos 'r' por 'resultado' para evitar conflictos
|
| 179 |
+
const isError = !resultado.success;
|
| 180 |
html += `
|
| 181 |
<div class="agent-result ${isError ? 'error' : ''}">
|
| 182 |
+
<strong>${resultado.agent} (${isError ? 'Error' : 'Éxito'})</strong>
|
| 183 |
+
<div>${resultado.response ? resultado.response.substring(0, 400) + (resultado.response.length > 400 ? '...' : '') : resultado.error || 'Sin respuesta'}</div>
|
| 184 |
</div>`;
|
| 185 |
+
|
| 186 |
+
// Mostrar imágenes si existen
|
| 187 |
+
if (resultado.image_urls && resultado.image_urls.length > 0) {
|
| 188 |
+
resultado.image_urls.forEach(url => {
|
| 189 |
+
html += `
|
| 190 |
+
<div style="margin:15px 0;">
|
| 191 |
+
<img src="${url}" alt="Imagen generada" style="max-width:100%; border-radius:8px; box-shadow:0 4px 8px rgba(0,0,0,0.2);">
|
| 192 |
+
</div>`;
|
| 193 |
+
});
|
| 194 |
+
}
|
| 195 |
});
|
| 196 |
} else {
|
| 197 |
html += '<p>No se delegó a ningún agente.</p>';
|
| 198 |
}
|
| 199 |
+
|
| 200 |
+
// Link de descarga de documento
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 201 |
if (data.file_url) {
|
| 202 |
html += `
|
| 203 |
<a href="${data.file_url}" target="_blank" class="download-btn" download>
|
| 204 |
Descargar documento generado
|
| 205 |
</a>`;
|
| 206 |
}
|
| 207 |
+
|
| 208 |
output.innerHTML = html;
|
| 209 |
} catch (err) {
|
| 210 |
output.innerHTML = `<pre style="color:red; background:#ffebee; padding:15px; border-radius:8px;">Error de conexión: ${err.message}</pre>`;
|