Docfile commited on
Commit
306906f
·
verified ·
1 Parent(s): 27b832f

Delete templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +0 -234
templates/index.html DELETED
@@ -1,234 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="fr">
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Mariam M-0</title>
7
-
8
- <!-- Intégration de Tailwind CSS -->
9
- <script defer src="https://cdn.tailwindcss.com"></script>
10
-
11
- <!-- Marked pour le rendu Markdown -->
12
- <script defer src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
13
-
14
- <!-- DOMPurify pour sécuriser le rendu HTML -->
15
- <script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/purify.min.js"></script>
16
-
17
- <!-- Highlight.js pour la coloration syntaxique -->
18
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/github.min.css">
19
- <script defer src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
20
-
21
- <style>
22
- @keyframes gradient {
23
- 0% { background-position: 0% 50%; }
24
- 50% { background-position: 100% 50%; }
25
- 100% { background-position: 0% 50%; }
26
- }
27
- .gradient-bg {
28
- background: linear-gradient(-45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab);
29
- background-size: 400% 400%;
30
- animation: gradient 15s ease infinite;
31
- }
32
-
33
- /* Assurer la bonne gestion des espaces et retours à la ligne sur mobile */
34
- .markdown-content {
35
- white-space: pre-wrap;
36
- word-break: break-word;
37
- }
38
-
39
- /* Utilisation des directives @apply de Tailwind pour le contenu Markdown */
40
- .markdown-content h1 { @apply text-2xl font-bold mb-4 mt-6; }
41
- .markdown-content h2 { @apply text-xl font-bold mb-3 mt-5; }
42
- .markdown-content h3 { @apply text-lg font-bold mb-2 mt-4; }
43
- .markdown-content p { @apply mb-4 leading-relaxed; }
44
- .markdown-content ul { @apply list-disc ml-6 mb-4; }
45
- .markdown-content ol { @apply list-decimal ml-6 mb-4; }
46
- .markdown-content li { @apply mb-1; }
47
- .markdown-content a { @apply text-blue-600 hover:text-blue-800 underline; }
48
- .markdown-content blockquote { @apply pl-4 border-l-4 border-gray-300 italic my-4; }
49
- .markdown-content code:not(pre code) { @apply bg-gray-100 px-1 rounded text-sm font-mono; }
50
- .markdown-content pre { @apply bg-gray-100 p-4 rounded-lg mb-4 overflow-x-auto; }
51
- .markdown-content table { @apply min-w-full border border-gray-300 mb-4; }
52
- .markdown-content th { @apply bg-gray-100 border-b border-gray-300 px-4 py-2 text-left; }
53
- .markdown-content td { @apply border-b border-gray-300 px-4 py-2; }
54
- .markdown-content img { @apply max-w-full h-auto my-4 rounded-lg; }
55
- </style>
56
- </head>
57
- <body class="min-h-screen bg-gray-50">
58
- <!-- Barre de gradient fixe en haut de page -->
59
- <div class="gradient-bg h-2 w-full fixed top-0"></div>
60
-
61
- <div class="max-w-4xl mx-auto px-4 py-8">
62
- <header class="text-center mb-12">
63
- <h1 class="text-4xl font-bold text-gray-800 mb-2">Mariam M-0</h1>
64
- <p class="text-gray-600">Votre assistant IA personnel</p>
65
- </header>
66
-
67
- <main>
68
- <section class="bg-white rounded-xl shadow-lg p-6 mb-8">
69
- <textarea
70
- id="question"
71
- class="w-full h-32 p-4 border border-gray-200 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent resize-none"
72
- placeholder="Posez votre question ici..."
73
- aria-label="Zone de saisie de la question"
74
- ></textarea>
75
- <button
76
- id="submitBtn"
77
- class="mt-4 px-6 py-3 bg-gradient-to-r from-blue-500 to-blue-600 text-white rounded-lg hover:from-blue-600 hover:to-blue-700 transition-all duration-200 flex items-center justify-center w-full sm:w-auto"
78
- aria-label="Obtenir une réponse"
79
- >
80
- <span>Obtenir une réponse</span>
81
- <div id="spinner" class="hidden ml-3 animate-spin rounded-full h-5 w-5 border-b-2 border-white" aria-hidden="true"></div>
82
- </button>
83
- </section>
84
-
85
- <section id="responseContainer" class="space-y-6">
86
- <article id="answerBox" class="hidden bg-white rounded-xl shadow-lg p-6 relative">
87
- <div class="flex items-center justify-between mb-4">
88
- <h2 class="text-xl font-semibold text-gray-800">Réponse</h2>
89
- <!-- Bouton Copier -->
90
- <button
91
- id="copyBtn"
92
- class="px-3 py-1 bg-blue-500 text-white text-sm rounded hover:bg-blue-600 transition-colors"
93
- title="Copier la réponse"
94
- aria-label="Copier la réponse"
95
- >
96
- Copier
97
- </button>
98
- </div>
99
- <div id="answer" class="markdown-content text-gray-700"></div>
100
- </article>
101
-
102
- <article id="thinkingBox" class="hidden bg-white rounded-xl shadow-lg p-6">
103
- <div class="flex items-center justify-between mb-4">
104
- <h2 class="text-xl font-semibold text-gray-800">Raisonnement</h2>
105
- <button
106
- id="toggleThinking"
107
- class="text-blue-500 hover:text-blue-600 focus:outline-none"
108
- aria-expanded="false"
109
- aria-controls="thinking"
110
- >
111
- Afficher
112
- </button>
113
- </div>
114
- <div id="thinking" class="hidden markdown-content text-gray-600"></div>
115
- </article>
116
- </section>
117
- </main>
118
- </div>
119
-
120
- <script defer>
121
- // Configuration de marked pour le rendu Markdown
122
- marked.setOptions({
123
- highlight: function(code, lang) {
124
- if (lang && hljs.getLanguage(lang)) {
125
- return hljs.highlight(code, { language: lang }).value;
126
- }
127
- return hljs.highlightAuto(code).value;
128
- },
129
- breaks: true,
130
- gfm: true
131
- });
132
-
133
- /**
134
- * Fonction pour rendre le Markdown de manière sécurisée.
135
- * @param {string} content - Le contenu en Markdown.
136
- * @returns {string} Le HTML rendu et sécurisé.
137
- */
138
- function renderMarkdown(content) {
139
- const rawHtml = marked.parse(content);
140
- return DOMPurify.sanitize(rawHtml);
141
- }
142
-
143
- const submitBtn = document.getElementById('submitBtn');
144
- const spinner = document.getElementById('spinner');
145
- const answerBox = document.getElementById('answerBox');
146
- const thinkingBox = document.getElementById('thinkingBox');
147
- const answer = document.getElementById('answer');
148
- const thinking = document.getElementById('thinking');
149
- const toggleThinking = document.getElementById('toggleThinking');
150
- const copyBtn = document.getElementById('copyBtn');
151
-
152
- // Bouton pour basculer l'affichage du raisonnement
153
- toggleThinking.addEventListener('click', () => {
154
- const isHidden = thinking.classList.contains('hidden');
155
- thinking.classList.toggle('hidden');
156
- toggleThinking.textContent = isHidden ? 'Masquer' : 'Afficher';
157
- toggleThinking.setAttribute('aria-expanded', isHidden);
158
- });
159
-
160
- // Bouton Copier
161
- copyBtn.addEventListener('click', () => {
162
- // Crée un élément temporaire pour copier le texte brut (sans HTML)
163
- const tempElement = document.createElement('textarea');
164
- tempElement.value = answer.innerText;
165
- document.body.appendChild(tempElement);
166
- tempElement.select();
167
- try {
168
- document.execCommand('copy');
169
- copyBtn.textContent = 'Copié';
170
- setTimeout(() => {
171
- copyBtn.textContent = 'Copier';
172
- }, 1500);
173
- } catch (err) {
174
- console.error('Erreur lors de la copie :', err);
175
- }
176
- document.body.removeChild(tempElement);
177
- });
178
-
179
- // Gestion de la soumission de la question
180
- submitBtn.addEventListener('click', async () => {
181
- const question = document.getElementById('question').value;
182
- if (!question.trim()) return;
183
-
184
- // Réinitialisation de l'interface utilisateur
185
- answer.innerHTML = '';
186
- thinking.innerHTML = '';
187
- submitBtn.disabled = true;
188
- spinner.classList.remove('hidden');
189
- answerBox.classList.add('hidden');
190
- thinkingBox.classList.add('hidden');
191
-
192
- try {
193
- const response = await fetch('/ask', {
194
- method: 'POST',
195
- headers: { 'Content-Type': 'application/json' },
196
- body: JSON.stringify({ question })
197
- });
198
-
199
- // Lecture du flux de réponse en continu
200
- const reader = response.body.getReader();
201
- const decoder = new TextDecoder();
202
-
203
- while (true) {
204
- const { done, value } = await reader.read();
205
- if (done) break;
206
- const chunks = decoder.decode(value).split('\n');
207
- chunks.forEach(chunk => {
208
- if (!chunk) return;
209
- const data = JSON.parse(chunk);
210
- if (data.type === 'thinking') {
211
- thinkingBox.classList.remove('hidden');
212
- thinking.innerHTML = renderMarkdown(data.content);
213
- } else if (data.type === 'answer') {
214
- answerBox.classList.remove('hidden');
215
- answer.innerHTML = renderMarkdown(data.content);
216
- // Rafraîchissement de la coloration syntaxique pour les blocs de code
217
- answer.querySelectorAll('pre code').forEach(block => {
218
- hljs.highlightElement(block);
219
- });
220
- }
221
- });
222
- }
223
- } catch (error) {
224
- console.error('Error:', error);
225
- answer.innerHTML = renderMarkdown("❌ Une erreur est survenue. Veuillez réessayer.");
226
- answerBox.classList.remove('hidden');
227
- } finally {
228
- submitBtn.disabled = false;
229
- spinner.classList.add('hidden');
230
- }
231
- });
232
- </script>
233
- </body>
234
- </html>