vfven commited on
Commit
bbbaad4
·
verified ·
1 Parent(s): f4b9863

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +78 -42
templates/index.html CHANGED
@@ -17,6 +17,7 @@
17
  --info: #3498db;
18
  --bg-light: #f8f9fa;
19
  --bg-card: #2d2d2d;
 
20
  }
21
 
22
  * { box-sizing: border-box; margin: 0; padding: 0; }
@@ -28,48 +29,52 @@
28
  line-height: 1.6;
29
  }
30
 
31
- h1 { color: #2c3e50; margin-bottom: 20px; }
32
  label { font-weight: bold; display: block; margin-bottom: 8px; }
33
 
34
  textarea {
35
  width: 100%;
36
- height: 120px;
37
  padding: 12px;
38
- margin-bottom: 12px;
39
  font-family: monospace;
40
  border: 1px solid #ccc;
41
- border-radius: 6px;
42
  resize: vertical;
 
43
  }
44
 
45
  button {
46
- padding: 12px 24px;
47
  background: var(--primary);
48
  color: white;
49
  border: none;
50
- border-radius: 6px;
51
  cursor: pointer;
52
- font-size: 1rem;
53
  transition: background 0.2s;
 
 
54
  }
55
  button:hover { background: var(--primary-dark); }
56
 
57
  #result {
58
  margin-top: 30px;
59
- padding: 20px;
60
  background: white;
61
- border-radius: 8px;
62
- box-shadow: 0 2px 10px rgba(0,0,0,0.1);
 
63
  }
64
 
65
  .spinner {
66
- border: 4px solid #f3f3f3;
67
- border-top: 4px solid var(--info);
68
  border-radius: 50%;
69
- width: 40px;
70
- height: 40px;
71
  animation: spin 1s linear infinite;
72
- margin: 20px auto;
73
  }
74
 
75
  @keyframes spin {
@@ -79,12 +84,13 @@
79
 
80
  /* Resultados de agentes */
81
  .agent-result {
82
- margin: 16px 0;
83
- padding: 16px;
84
- border-radius: 6px;
85
  background: var(--bg-card);
86
  color: var(--text-light);
87
- border-left: 4px solid var(--success);
 
88
  }
89
 
90
  .agent-result.error {
@@ -96,18 +102,38 @@
96
  .agent-result strong {
97
  color: var(--success-light);
98
  display: block;
99
- margin-bottom: 8px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
  }
101
 
102
  .download-btn {
103
  display: inline-block;
104
- padding: 12px 24px;
105
  background: #1976d2;
106
  color: white;
107
  text-decoration: none;
108
- border-radius: 6px;
109
- margin-top: 16px;
110
  transition: background 0.2s;
 
111
  }
112
 
113
  .download-btn:hover {
@@ -118,7 +144,7 @@
118
  background: #272822;
119
  color: #f8f8f2;
120
  padding: 15px;
121
- border-radius: 6px;
122
  overflow-x: auto;
123
  margin: 12px 0;
124
  }
@@ -142,61 +168,71 @@
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;">
149
  <div class="spinner"></div>
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 += `
@@ -204,7 +240,7 @@
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>`;
 
17
  --info: #3498db;
18
  --bg-light: #f8f9fa;
19
  --bg-card: #2d2d2d;
20
+ --border: #444;
21
  }
22
 
23
  * { box-sizing: border-box; margin: 0; padding: 0; }
 
29
  line-height: 1.6;
30
  }
31
 
32
+ h1 { color: #2c3e50; margin-bottom: 20px; text-align: center; }
33
  label { font-weight: bold; display: block; margin-bottom: 8px; }
34
 
35
  textarea {
36
  width: 100%;
37
+ height: 140px;
38
  padding: 12px;
39
+ margin-bottom: 16px;
40
  font-family: monospace;
41
  border: 1px solid #ccc;
42
+ border-radius: 8px;
43
  resize: vertical;
44
+ font-size: 1rem;
45
  }
46
 
47
  button {
48
+ padding: 14px 32px;
49
  background: var(--primary);
50
  color: white;
51
  border: none;
52
+ border-radius: 8px;
53
  cursor: pointer;
54
+ font-size: 1.1rem;
55
  transition: background 0.2s;
56
+ display: block;
57
+ margin: 0 auto 30px;
58
  }
59
  button:hover { background: var(--primary-dark); }
60
 
61
  #result {
62
  margin-top: 30px;
63
+ padding: 24px;
64
  background: white;
65
+ border-radius: 12px;
66
+ box-shadow: 0 4px 20px rgba(0,0,0,0.1);
67
+ min-height: 200px;
68
  }
69
 
70
  .spinner {
71
+ border: 5px solid #f3f3f3;
72
+ border-top: 5px solid var(--info);
73
  border-radius: 50%;
74
+ width: 50px;
75
+ height: 50px;
76
  animation: spin 1s linear infinite;
77
+ margin: 30px auto;
78
  }
79
 
