index.html 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <!DOCTYPE html>
  2. <html lang="fr">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <title>QA Agent Wiki</title>
  6. <style>
  7. body {
  8. font-family: Arial, sans-serif;
  9. margin: 40px;
  10. max-width: 800px;
  11. }
  12. h1 {
  13. color: #333;
  14. }
  15. input, textarea, button {
  16. width: 100%;
  17. padding: 10px;
  18. margin-top: 10px;
  19. margin-bottom: 20px;
  20. border: 1px solid #ccc;
  21. border-radius: 5px;
  22. }
  23. button {
  24. background-color: #007bff;
  25. color: white;
  26. font-weight: bold;
  27. cursor: pointer;
  28. }
  29. button:hover {
  30. background-color: #0056b3;
  31. }
  32. .response {
  33. background: #f1f1f1;
  34. padding: 15px;
  35. border-radius: 5px;
  36. white-space: pre-wrap;
  37. }
  38. </style>
  39. </head>
  40. <body>
  41. <h1>🔍 Posez une question à l’IA</h1>
  42. <!-- Affiché directement (plus de display: none) -->
  43. <div id="qa-section">
  44. <h3>Votre question</h3>
  45. <textarea id="question" rows="4" placeholder="Posez votre question ici..."></textarea>
  46. <button onclick="askQuestion()">Envoyer</button>
  47. <h3>Réponse de l'IA</h3>
  48. <div class="response" id="answer"></div>
  49. </div>
  50. <script>
  51. async function askQuestion() {
  52. const question = document.getElementById("question").value.trim();
  53. const answerBox = document.getElementById("answer");
  54. if (!question) {
  55. answerBox.innerText = "❗ Veuillez entrer une question.";
  56. return;
  57. }
  58. answerBox.innerText = "⏳ Recherche de la réponse...";
  59. try {
  60. const res = await fetch("/qa_chain", {
  61. method: "POST",
  62. headers: {
  63. "Content-Type": "application/json"
  64. },
  65. body: JSON.stringify({ question })
  66. });
  67. if (!res.ok) {
  68. throw new Error("Erreur du serveur");
  69. }
  70. const data = await res.json();
  71. answerBox.innerText = data.answer || "❌ Aucune réponse trouvée.";
  72. } catch (error) {
  73. answerBox.innerText = "❌ Erreur : " + error.message;
  74. }
  75. }
  76. </script>
  77. </body>
  78. </html>