Spaces:
Sleeping
Sleeping
EL GHAFRAOUI AYOUB
commited on
Commit
·
d4ce05f
1
Parent(s):
f1aa5ef
- app/templates/index.html +59 -47
app/templates/index.html
CHANGED
@@ -207,6 +207,17 @@
|
|
207 |
<div id="featuresOutput" class="bg-gray-50 rounded p-4 min-h-32"></div>
|
208 |
</div>
|
209 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
210 |
<!-- Add this right after the form -->
|
211 |
<div id="rawOutput" class="mt-8 bg-white rounded-lg shadow-lg p-6">
|
212 |
<h2 class="text-xl font-bold mb-4 text-gray-800">Raw Response Data</h2>
|
@@ -462,35 +473,53 @@
|
|
462 |
body: JSON.stringify(requestData)
|
463 |
});
|
464 |
|
465 |
-
const
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
487 |
|
488 |
} catch (error) {
|
489 |
console.error('Error:', error);
|
490 |
-
document.getElementById('rawApiResponse').textContent = `Error: ${error.message}`;
|
491 |
alert('Error generating plan');
|
492 |
} finally {
|
493 |
loading.style.display = 'none';
|
|
|
|
|
494 |
}
|
495 |
}
|
496 |
|
@@ -534,33 +563,16 @@
|
|
534 |
title.textContent = `Technical Project Plan: ${data.project_title}`;
|
535 |
sections.innerHTML = '';
|
536 |
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
.
|
541 |
-
|
542 |
-
|
543 |
-
const section = document.createElement('div');
|
544 |
-
section.className = 'mb-6 bg-white p-4 rounded shadow';
|
545 |
-
section.innerHTML = `
|
546 |
-
<h4 class="text-lg font-semibold mb-3 text-blue-600">${sectionTitle}</h4>
|
547 |
-
<div class="whitespace-pre-wrap text-gray-700 prose max-w-none">
|
548 |
-
${content}
|
549 |
-
</div>
|
550 |
-
`;
|
551 |
-
sections.appendChild(section);
|
552 |
});
|
553 |
|
554 |
-
output.classList.
|
555 |
}
|
556 |
-
|
557 |
-
// Add keyboard shortcut to toggle debug panel
|
558 |
-
document.addEventListener('keydown', function(e) {
|
559 |
-
if (e.ctrlKey && e.key === 'd') {
|
560 |
-
e.preventDefault();
|
561 |
-
toggleDebugPanel();
|
562 |
-
}
|
563 |
-
});
|
564 |
</script>
|
565 |
</body>
|
566 |
</html>
|
|
|
207 |
<div id="featuresOutput" class="bg-gray-50 rounded p-4 min-h-32"></div>
|
208 |
</div>
|
209 |
|
210 |
+
<!-- Add this before the rawOutput div -->
|
211 |
+
<div id="progressBar" class="hidden mt-4 mb-8">
|
212 |
+
<div class="flex justify-between mb-1">
|
213 |
+
<span class="text-sm font-medium text-blue-700" id="progressText">0%</span>
|
214 |
+
<span class="text-sm font-medium text-blue-700" id="progressStep">Step 0/100</span>
|
215 |
+
</div>
|
216 |
+
<div class="w-full bg-gray-200 rounded-full h-2.5">
|
217 |
+
<div class="bg-blue-600 h-2.5 rounded-full transition-all duration-150" id="progressFill" style="width: 0%"></div>
|
218 |
+
</div>
|
219 |
+
</div>
|
220 |
+
|
221 |
<!-- Add this right after the form -->
|
222 |
<div id="rawOutput" class="mt-8 bg-white rounded-lg shadow-lg p-6">
|
223 |
<h2 class="text-xl font-bold mb-4 text-gray-800">Raw Response Data</h2>
|
|
|
473 |
body: JSON.stringify(requestData)
|
474 |
});
|
475 |
|
476 |
+
const reader = response.body.getReader();
|
477 |
+
const decoder = new TextDecoder();
|
478 |
+
|
479 |
+
// Show progress bar
|
480 |
+
document.getElementById('progressBar').classList.remove('hidden');
|
481 |
+
|
482 |
+
while (true) {
|
483 |
+
const { value, done } = await reader.read();
|
484 |
+
if (done) break;
|
485 |
+
|
486 |
+
const chunk = decoder.decode(value);
|
487 |
+
const lines = chunk.split('\n');
|
488 |
+
|
489 |
+
for (const line of lines) {
|
490 |
+
if (line.startsWith('data: ')) {
|
491 |
+
const data = JSON.parse(line.slice(5));
|
492 |
+
|
493 |
+
if (data.type === 'progress') {
|
494 |
+
// Update progress bar
|
495 |
+
const progressFill = document.getElementById('progressFill');
|
496 |
+
const progressText = document.getElementById('progressText');
|
497 |
+
const progressStep = document.getElementById('progressStep');
|
498 |
+
|
499 |
+
progressFill.style.width = `${data.progress}%`;
|
500 |
+
progressText.textContent = `${Math.round(data.progress)}%`;
|
501 |
+
progressStep.textContent = `Step ${data.step}/${data.total}`;
|
502 |
+
} else if (data.type === 'complete') {
|
503 |
+
// Display final results
|
504 |
+
displayPlan(data);
|
505 |
+
document.getElementById('rawApiResponse').textContent = JSON.stringify(data, null, 2);
|
506 |
+
document.getElementById('rawContent').textContent = data.raw_content;
|
507 |
+
document.getElementById('rawSections').textContent = JSON.stringify(data.sections, null, 2);
|
508 |
+
} else if (data.type === 'error') {
|
509 |
+
console.error('Error:', data.error);
|
510 |
+
alert(`Error: ${data.error}`);
|
511 |
+
}
|
512 |
+
}
|
513 |
+
}
|
514 |
+
}
|
515 |
|
516 |
} catch (error) {
|
517 |
console.error('Error:', error);
|
|
|
518 |
alert('Error generating plan');
|
519 |
} finally {
|
520 |
loading.style.display = 'none';
|
521 |
+
// Hide progress bar when done
|
522 |
+
document.getElementById('progressBar').classList.add('hidden');
|
523 |
}
|
524 |
}
|
525 |
|
|
|
563 |
title.textContent = `Technical Project Plan: ${data.project_title}`;
|
564 |
sections.innerHTML = '';
|
565 |
|
566 |
+
// Keep only debug panel toggle functionality
|
567 |
+
document.addEventListener('keydown', function(e) {
|
568 |
+
if (e.ctrlKey && e.key === 'd') {
|
569 |
+
e.preventDefault();
|
570 |
+
toggleDebugPanel();
|
571 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
572 |
});
|
573 |
|
574 |
+
output.classList.add('hidden'); // Hide the output section
|
575 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
576 |
</script>
|
577 |
</body>
|
578 |
</html>
|