80
  @keyframes spin {
 
84
 
85
  /* Resultados de agentes */
86
  .agent-result {
87
+ margin: 20px 0;
88
+ padding: 18px;
89
+ border-radius: 10px;
90
  background: var(--bg-card);
91
  color: var(--text-light);
92
+ border-left: 5px solid var(--success);
93
+ box-shadow: 0 2px 8px rgba(0,0,0,0.2);
94
  }
95
 
96
  .agent-result.error {
 
102
  .agent-result strong {
103
  color: var(--success-light);
104
  display: block;
105
+ margin-bottom: 10px;
106
+ font-size: 1.2rem;
107
+ }
108
+
109
+ .generated-image {
110
+ margin: 20px 0;
111
+ text-align: center;
112
+ }
113
+
114
+ .generated-image img {
115
+ max-width: 100%;
116
+ border-radius: 12px;
117
+ box-shadow: 0 8px 20px rgba(0,0,0,0.3);
118
+ margin-bottom: 10px;
119
+ }
120
+
121
+ .caption {
122
+ color: #aaa;
123
+ font-size: 0.95rem;
124
+ margin-top: 8px;
125
  }
126
 
127
  .download-btn {
128
  display: inline-block;
129
+ padding: 12px 28px;
130
  background: #1976d2;
131
  color: white;
132
  text-decoration: none;
133
+ border-radius: 8px;
134
+ margin-top: 20px;
135
  transition: background 0.2s;
136
+ font-weight: bold;
137
  }
138
 
139
  .download-btn:hover {
 
144
  background: #272822;
145
  color: #f8f8f2;
146
  padding: 15px;
147
+ border-radius: 8px;
148
  overflow-x: auto;
149
  margin: 12px 0;
150
  }
 
168
  const taskInput = document.getElementById('task');
169
  const task = taskInput.value.trim();
170
  if (!task) return alert('Escribe algo primero');
171
+
172
  const output = document.getElementById('output');
173
  output.innerHTML = `
174
+ <div style="text-align:center; color:#666; padding:40px;">
175
  <div class="spinner"></div>
176
+ <p>Procesando tu misión... (puede tardar 10–90 segundos la primera vez)</p>
177
  </div>
178
  `;
179
+
180
  try {
181
  const res = await fetch('/api/mission', {
182
  method: 'POST',
183
  headers: { 'Content-Type': 'application/json' },
184
  body: JSON.stringify({ task })
185
  });
186
+
187
  const data = await res.json();
188
+
189
  if (!res.ok) {
190
  output.innerHTML = `<pre style="color:red; background:#ffebee; padding:15px; border-radius:8px;">Error ${res.status}: ${JSON.stringify(data, null, 2)}</pre>`;
191
  return;
192
  }
193
+
194
  let html = '<h3>Resultado de la misión</h3>';
195
+
196
  // Razonamiento del manager
197
  if (data.plan && data.plan.reasoning) {
198
  html += `<p><strong>Manager pensó:</strong> ${data.plan.reasoning}</p>`;
199
  }
200
+
201
  // Resultados de agentes
202
  if (data.results && data.results.length > 0) {
203
  html += '<h4>Agentes que trabajaron:</h4>';
204
+ data.results.forEach(resultado => {
205
  const isError = !resultado.success;
206
  html += `
207
  <div class="agent-result ${isError ? 'error' : ''}">
208
  <strong>${resultado.agent} (${isError ? 'Error' : 'Éxito'})</strong>
209
+ <div>${resultado.response ? resultado.response.substring(0, 400) + (resultado.response.length > 400 ? '...' : '') : resultado.error || 'Sin respuesta'}</div>`;
210
+
 
211
  // Mostrar imágenes si existen
212
+ if (resultado.image_url) {
213
+ html += `
214
+ <div class="generated-image">
215
+ <img src="${resultado.image_url}" alt="Imagen generada por ${resultado.agent}">
216
+ <div class="caption">Generada con FLUX.1-schnell</div>
217
+ </div>`;
218
+ } else if (resultado.image_urls && resultado.image_urls.length > 0) {
219
  resultado.image_urls.forEach(url => {
220
  html += `
221
+ <div class="generated-image">
222
+ <img src="${url}" alt="Imagen generada por ${resultado.agent}">
223
+ <div class="caption">Generada con FLUX.1-schnell</div>
224
  </div>`;
225
  });
226
+ } else if (resultado.queries && resultado.queries.length > 0) {
227
+ html += `<p><em>Ideas de imagen: ${resultado.queries.join(" • ")}</em></p>`;
228
  }
229
+
230
+ html += '</div>';
231
  });
232
  } else {
233
  html += '<p>No se delegó a ningún agente.</p>';
234
  }
235
+
236
  // Link de descarga de documento
237
  if (data.file_url) {
238
  html += `
 
240
  Descargar documento generado
241
  </a>`;
242
  }
243
+
244
  output.innerHTML = html;
245
  } catch (err) {
246
  output.innerHTML = `<pre style="color:red; background:#ffebee; padding:15px; border-radius:8px;">Error de conexión: ${err.message}</pre>`;