Spaces:
Sleeping
Sleeping
EL GHAFRAOUI AYOUB
commited on
Commit
·
d270add
1
Parent(s):
724e52e
C'
Browse files- app/templates/index.html +124 -58
app/templates/index.html
CHANGED
@@ -152,25 +152,36 @@
|
|
152 |
<h3 class="text-lg font-semibold mb-2" id="planTitle"></h3>
|
153 |
<div id="planSections" class="space-y-4"></div>
|
154 |
</div>
|
155 |
-
<div id="debugPanel" class="mt-6 bg-gray-800 rounded p-4 text-white
|
156 |
<div class="flex justify-between items-center mb-4">
|
157 |
<h3 class="text-lg font-semibold">Debug Panel</h3>
|
158 |
-
<
|
159 |
-
<
|
160 |
-
|
|
|
|
|
|
|
|
|
|
|
161 |
</div>
|
|
|
162 |
<div class="space-y-4">
|
163 |
-
<div>
|
164 |
-
<h4 class="text-sm font-semibold text-gray-400">Request Data</h4>
|
165 |
-
<pre id="requestData" class="text-xs bg-gray-900 p-
|
166 |
</div>
|
167 |
-
|
168 |
-
|
169 |
-
<
|
|
|
|
|
|
|
|
|
170 |
</div>
|
|
|
171 |
<div>
|
172 |
-
<h4 class="text-sm font-semibold text-gray-400">Parsed Sections</h4>
|
173 |
-
<pre id="parsedSections" class="text-xs bg-gray-900 p-
|
174 |
</div>
|
175 |
</div>
|
176 |
</div>
|
@@ -195,6 +206,37 @@
|
|
195 |
</div>
|
196 |
<div id="featuresOutput" class="bg-gray-50 rounded p-4 min-h-32"></div>
|
197 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
198 |
</div>
|
199 |
|
200 |
<!-- Chat Widget -->
|
@@ -397,40 +439,55 @@
|
|
397 |
return;
|
398 |
}
|
399 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
400 |
const loading = document.getElementById('planLoading');
|
401 |
const output = document.getElementById('planOutput');
|
402 |
loading.style.display = 'block';
|
403 |
output.classList.add('hidden');
|
404 |
|
405 |
try {
|
406 |
-
console.log('Sending request with data:', {
|
407 |
-
project_title: projectTitle,
|
408 |
-
requirements,
|
409 |
-
features,
|
410 |
-
platform,
|
411 |
-
additional_requirements: additionalRequirements
|
412 |
-
});
|
413 |
-
|
414 |
const response = await fetch('/generate-plan', {
|
415 |
method: 'POST',
|
416 |
headers: { 'Content-Type': 'application/json' },
|
417 |
-
body: JSON.stringify(
|
418 |
-
project_title: projectTitle,
|
419 |
-
requirements,
|
420 |
-
features,
|
421 |
-
platform,
|
422 |
-
additional_requirements: additionalRequirements
|
423 |
-
})
|
424 |
});
|
425 |
|
426 |
const data = await response.json();
|
427 |
-
console.log('Raw API Response:', data);
|
428 |
-
console.log('Sections:', data.sections);
|
429 |
-
console.log('Raw Content:', data.raw_content);
|
430 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
431 |
displayPlan(data);
|
|
|
|
|
|
|
|
|
432 |
} catch (error) {
|
433 |
-
console.error('Error
|
|
|
434 |
alert('Error generating plan');
|
435 |
} finally {
|
436 |
loading.style.display = 'none';
|
@@ -442,59 +499,68 @@
|
|
442 |
debugPanel.classList.toggle('hidden');
|
443 |
}
|
444 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
445 |
function displayPlan(data) {
|
446 |
-
console.log('Displaying plan data:', data);
|
447 |
const output = document.getElementById('planOutput');
|
448 |
const title = document.getElementById('planTitle');
|
449 |
const sections = document.getElementById('planSections');
|
450 |
|
451 |
-
|
452 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
453 |
|
454 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
455 |
sections.innerHTML = '';
|
456 |
|
457 |
-
// Display each section
|
458 |
Object.entries(data.sections).forEach(([key, content]) => {
|
459 |
-
console.log(`Processing section ${key}:`, content);
|
460 |
-
|
461 |
const sectionTitle = key
|
462 |
.split('_')
|
463 |
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
|
464 |
.join(' ');
|
465 |
|
466 |
-
// Format the content based on type
|
467 |
-
let formattedContent = content;
|
468 |
-
if (typeof content === 'object') {
|
469 |
-
console.log(`Section ${key} is an object:`, content);
|
470 |
-
formattedContent = Object.entries(content)
|
471 |
-
.map(([k, v]) => `<strong>${k}:</strong> ${v}`)
|
472 |
-
.join('<br>');
|
473 |
-
}
|
474 |
-
|
475 |
const section = document.createElement('div');
|
476 |
section.className = 'mb-6 bg-white p-4 rounded shadow';
|
477 |
section.innerHTML = `
|
478 |
<h4 class="text-lg font-semibold mb-3 text-blue-600">${sectionTitle}</h4>
|
479 |
<div class="whitespace-pre-wrap text-gray-700 prose max-w-none">
|
480 |
-
${
|
481 |
</div>
|
482 |
`;
|
483 |
sections.appendChild(section);
|
484 |
});
|
485 |
|
486 |
-
console.log('Final HTML output:', sections.innerHTML);
|
487 |
output.classList.remove('hidden');
|
488 |
-
|
489 |
-
// Update debug panel
|
490 |
-
document.getElementById('debugPanel').classList.remove('hidden');
|
491 |
-
document.getElementById('requestData').textContent = JSON.stringify({
|
492 |
-
project_title: data.project_title,
|
493 |
-
sections: data.sections
|
494 |
-
}, null, 2);
|
495 |
-
document.getElementById('rawResponse').textContent = data.raw_content;
|
496 |
-
document.getElementById('parsedSections').textContent = JSON.stringify(data.sections, null, 2);
|
497 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
498 |
</script>
|
499 |
</body>
|
500 |
</html>
|
|
|
152 |
<h3 class="text-lg font-semibold mb-2" id="planTitle"></h3>
|
153 |
<div id="planSections" class="space-y-4"></div>
|
154 |
</div>
|
155 |
+
<div id="debugPanel" class="mt-6 bg-gray-800 rounded-lg p-4 text-white">
|
156 |
<div class="flex justify-between items-center mb-4">
|
157 |
<h3 class="text-lg font-semibold">Debug Panel</h3>
|
158 |
+
<div class="space-x-2">
|
159 |
+
<button onclick="copyRawContent()" class="text-xs bg-blue-500 hover:bg-blue-600 px-2 py-1 rounded">
|
160 |
+
<i class="fas fa-copy mr-1"></i>Copy
|
161 |
+
</button>
|
162 |
+
<button onclick="toggleDebugPanel()" class="text-gray-400 hover:text-white">
|
163 |
+
<i class="fas fa-times"></i>
|
164 |
+
</button>
|
165 |
+
</div>
|
166 |
</div>
|
167 |
+
|
168 |
<div class="space-y-4">
|
169 |
+
<div class="border-b border-gray-700 pb-4">
|
170 |
+
<h4 class="text-sm font-semibold text-gray-400 mb-2">Request Data</h4>
|
171 |
+
<pre id="requestData" class="text-xs bg-gray-900 p-3 rounded overflow-auto max-h-40 font-mono"></pre>
|
172 |
</div>
|
173 |
+
|
174 |
+
<div class="border-b border-gray-700 pb-4">
|
175 |
+
<div class="flex justify-between items-center mb-2">
|
176 |
+
<h4 class="text-sm font-semibold text-gray-400">Raw Model Output</h4>
|
177 |
+
<span id="rawContentLength" class="text-xs text-gray-500"></span>
|
178 |
+
</div>
|
179 |
+
<pre id="rawContent" class="text-xs bg-gray-900 p-3 rounded overflow-auto max-h-96 font-mono whitespace-pre-wrap"></pre>
|
180 |
</div>
|
181 |
+
|
182 |
<div>
|
183 |
+
<h4 class="text-sm font-semibold text-gray-400 mb-2">Parsed Sections</h4>
|
184 |
+
<pre id="parsedSections" class="text-xs bg-gray-900 p-3 rounded overflow-auto max-h-40 font-mono"></pre>
|
185 |
</div>
|
186 |
</div>
|
187 |
</div>
|
|
|
206 |
</div>
|
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>
|
213 |
+
|
214 |
+
<div class="space-y-6">
|
215 |
+
<!-- Request Data -->
|
216 |
+
<div class="bg-gray-50 p-4 rounded-lg">
|
217 |
+
<h3 class="text-lg font-semibold mb-2 text-blue-600">Request Data</h3>
|
218 |
+
<pre id="rawRequest" class="bg-gray-900 text-green-400 p-4 rounded overflow-auto max-h-60 font-mono text-sm whitespace-pre-wrap"></pre>
|
219 |
+
</div>
|
220 |
+
|
221 |
+
<!-- API Response -->
|
222 |
+
<div class="bg-gray-50 p-4 rounded-lg">
|
223 |
+
<h3 class="text-lg font-semibold mb-2 text-blue-600">API Response</h3>
|
224 |
+
<pre id="rawApiResponse" class="bg-gray-900 text-green-400 p-4 rounded overflow-auto max-h-96 font-mono text-sm whitespace-pre-wrap"></pre>
|
225 |
+
</div>
|
226 |
+
|
227 |
+
<!-- Raw Content -->
|
228 |
+
<div class="bg-gray-50 p-4 rounded-lg">
|
229 |
+
<h3 class="text-lg font-semibold mb-2 text-blue-600">Raw Content</h3>
|
230 |
+
<pre id="rawContent" class="bg-gray-900 text-green-400 p-4 rounded overflow-auto max-h-96 font-mono text-sm whitespace-pre-wrap"></pre>
|
231 |
+
</div>
|
232 |
+
|
233 |
+
<!-- Parsed Sections -->
|
234 |
+
<div class="bg-gray-50 p-4 rounded-lg">
|
235 |
+
<h3 class="text-lg font-semibold mb-2 text-blue-600">Parsed Sections</h3>
|
236 |
+
<pre id="rawSections" class="bg-gray-900 text-green-400 p-4 rounded overflow-auto max-h-96 font-mono text-sm whitespace-pre-wrap"></pre>
|
237 |
+
</div>
|
238 |
+
</div>
|
239 |
+
</div>
|
240 |
</div>
|
241 |
|
242 |
<!-- Chat Widget -->
|
|
|
439 |
return;
|
440 |
}
|
441 |
|
442 |
+
const requestData = {
|
443 |
+
project_title: projectTitle,
|
444 |
+
requirements,
|
445 |
+
features,
|
446 |
+
platform,
|
447 |
+
additional_requirements: additionalRequirements
|
448 |
+
};
|
449 |
+
|
450 |
+
// Display request data
|
451 |
+
document.getElementById('rawRequest').textContent = JSON.stringify(requestData, null, 2);
|
452 |
+
|
453 |
const loading = document.getElementById('planLoading');
|
454 |
const output = document.getElementById('planOutput');
|
455 |
loading.style.display = 'block';
|
456 |
output.classList.add('hidden');
|
457 |
|
458 |
try {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
459 |
const response = await fetch('/generate-plan', {
|
460 |
method: 'POST',
|
461 |
headers: { 'Content-Type': 'application/json' },
|
462 |
+
body: JSON.stringify(requestData)
|
|
|
|
|
|
|
|
|
|
|
|
|
463 |
});
|
464 |
|
465 |
const data = await response.json();
|
|
|
|
|
|
|
466 |
|
467 |
+
// Display complete API response
|
468 |
+
document.getElementById('rawApiResponse').textContent = JSON.stringify(data, null, 2);
|
469 |
+
|
470 |
+
// Display raw content
|
471 |
+
document.getElementById('rawContent').textContent = data.raw_content;
|
472 |
+
|
473 |
+
// Display parsed sections
|
474 |
+
document.getElementById('rawSections').textContent = JSON.stringify(data.sections, null, 2);
|
475 |
+
|
476 |
+
// Log everything to console
|
477 |
+
console.log('Request:', requestData);
|
478 |
+
console.log('API Response:', data);
|
479 |
+
console.log('Raw Content:', data.raw_content);
|
480 |
+
console.log('Sections:', data.sections);
|
481 |
+
|
482 |
+
// Still display the formatted plan
|
483 |
displayPlan(data);
|
484 |
+
|
485 |
+
// Show raw output section
|
486 |
+
document.getElementById('rawOutput').classList.remove('hidden');
|
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';
|
|
|
499 |
debugPanel.classList.toggle('hidden');
|
500 |
}
|
501 |
|
502 |
+
function copyRawContent() {
|
503 |
+
const rawContent = document.getElementById('rawContent').textContent;
|
504 |
+
navigator.clipboard.writeText(rawContent).then(() => {
|
505 |
+
alert('Raw content copied to clipboard!');
|
506 |
+
});
|
507 |
+
}
|
508 |
+
|
509 |
function displayPlan(data) {
|
|
|
510 |
const output = document.getElementById('planOutput');
|
511 |
const title = document.getElementById('planTitle');
|
512 |
const sections = document.getElementById('planSections');
|
513 |
|
514 |
+
// Update debug panel with raw data
|
515 |
+
document.getElementById('requestData').textContent = JSON.stringify({
|
516 |
+
project_title: data.project_title,
|
517 |
+
sections: data.sections
|
518 |
+
}, null, 2);
|
519 |
+
|
520 |
+
// Display raw content with line breaks preserved
|
521 |
+
const rawContent = document.getElementById('rawContent');
|
522 |
+
rawContent.textContent = data.raw_content;
|
523 |
|
524 |
+
// Show content length
|
525 |
+
const contentLength = data.raw_content.length;
|
526 |
+
document.getElementById('rawContentLength').textContent =
|
527 |
+
`Length: ${contentLength} characters`;
|
528 |
+
|
529 |
+
// Display parsed sections
|
530 |
+
document.getElementById('parsedSections').textContent =
|
531 |
+
JSON.stringify(data.sections, null, 2);
|
532 |
+
|
533 |
+
// Original plan display code
|
534 |
+
title.textContent = `Technical Project Plan: ${data.project_title}`;
|
535 |
sections.innerHTML = '';
|
536 |
|
|
|
537 |
Object.entries(data.sections).forEach(([key, content]) => {
|
|
|
|
|
538 |
const sectionTitle = key
|
539 |
.split('_')
|
540 |
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
|
541 |
.join(' ');
|
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.remove('hidden');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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>
|