Docfile commited on
Commit
b80baf0
·
verified ·
1 Parent(s): f8f3294

Delete templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +0 -172
templates/index.html DELETED
@@ -1,172 +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
- <script src="https://cdn.tailwindcss.com"></script>
8
- <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
9
- <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/purify.min.js"></script>
10
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/github.min.css">
11
- <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
12
- <style>
13
- @keyframes gradient {
14
- 0% { background-position: 0% 50%; }
15
- 50% { background-position: 100% 50%; }
16
- 100% { background-position: 0% 50%; }
17
- }
18
- .gradient-bg {
19
- background: linear-gradient(-45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab);
20
- background-size: 400% 400%;
21
- animation: gradient 15s ease infinite;
22
- }
23
-
24
- .markdown-content h1 { @apply text-2xl font-bold mb-4 mt-6; }
25
- .markdown-content h2 { @apply text-xl font-bold mb-3 mt-5; }
26
- .markdown-content h3 { @apply text-lg font-bold mb-2 mt-4; }
27
- .markdown-content p { @apply mb-4 leading-relaxed; }
28
- .markdown-content ul { @apply list-disc ml-6 mb-4; }
29
- .markdown-content ol { @apply list-decimal ml-6 mb-4; }
30
- .markdown-content li { @apply mb-1; }
31
- .markdown-content a { @apply text-blue-600 hover:text-blue-800 underline; }
32
- .markdown-content blockquote { @apply pl-4 border-l-4 border-gray-300 italic my-4; }
33
- .markdown-content code:not(pre code) { @apply bg-gray-100 px-1 rounded text-sm font-mono; }
34
- .markdown-content pre { @apply bg-gray-100 p-4 rounded-lg mb-4 overflow-x-auto; }
35
- .markdown-content table { @apply min-w-full border border-gray-300 mb-4; }
36
- .markdown-content th { @apply bg-gray-100 border-b border-gray-300 px-4 py-2 text-left; }
37
- .markdown-content td { @apply border-b border-gray-300 px-4 py-2; }
38
- .markdown-content img { @apply max-w-full h-auto my-4 rounded-lg; }
39
- </style>
40
- </head>
41
- <body class="min-h-screen bg-gray-50">
42
- <div class="gradient-bg h-2 w-full fixed top-0"></div>
43
-
44
- <div class="max-w-4xl mx-auto px-4 py-8">
45
- <header class="text-center mb-12">
46
- <h1 class="text-4xl font-bold text-gray-800 mb-2">Mariam M-0</h1>
47
- <p class="text-gray-600">Votre assistant IA personnel</p>
48
- </header>
49
-
50
- <div class="bg-white rounded-xl shadow-lg p-6 mb-8">
51
- <textarea
52
- id="question"
53
- 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"
54
- placeholder="Posez votre question ici..."
55
- ></textarea>
56
- <button
57
- id="submitBtn"
58
- 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"
59
- >
60
- <span>Obtenir une réponse</span>
61
- <div id="spinner" class="hidden ml-3 animate-spin rounded-full h-5 w-5 border-b-2 border-white"></div>
62
- </button>
63
- </div>
64
-
65
- <div id="responseContainer" class="space-y-6">
66
- <div id="answerBox" class="hidden bg-white rounded-xl shadow-lg p-6">
67
- <h2 class="text-xl font-semibold text-gray-800 mb-4">Réponse</h2>
68
- <div id="answer" class="markdown-content text-gray-700"></div>
69
- </div>
70
-
71
- <div id="thinkingBox" class="hidden bg-white rounded-xl shadow-lg p-6">
72
- <div class="flex items-center justify-between mb-4">
73
- <h2 class="text-xl font-semibold text-gray-800">Raisonnement</h2>
74
- <button id="toggleThinking" class="text-blue-500 hover:text-blue-600">
75
- Afficher
76
- </button>
77
- </div>
78
- <div id="thinking" class="hidden markdown-content text-gray-600"></div>
79
- </div>
80
- </div>
81
- </div>
82
-
83
- <script>
84
- // Configuration de marked
85
- marked.setOptions({
86
- highlight: function(code, lang) {
87
- if (lang && hljs.getLanguage(lang)) {
88
- return hljs.highlight(code, { language: lang }).value;
89
- }
90
- return hljs.highlightAuto(code).value;
91
- },
92
- breaks: true,
93
- gfm: true
94
- });
95
-
96
- // Fonction pour rendre le Markdown de manière sécurisée
97
- function renderMarkdown(content) {
98
- const rawHtml = marked.parse(content);
99
- return DOMPurify.sanitize(rawHtml);
100
- }
101
-
102
- const submitBtn = document.getElementById('submitBtn');
103
- const spinner = document.getElementById('spinner');
104
- const answerBox = document.getElementById('answerBox');
105
- const thinkingBox = document.getElementById('thinkingBox');
106
- const answer = document.getElementById('answer');
107
- const thinking = document.getElementById('thinking');
108
- const toggleThinking = document.getElementById('toggleThinking');
109
-
110
- toggleThinking.addEventListener('click', () => {
111
- const isHidden = thinking.classList.contains('hidden');
112
- thinking.classList.toggle('hidden');
113
- toggleThinking.textContent = isHidden ? 'Masquer' : 'Afficher';
114
- });
115
-
116
- submitBtn.addEventListener('click', async () => {
117
- const question = document.getElementById('question').value;
118
- if (!question.trim()) return;
119
-
120
- // Reset UI
121
- answer.innerHTML = '';
122
- thinking.innerHTML = '';
123
- submitBtn.disabled = true;
124
- spinner.classList.remove('hidden');
125
- answerBox.classList.add('hidden');
126
- thinkingBox.classList.add('hidden');
127
-
128
- try {
129
- const response = await fetch('/ask', {
130
- method: 'POST',
131
- headers: {
132
- 'Content-Type': 'application/json',
133
- },
134
- body: JSON.stringify({ question }),
135
- });
136
-
137
- const reader = response.body.getReader();
138
- const decoder = new TextDecoder();
139
-
140
- while (true) {
141
- const { done, value } = await reader.read();
142
- if (done) break;
143
-
144
- const chunks = decoder.decode(value).split('\n');
145
- chunks.forEach(chunk => {
146
- if (!chunk) return;
147
-
148
- const data = JSON.parse(chunk);
149
- if (data.type === 'thinking') {
150
- thinkingBox.classList.remove('hidden');
151
- thinking.innerHTML = renderMarkdown(data.content);
152
- } else if (data.type === 'answer') {
153
- answerBox.classList.remove('hidden');
154
- answer.innerHTML = renderMarkdown(data.content);
155
- // Mettre à jour la coloration syntaxique pour les nouveaux blocs de code
156
- answer.querySelectorAll('pre code').forEach((block) => {
157
- hljs.highlightBlock(block);
158
- });
159
- }
160
- });
161
- }
162
- } catch (error) {
163
- console.error('Error:', error);
164
- answer.innerHTML = renderMarkdown("❌ Une erreur est survenue. Veuillez réessayer.");
165
- } finally {
166
- submitBtn.disabled = false;
167
- spinner.classList.add('hidden');
168
- }
169
- });
170
- </script>
171
- </body>
172
- </html>