File size: 16,366 Bytes
3b8a58e | 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 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Rohan - 3D AI Assistant</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">
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/three@0.128.0/examples/js/loaders/GLTFLoader.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/three@0.128.0/examples/js/controls/OrbitControls.min.js"></script>
<style>
#model-container {
width: 300px;
height: 300px;
margin: 0 auto;
position: relative;
}
#model-viewer {
width: 100%;
height: 100%;
background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
border-radius: 50%;
overflow: hidden;
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}
.chat-container {
height: 400px;
overflow-y: auto;
scrollbar-width: thin;
}
.chat-container::-webkit-scrollbar {
width: 6px;
}
.chat-container::-webkit-scrollbar-thumb {
background-color: rgba(156, 163, 175, 0.5);
border-radius: 3px;
}
.user-message {
animation: fadeIn 0.3s ease;
}
.ai-message {
animation: fadeIn 0.5s ease;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
.input-container {
box-shadow: 0 -5px 15px rgba(0, 0, 0, 0.05);
}
.status-indicator {
transition: all 0.3s ease;
}
.typing .status-indicator {
animation: pulse 1.5s infinite;
}
@keyframes pulse {
0%, 100% { opacity: 0.5; }
50% { opacity: 1; }
}
</style>
</head>
<body class="bg-gray-50 min-h-screen flex flex-col">
<div class="container mx-auto px-4 py-8 flex-1 flex flex-col max-w-3xl">
<!-- Header -->
<header class="text-center mb-8">
<h1 class="text-4xl font-bold text-indigo-600 mb-2">Rohan</h1>
<p class="text-gray-600">Your 3D AI assistant</p>
</header>
<!-- 3D Model -->
<div class="mb-8 flex flex-col items-center">
<div id="model-container">
<div id="model-viewer"></div>
</div>
<div class="mt-4 text-center">
<div class="status-indicator inline-block w-3 h-3 rounded-full bg-green-500 mr-2"></div>
<span class="text-gray-600 status-text">Ready to help you</span>
</div>
</div>
<!-- Chat Container -->
<div class="chat-container bg-white rounded-lg shadow-md p-4 mb-4 flex-1">
<div class="ai-message flex mb-4">
<div class="flex-shrink-0 mr-3">
<div class="w-8 h-8 rounded-full bg-indigo-100 flex items-center justify-center">
<i class="fas fa-robot text-indigo-500"></i>
</div>
</div>
<div class="bg-indigo-50 rounded-lg p-3 max-w-[85%]">
<p class="text-gray-800">Namaste! I'm Rohan, your 3D AI assistant. How can I help you today?</p>
</div>
</div>
<div id="chat-messages"></div>
</div>
<!-- Input Area -->
<div class="input-container bg-white rounded-lg shadow-md p-4">
<form id="chat-form" class="flex">
<input
type="text"
id="user-input"
placeholder="Ask me anything..."
class="flex-1 border border-gray-300 rounded-l-lg py-2 px-4 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent"
autocomplete="off"
>
<button
type="submit"
class="bg-indigo-600 hover:bg-indigo-700 text-white font-medium py-2 px-6 rounded-r-lg transition duration-200"
>
Send
</button>
</form>
<div class="mt-2 flex justify-between text-xs text-gray-500">
<span>Try: "weather in Delhi" or "what's 20% of 150?"</span>
<span id="typing-indicator" class="hidden">
<i class="fas fa-circle-notch fa-spin mr-1"></i> Rohan is typing...
</span>
</div>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
// Three.js setup
const container = document.getElementById('model-viewer');
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(75, 1, 0.1, 1000);
const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });
renderer.setSize(container.clientWidth, container.clientHeight);
container.appendChild(renderer.domElement);
// Lighting
const ambientLight = new THREE.AmbientLight(0xffffff, 0.6);
scene.add(ambientLight);
const directionalLight = new THREE.DirectionalLight(0xffffff, 0.8);
directionalLight.position.set(1, 1, 1);
scene.add(directionalLight);
// Controls
const controls = new THREE.OrbitControls(camera, renderer.domElement);
controls.enableZoom = false;
controls.enablePan = false;
controls.maxPolarAngle = Math.PI * 0.6;
controls.minPolarAngle = Math.PI * 0.4;
controls.maxAzimuthAngle = Math.PI * 0.2;
controls.minAzimuthAngle = -Math.PI * 0.2;
// Camera position
camera.position.z = 2;
// Load 3D model (using a free Indian boy model from Sketchfab)
const loader = new THREE.GLTFLoader();
const modelUrl = 'https://cdn.jsdelivr.net/gh/mrdoob/three.js@r128/examples/models/gltf/Parrot.glb';
// For demo purposes, we'll use a placeholder model
// In production, you would use a proper Indian boy model URL
loader.load(
modelUrl,
function(gltf) {
const model = gltf.scene;
model.scale.set(0.02, 0.02, 0.02);
model.position.y = -0.5;
scene.add(model);
// Animation loop
function animate() {
requestAnimationFrame(animate);
model.rotation.y += 0.005;
controls.update();
renderer.render(scene, camera);
}
animate();
},
undefined,
function(error) {
console.error('Error loading 3D model:', error);
// Fallback to a simple sphere if model fails to load
const geometry = new THREE.SphereGeometry(1, 32, 32);
const material = new THREE.MeshBasicMaterial({ color: 0x00ff00 });
const sphere = new THREE.Mesh(geometry, material);
scene.add(sphere);
function animate() {
requestAnimationFrame(animate);
sphere.rotation.y += 0.01;
renderer.render(scene, camera);
}
animate();
}
);
// Chat functionality
const chatForm = document.getElementById('chat-form');
const userInput = document.getElementById('user-input');
const chatMessages = document.getElementById('chat-messages');
const typingIndicator = document.getElementById('typing-indicator');
const statusText = document.querySelector('.status-text');
const statusIndicator = document.querySelector('.status-indicator');
// Change status
function setStatus(status, text) {
statusIndicator.className = `status-indicator inline-block w-3 h-3 rounded-full mr-2 ${status}`;
statusText.textContent = text;
if (status === 'typing') {
statusIndicator.classList.add('typing');
} else {
statusIndicator.classList.remove('typing');
}
}
// Add message to chat
function addMessage(content, isUser) {
const messageDiv = document.createElement('div');
messageDiv.className = `${isUser ? 'user-message' : 'ai-message'} flex mb-4 ${isUser ? 'justify-end' : ''}`;
messageDiv.innerHTML = `
${isUser ? '' : `
<div class="flex-shrink-0 mr-3">
<div class="w-8 h-8 rounded-full bg-indigo-100 flex items-center justify-center">
<i class="fas fa-robot text-indigo-500"></i>
</div>
</div>
`}
<div class="${isUser ? 'bg-indigo-100' : 'bg-indigo-50'} rounded-lg p-3 max-w-[85%]">
<p class="text-gray-800">${content}</p>
</div>
${isUser ? `
<div class="flex-shrink-0 ml-3">
<div class="w-8 h-8 rounded-full bg-gray-100 flex items-center justify-center">
<i class="fas fa-user text-gray-500"></i>
</div>
</div>
` : ''}
`;
chatMessages.appendChild(messageDiv);
chatMessages.scrollTop = chatMessages.scrollHeight;
}
// Simulate AI response
function getAIResponse(message) {
return new Promise((resolve) => {
setTimeout(() => {
const lowerMsg = message.toLowerCase();
if (lowerMsg.includes('weather') || lowerMsg.includes('temperature')) {
const location = message.replace(/weather|temperature|in|at/gi, '').trim();
resolve(`The weather in ${location || "your location"} is pleasant today! Around 30°C with moderate humidity.`);
}
else if (lowerMsg.includes('hi') || lowerMsg.includes('hello') || lowerMsg.includes('namaste')) {
resolve("Namaste! How can I assist you today?");
}
else if (lowerMsg.includes('how are you')) {
resolve("I'm doing great, dhanyavaad for asking! What can I do for you?");
}
else if (lowerMsg.includes('thank') || lowerMsg.includes('dhanyavaad')) {
resolve("You're most welcome! Let me know if you need anything else.");
}
else if (lowerMsg.includes('+') || lowerMsg.includes('-') || lowerMsg.includes('*') || lowerMsg.includes('/') || lowerMsg.includes('math') || lowerMsg.includes('%')) {
try {
const result = eval(message.replace(/[^-()\d/*+.]/g, ''));
resolve(`The answer is ${result}.`);
} catch {
resolve("I couldn't calculate that. Could you please rephrase your math question?");
}
}
else if (lowerMsg.includes('time')) {
const now = new Date();
resolve(`The current time is ${now.toLocaleTimeString()}.`);
}
else if (lowerMsg.includes('india') || lowerMsg.includes('bharat')) {
resolve("India is a beautiful country with diverse culture, languages, and traditions. It's known for its rich history, delicious food, and warm hospitality!");
}
else {
resolve(`I understand you're asking about "${message}". Here's what I found: This is a simulated response. In a real app, I'd provide a detailed answer to your question.`);
}
}, 1500);
});
}
// Handle form submission
chatForm.addEventListener('submit', async function(e) {
e.preventDefault();
const message = userInput.value.trim();
if (!message) return;
// Add user message
addMessage(message, true);
userInput.value = '';
// Show typing indicator
setStatus('bg-yellow-500 typing', 'Thinking...');
typingIndicator.classList.remove('hidden');
// Get AI response
try {
const response = await getAIResponse(message);
// Hide typing indicator
typingIndicator.classList.add('hidden');
// Set appropriate status
if (response.includes('Namaste') || response.includes('welcome') || response.includes('pleasant')) {
setStatus('bg-green-500', 'Happy to help!');
} else if (response.includes('understand') || response.includes('rephrase') || response.includes('think')) {
setStatus('bg-blue-500', 'Processing...');
} else if (response.includes('couldn\'t') || response.includes('sorry')) {
setStatus('bg-red-500', 'Having trouble');
} else {
setStatus('bg-green-500', 'Ready to help');
}
// Add AI response
addMessage(response, false);
} catch (error) {
typingIndicator.classList.add('hidden');
setStatus('bg-red-500', 'Error occurred');
addMessage("Something went wrong. Please try again.", false);
console.error(error);
}
});
// Focus input on load
userInput.focus();
// Resize handler
window.addEventListener('resize', function() {
camera.aspect = 1;
camera.updateProjectionMatrix();
renderer.setSize(container.clientWidth, container.clientHeight);
});
});
</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=m-Kairo/chatbot" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html> |