Update templates/index.html
Browse files- templates/index.html +864 -268
templates/index.html
CHANGED
|
@@ -1,278 +1,874 @@
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
<html lang="fr">
|
| 3 |
<head>
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
</label>
|
| 136 |
-
<label class="flex items-center cursor-pointer tooltip">
|
| 137 |
-
<span class="mr-2 text-xs sm:text-sm font-medium text-accent-700 dark:text-accent-300"><i class="fa-solid fa-brain mr-1.5"></i><span class="hidden sm:inline">Avancé</span><span id="advanced-cooldown-timer" class="text-xs ml-1 hidden"></span></span>
|
| 138 |
-
<label class="relative inline-flex items-center cursor-pointer"><input type="checkbox" id="advanced_reasoning_toggle" name="advanced_reasoning" value="true" class="sr-only peer"><div class="w-9 h-5 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-purple-300 dark:peer-focus:ring-purple-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-4 after:w-4 after:transition-all dark:border-gray-600 peer-checked:bg-purple-600"></div></label>
|
| 139 |
-
<span class="tooltip-text">Utiliser le modèle Pro (plus puissant, 1 fois/min)</span>
|
| 140 |
-
</label>
|
| 141 |
-
</div>
|
| 142 |
-
<div class="flex items-center space-x-2">
|
| 143 |
-
<label for="file_upload" class="cursor-pointer flex items-center text-primary-600 hover:text-primary-700 dark:text-primary-400 dark:hover:text-primary-300 tooltip">
|
| 144 |
-
<i class="fa-solid fa-paperclip"></i>
|
| 145 |
-
<span class="ml-1.5 hidden sm:inline">Fichier</span>
|
| 146 |
-
<!-- CHANGED: Ajout des types de fichiers audio dans `accept` -->
|
| 147 |
-
<input type="file" id="file_upload" name="file" class="hidden" accept=".txt,.pdf,.png,.jpg,.jpeg,.mp3,.wav,.aac,.ogg,.flac">
|
| 148 |
-
<!-- CHANGED: Mise à jour du tooltip -->
|
| 149 |
-
<span class="tooltip-text">Joindre (texte, pdf, image, audio)</span>
|
| 150 |
-
</label>
|
| 151 |
-
<div id="file-chip" class="chip hidden">
|
| 152 |
-
<i class="fa-solid fa-file chip-icon"></i><span id="file-name" class="truncate max-w-[100px] sm:max-w-[120px]"></span><i id="clear-file" class="fa-solid fa-xmark ml-1 cursor-pointer opacity-70 hover:opacity-100"></i>
|
| 153 |
-
</div>
|
| 154 |
-
</div>
|
| 155 |
-
</div>
|
| 156 |
-
<!-- Formulaire de chat -->
|
| 157 |
-
<form id="chat-form" class="p-3 sm:p-4 bg-white dark:bg-gray-900">
|
| 158 |
-
<div class="input-wrapper">
|
| 159 |
-
<textarea id="prompt" name="prompt" class="chat-input chat-textarea w-full border focus:outline-none text-sm sm:text-base"
|
| 160 |
-
<!-- CHANGED: Mise à jour du placeholder -->
|
| 161 |
-
placeholder="Posez une question, collez une URL, ou joignez un fichier..."
|
| 162 |
-
autocomplete="off" rows="1"></textarea>
|
| 163 |
-
<div class="send-button-wrapper">
|
| 164 |
-
<button type="submit" id="send-button" class="bg-primary-500 hover:bg-primary-600 disabled:bg-primary-300 text-white rounded-full w-9 h-9 transition focus:outline-none focus:ring-2 focus:ring-primary-400 flex items-center justify-center" title="Envoyer le message">
|
| 165 |
-
<i class="fa-solid fa-paper-plane text-sm"></i>
|
| 166 |
-
</button>
|
| 167 |
-
</div>
|
| 168 |
</div>
|
| 169 |
-
|
| 170 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 171 |
</div>
|
| 172 |
-
</form>
|
| 173 |
</div>
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 277 |
</body>
|
| 278 |
</html>
|
|
|
|
| 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>Chatbot Gemini Avancé</title>
|
| 7 |
+
<style>
|
| 8 |
+
* {
|
| 9 |
+
margin: 0;
|
| 10 |
+
padding: 0;
|
| 11 |
+
box-sizing: border-box;
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
body {
|
| 15 |
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
| 16 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 17 |
+
height: 100vh;
|
| 18 |
+
overflow: hidden;
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
.container {
|
| 22 |
+
display: flex;
|
| 23 |
+
height: 100vh;
|
| 24 |
+
max-width: 1400px;
|
| 25 |
+
margin: 0 auto;
|
| 26 |
+
background: rgba(255, 255, 255, 0.95);
|
| 27 |
+
box-shadow: 0 8px 32px rgba(31, 38, 135, 0.37);
|
| 28 |
+
backdrop-filter: blur(8px);
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
.sidebar {
|
| 32 |
+
width: 300px;
|
| 33 |
+
background: rgba(255, 255, 255, 0.1);
|
| 34 |
+
border-right: 1px solid rgba(255, 255, 255, 0.2);
|
| 35 |
+
padding: 20px;
|
| 36 |
+
overflow-y: auto;
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
.sidebar h2 {
|
| 40 |
+
color: #333;
|
| 41 |
+
margin-bottom: 20px;
|
| 42 |
+
font-size: 1.3em;
|
| 43 |
+
text-align: center;
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
.control-group {
|
| 47 |
+
margin-bottom: 20px;
|
| 48 |
+
padding: 15px;
|
| 49 |
+
background: rgba(255, 255, 255, 0.8);
|
| 50 |
+
border-radius: 10px;
|
| 51 |
+
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
.control-group h3 {
|
| 55 |
+
color: #444;
|
| 56 |
+
margin-bottom: 10px;
|
| 57 |
+
font-size: 1em;
|
| 58 |
+
border-bottom: 2px solid #667eea;
|
| 59 |
+
padding-bottom: 5px;
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
.form-group {
|
| 63 |
+
margin-bottom: 15px;
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
label {
|
| 67 |
+
display: block;
|
| 68 |
+
margin-bottom: 5px;
|
| 69 |
+
font-weight: 500;
|
| 70 |
+
color: #555;
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
select, input[type="file"] {
|
| 74 |
+
width: 100%;
|
| 75 |
+
padding: 8px;
|
| 76 |
+
border: 2px solid #ddd;
|
| 77 |
+
border-radius: 5px;
|
| 78 |
+
font-size: 14px;
|
| 79 |
+
transition: border-color 0.3s;
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
select:focus, input[type="file"]:focus {
|
| 83 |
+
border-color: #667eea;
|
| 84 |
+
outline: none;
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
.checkbox-group {
|
| 88 |
+
display: flex;
|
| 89 |
+
align-items: center;
|
| 90 |
+
margin-bottom: 10px;
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
.checkbox-group input[type="checkbox"] {
|
| 94 |
+
margin-right: 8px;
|
| 95 |
+
transform: scale(1.2);
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
.checkbox-group label {
|
| 99 |
+
margin-bottom: 0;
|
| 100 |
+
cursor: pointer;
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
.btn {
|
| 104 |
+
background: linear-gradient(45deg, #667eea, #764ba2);
|
| 105 |
+
color: white;
|
| 106 |
+
border: none;
|
| 107 |
+
padding: 10px 15px;
|
| 108 |
+
border-radius: 5px;
|
| 109 |
+
cursor: pointer;
|
| 110 |
+
font-size: 14px;
|
| 111 |
+
transition: transform 0.2s, box-shadow 0.2s;
|
| 112 |
+
width: 100%;
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
.btn:hover {
|
| 116 |
+
transform: translateY(-2px);
|
| 117 |
+
box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
.btn-danger {
|
| 121 |
+
background: linear-gradient(45deg, #ff6b6b, #ee5a52);
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
.btn-danger:hover {
|
| 125 |
+
box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
.main-content {
|
| 129 |
+
flex: 1;
|
| 130 |
+
display: flex;
|
| 131 |
+
flex-direction: column;
|
| 132 |
+
height: 100vh;
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
.chat-header {
|
| 136 |
+
background: rgba(255, 255, 255, 0.9);
|
| 137 |
+
padding: 20px;
|
| 138 |
+
border-bottom: 1px solid rgba(255, 255, 255, 0.2);
|
| 139 |
+
text-align: center;
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
.chat-header h1 {
|
| 143 |
+
color: #333;
|
| 144 |
+
font-size: 1.5em;
|
| 145 |
+
margin-bottom: 5px;
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
.chat-status {
|
| 149 |
+
color: #666;
|
| 150 |
+
font-size: 0.9em;
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
.chat-container {
|
| 154 |
+
flex: 1;
|
| 155 |
+
overflow-y: auto;
|
| 156 |
+
padding: 20px;
|
| 157 |
+
background: rgba(255, 255, 255, 0.05);
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
+
.message {
|
| 161 |
+
margin-bottom: 20px;
|
| 162 |
+
display: flex;
|
| 163 |
+
animation: slideIn 0.3s ease-out;
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
@keyframes slideIn {
|
| 167 |
+
from {
|
| 168 |
+
opacity: 0;
|
| 169 |
+
transform: translateY(20px);
|
| 170 |
+
}
|
| 171 |
+
to {
|
| 172 |
+
opacity: 1;
|
| 173 |
+
transform: translateY(0);
|
| 174 |
+
}
|
| 175 |
+
}
|
| 176 |
+
|
| 177 |
+
.message.user {
|
| 178 |
+
justify-content: flex-end;
|
| 179 |
+
}
|
| 180 |
+
|
| 181 |
+
.message-content {
|
| 182 |
+
max-width: 70%;
|
| 183 |
+
padding: 15px 20px;
|
| 184 |
+
border-radius: 18px;
|
| 185 |
+
position: relative;
|
| 186 |
+
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
| 187 |
+
}
|
| 188 |
+
|
| 189 |
+
.message.user .message-content {
|
| 190 |
+
background: linear-gradient(135deg, #667eea, #764ba2);
|
| 191 |
+
color: white;
|
| 192 |
+
border-bottom-right-radius: 5px;
|
| 193 |
+
}
|
| 194 |
+
|
| 195 |
+
.message.assistant .message-content {
|
| 196 |
+
background: rgba(255, 255, 255, 0.9);
|
| 197 |
+
color: #333;
|
| 198 |
+
border-bottom-left-radius: 5px;
|
| 199 |
+
border: 1px solid rgba(255, 255, 255, 0.2);
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
.message-time {
|
| 203 |
+
font-size: 0.8em;
|
| 204 |
+
opacity: 0.7;
|
| 205 |
+
margin-top: 5px;
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
.thinking-section {
|
| 209 |
+
background: rgba(255, 235, 59, 0.1);
|
| 210 |
+
border: 1px solid rgba(255, 235, 59, 0.3);
|
| 211 |
+
border-radius: 10px;
|
| 212 |
+
padding: 10px;
|
| 213 |
+
margin-bottom: 10px;
|
| 214 |
+
font-style: italic;
|
| 215 |
+
color: #666;
|
| 216 |
+
}
|
| 217 |
+
|
| 218 |
+
.thinking-section::before {
|
| 219 |
+
content: "🤔 Réflexion du modèle:";
|
| 220 |
+
font-weight: bold;
|
| 221 |
+
color: #f57f17;
|
| 222 |
+
display: block;
|
| 223 |
+
margin-bottom: 5px;
|
| 224 |
+
}
|
| 225 |
+
|
| 226 |
+
.input-container {
|
| 227 |
+
padding: 20px;
|
| 228 |
+
background: rgba(255, 255, 255, 0.9);
|
| 229 |
+
border-top: 1px solid rgba(255, 255, 255, 0.2);
|
| 230 |
+
}
|
| 231 |
+
|
| 232 |
+
.input-row {
|
| 233 |
+
display: flex;
|
| 234 |
+
gap: 10px;
|
| 235 |
+
align-items: flex-end;
|
| 236 |
+
}
|
| 237 |
+
|
| 238 |
+
.message-input {
|
| 239 |
+
flex: 1;
|
| 240 |
+
padding: 12px 15px;
|
| 241 |
+
border: 2px solid #ddd;
|
| 242 |
+
border-radius: 25px;
|
| 243 |
+
font-size: 16px;
|
| 244 |
+
resize: none;
|
| 245 |
+
min-height: 50px;
|
| 246 |
+
max-height: 120px;
|
| 247 |
+
transition: border-color 0.3s;
|
| 248 |
+
}
|
| 249 |
+
|
| 250 |
+
.message-input:focus {
|
| 251 |
+
border-color: #667eea;
|
| 252 |
+
outline: none;
|
| 253 |
+
}
|
| 254 |
+
|
| 255 |
+
.send-btn {
|
| 256 |
+
background: linear-gradient(45deg, #667eea, #764ba2);
|
| 257 |
+
color: white;
|
| 258 |
+
border: none;
|
| 259 |
+
border-radius: 50%;
|
| 260 |
+
width: 50px;
|
| 261 |
+
height: 50px;
|
| 262 |
+
cursor: pointer;
|
| 263 |
+
display: flex;
|
| 264 |
+
align-items: center;
|
| 265 |
+
justify-content: center;
|
| 266 |
+
transition: transform 0.2s, box-shadow 0.2s;
|
| 267 |
+
}
|
| 268 |
+
|
| 269 |
+
.send-btn:hover:not(:disabled) {
|
| 270 |
+
transform: scale(1.1);
|
| 271 |
+
box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
|
| 272 |
+
}
|
| 273 |
+
|
| 274 |
+
.send-btn:disabled {
|
| 275 |
+
background: #ccc;
|
| 276 |
+
cursor: not-allowed;
|
| 277 |
+
}
|
| 278 |
+
|
| 279 |
+
.file-upload-area {
|
| 280 |
+
margin-bottom: 10px;
|
| 281 |
+
padding: 10px;
|
| 282 |
+
border: 2px dashed #ddd;
|
| 283 |
+
border-radius: 10px;
|
| 284 |
+
text-align: center;
|
| 285 |
+
transition: border-color 0.3s;
|
| 286 |
+
}
|
| 287 |
+
|
| 288 |
+
.file-upload-area.dragover {
|
| 289 |
+
border-color: #667eea;
|
| 290 |
+
background: rgba(102, 126, 234, 0.1);
|
| 291 |
+
}
|
| 292 |
+
|
| 293 |
+
.uploaded-file {
|
| 294 |
+
background: rgba(102, 126, 234, 0.1);
|
| 295 |
+
border: 1px solid #667eea;
|
| 296 |
+
border-radius: 5px;
|
| 297 |
+
padding: 5px 10px;
|
| 298 |
+
margin: 5px 0;
|
| 299 |
+
display: flex;
|
| 300 |
+
justify-content: space-between;
|
| 301 |
+
align-items: center;
|
| 302 |
+
}
|
| 303 |
+
|
| 304 |
+
.remove-file {
|
| 305 |
+
background: #ff6b6b;
|
| 306 |
+
color: white;
|
| 307 |
+
border: none;
|
| 308 |
+
border-radius: 50%;
|
| 309 |
+
width: 20px;
|
| 310 |
+
height: 20px;
|
| 311 |
+
cursor: pointer;
|
| 312 |
+
font-size: 12px;
|
| 313 |
+
}
|
| 314 |
+
|
| 315 |
+
.typing-indicator {
|
| 316 |
+
display: none;
|
| 317 |
+
padding: 10px 20px;
|
| 318 |
+
background: rgba(255, 255, 255, 0.9);
|
| 319 |
+
border-radius: 18px;
|
| 320 |
+
margin-bottom: 20px;
|
| 321 |
+
width: fit-content;
|
| 322 |
+
}
|
| 323 |
+
|
| 324 |
+
.typing-indicator.show {
|
| 325 |
+
display: block;
|
| 326 |
+
animation: slideIn 0.3s ease-out;
|
| 327 |
+
}
|
| 328 |
+
|
| 329 |
+
.typing-dots {
|
| 330 |
+
display: flex;
|
| 331 |
+
gap: 4px;
|
| 332 |
+
}
|
| 333 |
+
|
| 334 |
+
.typing-dots span {
|
| 335 |
+
width: 8px;
|
| 336 |
+
height: 8px;
|
| 337 |
+
background: #667eea;
|
| 338 |
+
border-radius: 50%;
|
| 339 |
+
animation: typing 1.4s infinite;
|
| 340 |
+
}
|
| 341 |
+
|
| 342 |
+
.typing-dots span:nth-child(2) {
|
| 343 |
+
animation-delay: 0.2s;
|
| 344 |
+
}
|
| 345 |
+
|
| 346 |
+
.typing-dots span:nth-child(3) {
|
| 347 |
+
animation-delay: 0.4s;
|
| 348 |
+
}
|
| 349 |
+
|
| 350 |
+
@keyframes typing {
|
| 351 |
+
0%, 60%, 100% {
|
| 352 |
+
transform: translateY(0);
|
| 353 |
+
opacity: 0.4;
|
| 354 |
+
}
|
| 355 |
+
30% {
|
| 356 |
+
transform: translateY(-10px);
|
| 357 |
+
opacity: 1;
|
| 358 |
+
}
|
| 359 |
+
}
|
| 360 |
+
|
| 361 |
+
.error-message {
|
| 362 |
+
background: #ffebee;
|
| 363 |
+
color: #c62828;
|
| 364 |
+
border: 1px solid #ffcdd2;
|
| 365 |
+
border-radius: 5px;
|
| 366 |
+
padding: 10px;
|
| 367 |
+
margin: 10px 0;
|
| 368 |
+
}
|
| 369 |
+
|
| 370 |
+
/* Responsive Design */
|
| 371 |
+
@media (max-width: 768px) {
|
| 372 |
+
.container {
|
| 373 |
+
flex-direction: column;
|
| 374 |
+
}
|
| 375 |
+
|
| 376 |
+
.sidebar {
|
| 377 |
+
width: 100%;
|
| 378 |
+
height: auto;
|
| 379 |
+
max-height: 40vh;
|
| 380 |
+
order: 2;
|
| 381 |
+
}
|
| 382 |
+
|
| 383 |
+
.main-content {
|
| 384 |
+
order: 1;
|
| 385 |
+
height: 60vh;
|
| 386 |
+
}
|
| 387 |
+
|
| 388 |
+
.message-content {
|
| 389 |
+
max-width: 85%;
|
| 390 |
+
}
|
| 391 |
+
}
|
| 392 |
+
|
| 393 |
+
/* Code styling */
|
| 394 |
+
pre {
|
| 395 |
+
background: #f5f5f5;
|
| 396 |
+
border-radius: 5px;
|
| 397 |
+
padding: 10px;
|
| 398 |
+
overflow-x: auto;
|
| 399 |
+
margin: 10px 0;
|
| 400 |
+
}
|
| 401 |
+
|
| 402 |
+
code {
|
| 403 |
+
background: #f5f5f5;
|
| 404 |
+
padding: 2px 4px;
|
| 405 |
+
border-radius: 3px;
|
| 406 |
+
font-family: 'Courier New', monospace;
|
| 407 |
+
}
|
| 408 |
+
</style>
|
| 409 |
</head>
|
| 410 |
+
<body>
|
| 411 |
+
<div class="container">
|
| 412 |
+
<!-- Sidebar -->
|
| 413 |
+
<div class="sidebar">
|
| 414 |
+
<h2>🤖 Configuration</h2>
|
| 415 |
+
|
| 416 |
+
<!-- Modèle -->
|
| 417 |
+
<div class="control-group">
|
| 418 |
+
<h3>Modèle</h3>
|
| 419 |
+
<div class="form-group">
|
| 420 |
+
<label for="model-select">Modèle Gemini:</label>
|
| 421 |
+
<select id="model-select">
|
| 422 |
+
{% for name, value in models.items() %}
|
| 423 |
+
<option value="{{ value }}" {% if name == "Gemini 2.5 Flash" %}selected{% endif %}>{{ name }}</option>
|
| 424 |
+
{% endfor %}
|
| 425 |
+
</select>
|
| 426 |
+
</div>
|
| 427 |
+
</div>
|
| 428 |
+
|
| 429 |
+
<!-- Thinking Options -->
|
| 430 |
+
<div class="control-group">
|
| 431 |
+
<h3>🧠 Options de Réflexion</h3>
|
| 432 |
+
<div class="checkbox-group">
|
| 433 |
+
<input type="checkbox" id="thinking-enabled" checked>
|
| 434 |
+
<label for="thinking-enabled">Activer le raisonnement</label>
|
| 435 |
+
</div>
|
| 436 |
+
<div class="checkbox-group">
|
| 437 |
+
<input type="checkbox" id="include-thoughts">
|
| 438 |
+
<label for="include-thoughts">Afficher les pensées</label>
|
| 439 |
+
</div>
|
| 440 |
+
<p style="font-size: 0.8em; color: #666; margin-top: 5px;">
|
| 441 |
+
🔧 Tous les outils avancés sont actifs par défaut:<br>
|
| 442 |
+
• Exécution de code<br>
|
| 443 |
+
• Recherche Google<br>
|
| 444 |
+
• Contexte URL
|
| 445 |
+
</p>
|
| 446 |
+
</div>
|
| 447 |
+
|
| 448 |
+
<!-- File Upload -->
|
| 449 |
+
<div class="control-group">
|
| 450 |
+
<h3>📁 Upload de fichier</h3>
|
| 451 |
+
<div class="file-upload-area" id="file-upload-area">
|
| 452 |
+
<p>Glissez un fichier ici ou cliquez pour sélectionner</p>
|
| 453 |
+
<input type="file" id="file-input" style="display: none;" accept=".png,.jpg,.jpeg,.pdf,.mp4,.mov,.txt,.csv,.json">
|
| 454 |
+
</div>
|
| 455 |
+
<div id="uploaded-files"></div>
|
| 456 |
+
</div>
|
| 457 |
+
|
| 458 |
+
<!-- Actions -->
|
| 459 |
+
<div class="control-group">
|
| 460 |
+
<h3>Actions</h3>
|
| 461 |
+
<button class="btn btn-danger" onclick="resetChat()">🗑️ Réinitialiser</button>
|
| 462 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 463 |
</div>
|
| 464 |
+
|
| 465 |
+
<!-- Main Content -->
|
| 466 |
+
<div class="main-content">
|
| 467 |
+
<!-- Header -->
|
| 468 |
+
<div class="chat-header">
|
| 469 |
+
<h1>💬 Chatbot Gemini Avancé</h1>
|
| 470 |
+
<div class="chat-status" id="chat-status">Prêt à discuter</div>
|
| 471 |
+
</div>
|
| 472 |
+
|
| 473 |
+
<!-- Chat Container -->
|
| 474 |
+
<div class="chat-container" id="chat-container">
|
| 475 |
+
<div class="message assistant">
|
| 476 |
+
<div class="message-content">
|
| 477 |
+
<div>👋 Bonjour ! Je suis votre assistant Gemini avec toutes les fonctionnalités avancées activées :</div>
|
| 478 |
+
<div style="margin-top: 10px;">
|
| 479 |
+
✅ <strong>Exécution de code Python</strong><br>
|
| 480 |
+
✅ <strong>Recherche Google en temps réel</strong><br>
|
| 481 |
+
✅ <strong>Analyse d'URLs</strong><br>
|
| 482 |
+
✅ <strong>Traitement de fichiers (images, PDF, vidéos, textes)</strong><br>
|
| 483 |
+
✅ <strong>Raisonnement avancé avec Thinking</strong>
|
| 484 |
+
</div>
|
| 485 |
+
<div style="margin-top: 10px; font-style: italic;">
|
| 486 |
+
Comment puis-je vous aider aujourd'hui ?
|
| 487 |
+
</div>
|
| 488 |
+
<div class="message-time">Just now</div>
|
| 489 |
+
</div>
|
| 490 |
+
</div>
|
| 491 |
+
</div>
|
| 492 |
+
|
| 493 |
+
<!-- Typing Indicator -->
|
| 494 |
+
<div class="typing-indicator" id="typing-indicator">
|
| 495 |
+
<div class="typing-dots">
|
| 496 |
+
<span></span>
|
| 497 |
+
<span></span>
|
| 498 |
+
<span></span>
|
| 499 |
+
</div>
|
| 500 |
+
</div>
|
| 501 |
+
|
| 502 |
+
<!-- Input Area -->
|
| 503 |
+
<div class="input-container">
|
| 504 |
+
<div class="input-row">
|
| 505 |
+
<textarea
|
| 506 |
+
id="message-input"
|
| 507 |
+
class="message-input"
|
| 508 |
+
placeholder="Tapez votre message... (Shift+Entrée pour nouvelle ligne)"
|
| 509 |
+
rows="1"></textarea>
|
| 510 |
+
<button id="send-btn" class="send-btn">
|
| 511 |
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor">
|
| 512 |
+
<path d="M2.01 21L23 12 2.01 3 2 10l15 2-15 2z"/>
|
| 513 |
+
</svg>
|
| 514 |
+
</button>
|
| 515 |
+
</div>
|
| 516 |
+
</div>
|
| 517 |
</div>
|
|
|
|
| 518 |
</div>
|
| 519 |
+
|
| 520 |
+
<script>
|
| 521 |
+
// Variables globales
|
| 522 |
+
let currentFile = null;
|
| 523 |
+
let isWaitingResponse = false;
|
| 524 |
+
|
| 525 |
+
// Éléments DOM
|
| 526 |
+
const chatContainer = document.getElementById('chat-container');
|
| 527 |
+
const messageInput = document.getElementById('message-input');
|
| 528 |
+
const sendBtn = document.getElementById('send-btn');
|
| 529 |
+
const typingIndicator = document.getElementById('typing-indicator');
|
| 530 |
+
const fileInput = document.getElementById('file-input');
|
| 531 |
+
const fileUploadArea = document.getElementById('file-upload-area');
|
| 532 |
+
const uploadedFilesDiv = document.getElementById('uploaded-files');
|
| 533 |
+
const chatStatus = document.getElementById('chat-status');
|
| 534 |
+
|
| 535 |
+
// Configuration du drag & drop
|
| 536 |
+
fileUploadArea.addEventListener('click', () => fileInput.click());
|
| 537 |
+
fileUploadArea.addEventListener('dragover', (e) => {
|
| 538 |
+
e.preventDefault();
|
| 539 |
+
fileUploadArea.classList.add('dragover');
|
| 540 |
+
});
|
| 541 |
+
fileUploadArea.addEventListener('dragleave', () => {
|
| 542 |
+
fileUploadArea.classList.remove('dragover');
|
| 543 |
+
});
|
| 544 |
+
fileUploadArea.addEventListener('drop', (e) => {
|
| 545 |
+
e.preventDefault();
|
| 546 |
+
fileUploadArea.classList.remove('dragover');
|
| 547 |
+
const files = e.dataTransfer.files;
|
| 548 |
+
if (files.length > 0) {
|
| 549 |
+
handleFileUpload(files[0]);
|
| 550 |
+
}
|
| 551 |
+
});
|
| 552 |
+
|
| 553 |
+
// Configuration de l'input file
|
| 554 |
+
fileInput.addEventListener('change', (e) => {
|
| 555 |
+
if (e.target.files.length > 0) {
|
| 556 |
+
handleFileUpload(e.target.files[0]);
|
| 557 |
+
}
|
| 558 |
+
});
|
| 559 |
+
|
| 560 |
+
// Auto-resize textarea
|
| 561 |
+
messageInput.addEventListener('input', function() {
|
| 562 |
+
this.style.height = 'auto';
|
| 563 |
+
this.style.height = Math.min(this.scrollHeight, 120) + 'px';
|
| 564 |
+
});
|
| 565 |
+
|
| 566 |
+
// Gestion des touches
|
| 567 |
+
messageInput.addEventListener('keydown', (e) => {
|
| 568 |
+
if (e.key === 'Enter' && !e.shiftKey) {
|
| 569 |
+
e.preventDefault();
|
| 570 |
+
sendMessage();
|
| 571 |
+
}
|
| 572 |
+
});
|
| 573 |
+
|
| 574 |
+
// Bouton d'envoi
|
| 575 |
+
sendBtn.addEventListener('click', sendMessage);
|
| 576 |
+
|
| 577 |
+
// Fonctions utilitaires
|
| 578 |
+
function formatTime() {
|
| 579 |
+
return new Date().toLocaleTimeString('fr-FR', {
|
| 580 |
+
hour: '2-digit',
|
| 581 |
+
minute: '2-digit'
|
| 582 |
+
});
|
| 583 |
+
}
|
| 584 |
+
|
| 585 |
+
function scrollToBottom() {
|
| 586 |
+
chatContainer.scrollTop = chatContainer.scrollHeight;
|
| 587 |
+
}
|
| 588 |
+
|
| 589 |
+
function showTyping() {
|
| 590 |
+
typingIndicator.classList.add('show');
|
| 591 |
+
scrollToBottom();
|
| 592 |
+
}
|
| 593 |
+
|
| 594 |
+
function hideTyping() {
|
| 595 |
+
typingIndicator.classList.remove('show');
|
| 596 |
+
}
|
| 597 |
+
|
| 598 |
+
function updateChatStatus(status) {
|
| 599 |
+
chatStatus.textContent = status;
|
| 600 |
+
}
|
| 601 |
+
|
| 602 |
+
// Gestion de l'upload de fichiers
|
| 603 |
+
async function handleFileUpload(file) {
|
| 604 |
+
const formData = new FormData();
|
| 605 |
+
formData.append('file', file);
|
| 606 |
+
|
| 607 |
+
try {
|
| 608 |
+
updateChatStatus('Upload du fichier...');
|
| 609 |
+
const response = await fetch('/upload_file', {
|
| 610 |
+
method: 'POST',
|
| 611 |
+
body: formData
|
| 612 |
+
});
|
| 613 |
+
|
| 614 |
+
const result = await response.json();
|
| 615 |
+
|
| 616 |
+
if (result.success) {
|
| 617 |
+
currentFile = {
|
| 618 |
+
id: result.file_id,
|
| 619 |
+
name: result.filename,
|
| 620 |
+
type: result.mime_type
|
| 621 |
+
};
|
| 622 |
+
|
| 623 |
+
displayUploadedFile(result.filename, result.mime_type);
|
| 624 |
+
updateChatStatus('Fichier uploadé avec succès');
|
| 625 |
+
} else {
|
| 626 |
+
showError('Erreur lors de l\'upload: ' + result.error);
|
| 627 |
+
updateChatStatus('Erreur d\'upload');
|
| 628 |
+
}
|
| 629 |
+
} catch (error) {
|
| 630 |
+
console.error('Erreur upload:', error);
|
| 631 |
+
showError('Erreur lors de l\'upload du fichier');
|
| 632 |
+
updateChatStatus('Erreur d\'upload');
|
| 633 |
+
}
|
| 634 |
+
}
|
| 635 |
+
|
| 636 |
+
function displayUploadedFile(filename, mimeType) {
|
| 637 |
+
const fileIcon = getFileIcon(mimeType);
|
| 638 |
+
uploadedFilesDiv.innerHTML = `
|
| 639 |
+
<div class="uploaded-file">
|
| 640 |
+
<span>${fileIcon} ${filename}</span>
|
| 641 |
+
<button class="remove-file" onclick="removeFile()">×</button>
|
| 642 |
</div>
|
| 643 |
+
`;
|
| 644 |
+
}
|
| 645 |
+
|
| 646 |
+
function getFileIcon(mimeType) {
|
| 647 |
+
if (mimeType.startsWith('image/')) return '🖼️';
|
| 648 |
+
if (mimeType === 'application/pdf') return '📄';
|
| 649 |
+
if (mimeType.startsWith('video/')) return '🎥';
|
| 650 |
+
if (mimeType.includes('text')) return '📝';
|
| 651 |
+
return '📎';
|
| 652 |
+
}
|
| 653 |
+
|
| 654 |
+
function removeFile() {
|
| 655 |
+
currentFile = null;
|
| 656 |
+
uploadedFilesDiv.innerHTML = '';
|
| 657 |
+
fileInput.value = '';
|
| 658 |
+
updateChatStatus('Fichier retiré');
|
| 659 |
+
}
|
| 660 |
+
|
| 661 |
+
// Gestion des messages
|
| 662 |
+
function addMessage(content, isUser, hasThoughts = false, thoughtsContent = '') {
|
| 663 |
+
const messageDiv = document.createElement('div');
|
| 664 |
+
messageDiv.className = `message ${isUser ? 'user' : 'assistant'}`;
|
| 665 |
+
|
| 666 |
+
let messageHTML = `
|
| 667 |
+
<div class="message-content">
|
| 668 |
+
${hasThoughts ? `<div class="thinking-section">${thoughtsContent}</div>` : ''}
|
| 669 |
+
<div>${formatMessage(content)}</div>
|
| 670 |
+
<div class="message-time">${formatTime()}</div>
|
| 671 |
+
</div>
|
| 672 |
+
`;
|
| 673 |
+
|
| 674 |
+
messageDiv.innerHTML = messageHTML;
|
| 675 |
+
chatContainer.appendChild(messageDiv);
|
| 676 |
+
scrollToBottom();
|
| 677 |
+
return messageDiv;
|
| 678 |
+
}
|
| 679 |
+
|
| 680 |
+
function formatMessage(content) {
|
| 681 |
+
// Conversion basique markdown vers HTML
|
| 682 |
+
return content
|
| 683 |
+
.replace(/\*\*(.*?)\*\*/g, '<strong>$1</strong>')
|
| 684 |
+
.replace(/\*(.*?)\*/g, '<em>$1</em>')
|
| 685 |
+
.replace(/`([^`]+)`/g, '<code>$1</code>')
|
| 686 |
+
.replace(/```([^```]+)```/g, '<pre><code>$1</code></pre>')
|
| 687 |
+
.replace(/\n/g, '<br>');
|
| 688 |
+
}
|
| 689 |
+
|
| 690 |
+
function showError(message) {
|
| 691 |
+
const errorDiv = document.createElement('div');
|
| 692 |
+
errorDiv.className = 'error-message';
|
| 693 |
+
errorDiv.textContent = message;
|
| 694 |
+
chatContainer.appendChild(errorDiv);
|
| 695 |
+
scrollToBottom();
|
| 696 |
+
|
| 697 |
+
setTimeout(() => {
|
| 698 |
+
errorDiv.remove();
|
| 699 |
+
}, 5000);
|
| 700 |
+
}
|
| 701 |
+
|
| 702 |
+
// Envoi de messages
|
| 703 |
+
async function sendMessage() {
|
| 704 |
+
if (isWaitingResponse) return;
|
| 705 |
+
|
| 706 |
+
const message = messageInput.value.trim();
|
| 707 |
+
if (!message) return;
|
| 708 |
+
|
| 709 |
+
const model = document.getElementById('model-select').value;
|
| 710 |
+
const thinkingEnabled = document.getElementById('thinking-enabled').checked;
|
| 711 |
+
const includeThoughts = document.getElementById('include-thoughts').checked;
|
| 712 |
+
|
| 713 |
+
// Afficher le message de l'utilisateur
|
| 714 |
+
addMessage(message, true);
|
| 715 |
+
|
| 716 |
+
// Nettoyer l'input
|
| 717 |
+
messageInput.value = '';
|
| 718 |
+
messageInput.style.height = 'auto';
|
| 719 |
+
|
| 720 |
+
// Désactiver l'envoi
|
| 721 |
+
isWaitingResponse = true;
|
| 722 |
+
sendBtn.disabled = true;
|
| 723 |
+
showTyping();
|
| 724 |
+
updateChatStatus('Génération de la réponse...');
|
| 725 |
+
|
| 726 |
+
try {
|
| 727 |
+
const endpoint = currentFile ? '/send_message_with_file' : '/send_message';
|
| 728 |
+
const requestBody = {
|
| 729 |
+
message: message,
|
| 730 |
+
model: model,
|
| 731 |
+
thinking_enabled: thinkingEnabled,
|
| 732 |
+
include_thoughts: includeThoughts
|
| 733 |
+
};
|
| 734 |
+
|
| 735 |
+
if (currentFile) {
|
| 736 |
+
requestBody.file_id = currentFile.id;
|
| 737 |
+
}
|
| 738 |
+
|
| 739 |
+
const response = await fetch(endpoint, {
|
| 740 |
+
method: 'POST',
|
| 741 |
+
headers: {
|
| 742 |
+
'Content-Type': 'application/json',
|
| 743 |
+
},
|
| 744 |
+
body: JSON.stringify(requestBody)
|
| 745 |
+
});
|
| 746 |
+
|
| 747 |
+
if (!response.ok) {
|
| 748 |
+
throw new Error('Erreur de réseau');
|
| 749 |
+
}
|
| 750 |
+
|
| 751 |
+
const reader = response.body.getReader();
|
| 752 |
+
const decoder = new TextDecoder();
|
| 753 |
+
|
| 754 |
+
let assistantMessage = null;
|
| 755 |
+
let fullResponse = '';
|
| 756 |
+
let thoughtsContent = '';
|
| 757 |
+
|
| 758 |
+
hideTyping();
|
| 759 |
+
|
| 760 |
+
while (true) {
|
| 761 |
+
const { done, value } = await reader.read();
|
| 762 |
+
if (done) break;
|
| 763 |
+
|
| 764 |
+
const chunk = decoder.decode(value);
|
| 765 |
+
const lines = chunk.split('\n');
|
| 766 |
+
|
| 767 |
+
for (const line of lines) {
|
| 768 |
+
if (line.startsWith('data: ')) {
|
| 769 |
+
try {
|
| 770 |
+
const data = JSON.parse(line.slice(6));
|
| 771 |
+
|
| 772 |
+
if (data.error) {
|
| 773 |
+
showError(data.error);
|
| 774 |
+
break;
|
| 775 |
+
}
|
| 776 |
+
|
| 777 |
+
if (data.type === 'thought') {
|
| 778 |
+
thoughtsContent += data.content;
|
| 779 |
+
} else if (data.type === 'text') {
|
| 780 |
+
if (!assistantMessage) {
|
| 781 |
+
assistantMessage = addMessage('', false, includeThoughts, thoughtsContent);
|
| 782 |
+
}
|
| 783 |
+
|
| 784 |
+
fullResponse += data.content;
|
| 785 |
+
|
| 786 |
+
// Mettre à jour le contenu du message
|
| 787 |
+
const messageContent = assistantMessage.querySelector('.message-content > div:last-child');
|
| 788 |
+
if (messageContent) {
|
| 789 |
+
messageContent.innerHTML = formatMessage(fullResponse) + '<div class="message-time">' + formatTime() + '</div>';
|
| 790 |
+
}
|
| 791 |
+
|
| 792 |
+
scrollToBottom();
|
| 793 |
+
} else if (data.type === 'end') {
|
| 794 |
+
// Message terminé
|
| 795 |
+
updateChatStatus('Prêt à discuter');
|
| 796 |
+
}
|
| 797 |
+
} catch (e) {
|
| 798 |
+
console.error('Erreur parsing JSON:', e);
|
| 799 |
+
}
|
| 800 |
+
}
|
| 801 |
+
}
|
| 802 |
+
}
|
| 803 |
+
|
| 804 |
+
// Nettoyer le fichier après envoi
|
| 805 |
+
if (currentFile) {
|
| 806 |
+
removeFile();
|
| 807 |
+
}
|
| 808 |
+
|
| 809 |
+
} catch (error) {
|
| 810 |
+
console.error('Erreur:', error);
|
| 811 |
+
hideTyping();
|
| 812 |
+
showError('Erreur lors de l\'envoi du message: ' + error.message);
|
| 813 |
+
updateChatStatus('Erreur de communication');
|
| 814 |
+
} finally {
|
| 815 |
+
isWaitingResponse = false;
|
| 816 |
+
sendBtn.disabled = false;
|
| 817 |
+
}
|
| 818 |
+
}
|
| 819 |
+
|
| 820 |
+
// Reset du chat
|
| 821 |
+
async function resetChat() {
|
| 822 |
+
if (!confirm('Êtes-vous sûr de vouloir réinitialiser la conversation ?')) {
|
| 823 |
+
return;
|
| 824 |
+
}
|
| 825 |
+
|
| 826 |
+
try {
|
| 827 |
+
const response = await fetch('/reset_chat', {
|
| 828 |
+
method: 'POST',
|
| 829 |
+
headers: {
|
| 830 |
+
'Content-Type': 'application/json',
|
| 831 |
+
}
|
| 832 |
+
});
|
| 833 |
+
|
| 834 |
+
const result = await response.json();
|
| 835 |
+
|
| 836 |
+
if (result.success) {
|
| 837 |
+
// Nettoyer l'interface
|
| 838 |
+
chatContainer.innerHTML = `
|
| 839 |
+
<div class="message assistant">
|
| 840 |
+
<div class="message-content">
|
| 841 |
+
<div>👋 Nouvelle conversation démarrée ! Toutes les fonctionnalités avancées sont toujours actives.</div>
|
| 842 |
+
<div class="message-time">${formatTime()}</div>
|
| 843 |
+
</div>
|
| 844 |
+
</div>
|
| 845 |
+
`;
|
| 846 |
+
|
| 847 |
+
removeFile();
|
| 848 |
+
updateChatStatus('Conversation réinitialisée');
|
| 849 |
+
} else {
|
| 850 |
+
showError('Erreur lors de la réinitialisation');
|
| 851 |
+
}
|
| 852 |
+
} catch (error) {
|
| 853 |
+
console.error('Erreur reset:', error);
|
| 854 |
+
showError('Erreur lors de la réinitialisation');
|
| 855 |
+
}
|
| 856 |
+
}
|
| 857 |
+
|
| 858 |
+
// Initialisation
|
| 859 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 860 |
+
updateChatStatus('Prêt à discuter');
|
| 861 |
+
messageInput.focus();
|
| 862 |
+
});
|
| 863 |
+
|
| 864 |
+
// Gestion de la reconnexion
|
| 865 |
+
window.addEventListener('online', () => {
|
| 866 |
+
updateChatStatus('Reconnecté');
|
| 867 |
+
});
|
| 868 |
+
|
| 869 |
+
window.addEventListener('offline', () => {
|
| 870 |
+
updateChatStatus('Hors ligne');
|
| 871 |
+
});
|
| 872 |
+
</script>
|
| 873 |
</body>
|
| 874 |
</html>
|