vfven commited on
Commit
c6e7c55
·
verified ·
1 Parent(s): efa6401

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +24 -13
templates/index.html CHANGED
@@ -30,31 +30,42 @@
30
  <script>
31
  async function launchMission() {
32
  const task = document.getElementById('task').value.trim();
33
- if (!task) {
34
- alert('Escribe algo primero');
35
- return;
36
- }
37
-
38
  const output = document.getElementById('output');
39
- output.textContent = 'Procesando...';
40
-
41
  try {
42
  const res = await fetch('/api/mission', {
43
  method: 'POST',
44
  headers: { 'Content-Type': 'application/json' },
45
  body: JSON.stringify({ task })
46
  });
47
-
48
  const data = await res.json();
49
-
50
  if (!res.ok) {
51
- output.textContent = `Error ${res.status}: ${JSON.stringify(data, null, 2)}`;
52
  return;
53
  }
54
-
55
- output.textContent = JSON.stringify(data, null, 2);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  } catch (err) {
57
- output.textContent = 'Error de conexión: ' + err.message;
58
  }
59
  }
60
  </script>
 
30
  <script>
31
  async function launchMission() {
32
  const task = document.getElementById('task').value.trim();
33
+ if (!task) return alert('Escribe algo primero');
34
+
 
 
 
35
  const output = document.getElementById('output');
36
+ output.innerHTML = '<div style="color:#666;">Procesando... (puede tardar 10–60 segundos la primera vez)</div>';
37
+
38
  try {
39
  const res = await fetch('/api/mission', {
40
  method: 'POST',
41
  headers: { 'Content-Type': 'application/json' },
42
  body: JSON.stringify({ task })
43
  });
44
+
45
  const data = await res.json();
46
+
47
  if (!res.ok) {
48
+ output.innerHTML = `<pre style="color:red;">Error ${res.status}: ${JSON.stringify(data, null, 2)}</pre>`;
49
  return;
50
  }
51
+
52
+ let html = `<pre>${JSON.stringify(data, null, 2)}</pre>`;
53
+
54
+ if (data.file_path) {
55
+ html += `<p><a href="/data/docs/${data.file_path}" download>Descargar documento generado</a></p>`;
56
+ }
57
+
58
+ if (data.results && data.results.length > 0) {
59
+ html += '<h3>Resultados de agentes:</h3><ul>';
60
+ data.results.forEach(r => {
61
+ html += `<li><strong>${r.agent}:</strong> ${r.response ? r.response.substring(0, 200) + '...' : r.error}</li>`;
62
+ });
63
+ html += '</ul>';
64
+ }
65
+
66
+ output.innerHTML = html;
67
  } catch (err) {
68
+ output.innerHTML = `<pre style="color:red;">Error de conexión: ${err.message}</pre>`;
69
  }
70
  }
71
  </script>