File size: 17,444 Bytes
0313a03 | 1 2 3 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 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 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 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 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 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 | <!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Chatbot IA</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
.message-animation {
animation: fadeIn 0.3s ease-out forwards;
}
.typing-indicator span {
display: inline-block;
width: 8px;
height: 8px;
border-radius: 50%;
background-color: #4b5563;
margin: 0 2px;
}
.typing-indicator span:nth-child(1) {
animation: bounce 1s infinite;
}
.typing-indicator span:nth-child(2) {
animation: bounce 1s infinite 0.2s;
}
.typing-indicator span:nth-child(3) {
animation: bounce 1s infinite 0.4s;
}
@keyframes bounce {
0%, 100% { transform: translateY(0); }
50% { transform: translateY(-5px); }
}
.chat-container {
height: calc(100vh - 120px);
}
@media (max-width: 640px) {
.chat-container {
height: calc(100vh - 100px);
}
}
</style>
</head>
<body class="bg-gray-100 font-sans">
<div class="max-w-4xl mx-auto p-4">
<!-- Header -->
<header class="bg-gradient-to-r from-blue-600 to-indigo-700 text-white rounded-xl shadow-lg mb-6 p-6 flex items-center justify-between">
<div class="flex items-center space-x-4">
<div class="bg-white/20 p-3 rounded-full">
<i class="fas fa-robot text-2xl"></i>
</div>
<div>
<h1 class="text-2xl font-bold">Assistant IA</h1>
<p class="text-sm opacity-80">Basé sur OpenAI</p>
</div>
</div>
<div class="hidden md:flex items-center space-x-2 bg-white/10 px-4 py-2 rounded-full">
<span class="h-2 w-2 bg-green-400 rounded-full animate-pulse"></span>
<span class="text-sm">En ligne</span>
</div>
</header>
<!-- Chat container -->
<div class="bg-white rounded-xl shadow-lg overflow-hidden">
<!-- Chat messages -->
<div class="chat-container overflow-y-auto p-4 space-y-4" id="chat-messages">
<!-- Welcome message -->
<div class="flex items-start space-x-3 message-animation">
<div class="bg-blue-100 p-3 rounded-full">
<i class="fas fa-robot text-blue-600"></i>
</div>
<div class="bg-blue-50 rounded-xl p-4 max-w-[80%]">
<p class="text-gray-800">Bonjour ! Je suis votre assistant IA. Comment puis-je vous aider aujourd'hui ?</p>
<p class="text-xs text-gray-500 mt-2">Basé sur OpenAI</p>
</div>
</div>
</div>
<!-- Input area -->
<div class="border-t border-gray-200 p-4 bg-gray-50">
<div class="flex items-center space-x-2">
<div class="flex-1 relative">
<textarea
id="user-input"
rows="1"
placeholder="Tapez votre message ici..."
class="w-full border border-gray-300 rounded-xl py-3 px-4 pr-12 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent resize-none"
style="min-height: 50px; max-height: 150px;"
></textarea>
<button id="send-button" class="absolute right-3 bottom-3 text-blue-600 hover:text-blue-700">
<i class="fas fa-paper-plane text-xl"></i>
</button>
</div>
<button id="voice-button" class="bg-blue-600 text-white p-3 rounded-full hover:bg-blue-700 transition">
<i class="fas fa-microphone"></i>
</button>
</div>
<p class="text-xs text-gray-500 mt-2 text-center">L'IA peut faire des erreurs. Vérifiez les informations importantes.</p>
</div>
</div>
<!-- Features grid -->
<div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-4 mt-6">
<div class="bg-white p-4 rounded-xl shadow hover:shadow-md transition cursor-pointer">
<div class="bg-blue-100 w-10 h-10 rounded-full flex items-center justify-center mb-3">
<i class="fas fa-lightbulb text-blue-600"></i>
</div>
<h3 class="font-semibold">Idées créatives</h3>
<p class="text-sm text-gray-600 mt-1">Générez des idées innovantes pour vos projets</p>
</div>
<div class="bg-white p-4 rounded-xl shadow hover:shadow-md transition cursor-pointer">
<div class="bg-purple-100 w-10 h-10 rounded-full flex items-center justify-center mb-3">
<i class="fas fa-code text-purple-600"></i>
</div>
<h3 class="font-semibold">Aide au code</h3>
<p class="text-sm text-gray-600 mt-1">Obtenez de l'aide pour résoudre vos problèmes de programmation</p>
</div>
<div class="bg-white p-4 rounded-xl shadow hover:shadow-md transition cursor-pointer">
<div class="bg-green-100 w-10 h-10 rounded-full flex items-center justify-center mb-3">
<i class="fas fa-language text-green-600"></i>
</div>
<h3 class="font-semibold">Traduction</h3>
<p class="text-sm text-gray-600 mt-1">Traduisez du texte entre plusieurs langues</p>
</div>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
const chatMessages = document.getElementById('chat-messages');
const userInput = document.getElementById('user-input');
const sendButton = document.getElementById('send-button');
const voiceButton = document.getElementById('voice-button');
let isTyping = false;
let recognition;
// Auto-resize textarea
userInput.addEventListener('input', function() {
this.style.height = 'auto';
this.style.height = (this.scrollHeight) + 'px';
});
// Send message on Enter (but allow Shift+Enter for new line)
userInput.addEventListener('keydown', function(e) {
if (e.key === 'Enter' && !e.shiftKey) {
e.preventDefault();
sendMessage();
}
});
// Send message on button click
sendButton.addEventListener('click', sendMessage);
// Voice recognition setup
voiceButton.addEventListener('click', toggleVoiceRecognition);
function toggleVoiceRecognition() {
if (!recognition) {
recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();
recognition.lang = 'fr-FR';
recognition.interimResults = false;
recognition.onstart = function() {
voiceButton.innerHTML = '<i class="fas fa-microphone-slash"></i>';
voiceButton.classList.remove('bg-blue-600');
voiceButton.classList.add('bg-red-500');
addBotMessage("Je vous écoute...", true);
};
recognition.onresult = function(event) {
const transcript = event.results[0][0].transcript;
userInput.value = transcript;
recognition.stop();
};
recognition.onend = function() {
voiceButton.innerHTML = '<i class="fas fa-microphone"></i>';
voiceButton.classList.remove('bg-red-500');
voiceButton.classList.add('bg-blue-600');
// Remove the listening message
const messages = document.querySelectorAll('.message-animation');
if (messages.length > 0) {
const lastMessage = messages[messages.length - 1];
if (lastMessage.querySelector('p').textContent === "Je vous écoute...") {
lastMessage.remove();
}
}
if (userInput.value.trim() !== '') {
sendMessage();
}
};
recognition.onerror = function(event) {
console.error('Erreur de reconnaissance vocale:', event.error);
recognition.stop();
};
}
if (voiceButton.classList.contains('bg-blue-600')) {
recognition.start();
} else {
recognition.stop();
}
}
function sendMessage() {
const message = userInput.value.trim();
if (message === '' || isTyping) return;
// Add user message to chat
addUserMessage(message);
userInput.value = '';
userInput.style.height = 'auto';
// Show typing indicator
showTypingIndicator();
// Simulate API call to OpenAI (in a real app, you'd call your backend)
setTimeout(() => {
// Remove typing indicator
hideTypingIndicator();
// Simulate different response types
const responseType = Math.floor(Math.random() * 3);
let response;
if (responseType === 0) {
response = `Voici une réponse à votre message: "${message}". L'IA peut vous aider avec une variété de tâches, y compris la rédaction, la programmation, la génération d'idées et plus encore.`;
} else if (responseType === 1) {
response = `J'ai analysé votre demande concernant "${message}". Voici quelques suggestions que vous pourriez trouver utiles: 1) Première suggestion, 2) Deuxième option, 3) Alternative supplémentaire.`;
} else {
response = `Merci pour votre message! "${message}" est un sujet intéressant. Voici ce que je peux vous dire à ce sujet: L'IA transforme de nombreux aspects de notre vie quotidienne et professionnelle.`;
}
// Add bot response
addBotMessage(response);
}, 1500 + Math.random() * 2000); // Random delay between 1.5-3.5 seconds
}
function addUserMessage(message) {
const messageElement = document.createElement('div');
messageElement.className = 'flex items-start justify-end space-x-3 message-animation';
messageElement.innerHTML = `
<div class="bg-blue-600 text-white rounded-xl p-4 max-w-[80%]">
<p>${message}</p>
</div>
<div class="bg-gray-200 p-3 rounded-full">
<i class="fas fa-user text-gray-600"></i>
</div>
`;
chatMessages.appendChild(messageElement);
scrollToBottom();
}
function addBotMessage(message, isSystem = false) {
const messageElement = document.createElement('div');
messageElement.className = 'flex items-start space-x-3 message-animation';
if (isSystem) {
messageElement.innerHTML = `
<div class="bg-gray-100 p-3 rounded-full">
<i class="fas fa-info-circle text-gray-600"></i>
</div>
<div class="bg-gray-100 rounded-xl p-4 max-w-[80%]">
<p class="text-gray-800">${message}</p>
</div>
`;
} else {
messageElement.innerHTML = `
<div class="bg-blue-100 p-3 rounded-full">
<i class="fas fa-robot text-blue-600"></i>
</div>
<div class="bg-blue-50 rounded-xl p-4 max-w-[80%]">
<p class="text-gray-800">${message}</p>
<p class="text-xs text-gray-500 mt-2">Basé sur OpenAI</p>
</div>
`;
}
chatMessages.appendChild(messageElement);
scrollToBottom();
}
function showTypingIndicator() {
isTyping = true;
const typingElement = document.createElement('div');
typingElement.className = 'flex items-start space-x-3 message-animation';
typingElement.innerHTML = `
<div class="bg-blue-100 p-3 rounded-full">
<i class="fas fa-robot text-blue-600"></i>
</div>
<div class="bg-blue-50 rounded-xl p-4 max-w-[80%]">
<div class="typing-indicator flex space-x-1">
<span></span>
<span></span>
<span></span>
</div>
</div>
`;
chatMessages.appendChild(typingElement);
scrollToBottom();
}
function hideTypingIndicator() {
isTyping = false;
const typingIndicators = document.querySelectorAll('.typing-indicator');
if (typingIndicators.length > 0) {
typingIndicators[typingIndicators.length - 1].parentElement.parentElement.parentElement.remove();
}
}
function scrollToBottom() {
chatMessages.scrollTop = chatMessages.scrollHeight;
}
// Example quick questions
const quickQuestions = [
"Qu'est-ce que l'IA générative?",
"Peux-tu m'aider à coder une calculatrice en JavaScript?",
"Donne-moi des idées pour un roman de science-fiction",
"Explique-moi le théorème de Pythagore"
];
// Add quick question buttons (optional)
const quickQuestionsContainer = document.createElement('div');
quickQuestionsContainer.className = 'flex flex-wrap gap-2 mt-4 justify-center';
quickQuestions.forEach(question => {
const button = document.createElement('button');
button.className = 'bg-white text-sm text-gray-700 border border-gray-300 rounded-full px-4 py-2 hover:bg-gray-100 transition';
button.textContent = question;
button.addEventListener('click', () => {
userInput.value = question;
userInput.focus();
});
quickQuestionsContainer.appendChild(button);
});
document.querySelector('.bg-gray-50').insertBefore(quickQuestionsContainer, document.querySelector('.bg-gray-50 p'));
});
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Kasonga/prince" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html> |