Spaces:
Running
Running
File size: 24,063 Bytes
6002c17 | 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 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 | <!DOCTYPE html>
<html lang="en" class="dark">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>NelsonGPT - Pediatric Medical 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">
<link rel="manifest" href="/manifest.json">
<meta name="theme-color" content="#1e1e1e">
<style>
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
.message-fade {
animation: fadeIn 0.3s ease-out forwards;
}
.typing-indicator::after {
content: "...";
animation: typing 1.5s infinite;
}
@keyframes typing {
0% { content: "."; }
33% { content: ".."; }
66% { content: "..."; }
}
.code-block {
background-color: #2d3748;
border-radius: 0.375rem;
padding: 1rem;
font-family: monospace;
overflow-x: auto;
}
.tooltip {
position: relative;
}
.tooltip:hover .tooltip-text {
visibility: visible;
opacity: 1;
}
.tooltip-text {
visibility: hidden;
opacity: 0;
position: absolute;
z-index: 1;
bottom: 125%;
left: 50%;
transform: translateX(-50%);
background-color: #333;
color: white;
padding: 0.5rem;
border-radius: 0.375rem;
transition: opacity 0.3s;
width: max-content;
max-width: 200px;
font-size: 0.875rem;
}
.pulse {
animation: pulse 2s infinite;
}
@keyframes pulse {
0% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.7); }
70% { box-shadow: 0 0 0 10px rgba(74, 222, 128, 0); }
100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); }
}
</style>
</head>
<body class="bg-gray-900 text-gray-100 h-screen flex flex-col">
<!-- App Header -->
<header class="bg-gray-800 py-3 px-4 flex items-center justify-between sticky top-0 z-10">
<div class="flex items-center space-x-2">
<div class="w-8 h-8 rounded-full bg-gradient-to-r from-blue-500 to-green-500 flex items-center justify-center">
<i class="fas fa-child text-white"></i>
</div>
<h1 class="font-bold text-lg">NelsonGPT</h1>
</div>
<div class="flex items-center space-x-4">
<div class="relative">
<button id="model-selector" class="flex items-center space-x-1 bg-gray-700 hover:bg-gray-600 px-3 py-1 rounded-lg text-sm">
<span>Mistral-7B</span>
<i class="fas fa-chevron-down text-xs"></i>
</button>
<div id="model-dropdown" class="hidden absolute right-0 mt-2 w-48 bg-gray-700 rounded-lg shadow-lg z-20">
<a href="#" class="block px-4 py-2 hover:bg-gray-600 rounded-t-lg">Mistral-7B</a>
<a href="#" class="block px-4 py-2 hover:bg-gray-600">Gemini-Pro</a>
<a href="#" class="block px-4 py-2 hover:bg-gray-600 rounded-b-lg">Claude-3</a>
</div>
</div>
<button id="settings-btn" class="text-gray-300 hover:text-white">
<i class="fas fa-cog"></i>
</button>
</div>
</header>
<!-- Main Chat Area -->
<main class="flex-1 overflow-y-auto bg-gray-900 p-4 space-y-4" id="chat-container">
<!-- Welcome Message -->
<div class="message-fade bg-gray-800 rounded-xl p-4 max-w-3xl mx-auto">
<div class="flex items-start space-x-3">
<div class="w-8 h-8 rounded-full bg-gradient-to-r from-blue-500 to-green-500 flex items-center justify-center flex-shrink-0">
<i class="fas fa-child text-white"></i>
</div>
<div>
<h3 class="font-bold">NelsonGPT</h3>
<div class="prose prose-invert max-w-none mt-1">
<p>Hello! I'm NelsonGPT, your AI-powered pediatric medical assistant. How can I help you today?</p>
<p class="mt-2">Here are some things I can do:</p>
<ul class="list-disc pl-5 mt-1">
<li>Provide evidence-based pediatric guidance</li>
<li>Calculate medication dosages</li>
<li>Explain developmental milestones</li>
<li>Assist with emergency protocols</li>
<li>Interpret growth charts</li>
</ul>
</div>
</div>
</div>
</div>
<!-- Sample Message -->
<div class="message-fade bg-gray-700 rounded-xl p-4 max-w-3xl ml-auto">
<div class="flex items-start space-x-3">
<div class="w-8 h-8 rounded-full bg-gray-600 flex items-center justify-center flex-shrink-0">
<i class="fas fa-user text-white"></i>
</div>
<div>
<h3 class="font-bold">You</h3>
<div class="prose prose-invert max-w-none mt-1">
<p>What's the recommended treatment for otitis media in a 2-year-old?</p>
</div>
</div>
</div>
</div>
<!-- Sample Response -->
<div class="message-fade bg-gray-800 rounded-xl p-4 max-w-3xl mx-auto">
<div class="flex items-start space-x-3">
<div class="w-8 h-8 rounded-full bg-gradient-to-r from-blue-500 to-green-500 flex items-center justify-center flex-shrink-0">
<i class="fas fa-child text-white"></i>
</div>
<div>
<div class="flex items-center justify-between">
<h3 class="font-bold">NelsonGPT</h3>
<button class="text-xs text-gray-400 hover:text-white flex items-center">
<i class="fas fa-quote-right mr-1"></i>
<span>Citations</span>
</button>
</div>
<div class="prose prose-invert max-w-none mt-1">
<p>For acute otitis media in a 2-year-old, the recommended first-line treatment is:</p>
<ul class="list-disc pl-5 mt-1">
<li><strong>Amoxicillin</strong>: 80-90 mg/kg/day divided into 2 doses (max 3 g/day) for 10 days</li>
<li><strong>Alternative</strong> (if penicillin allergy): Cefdinir (14 mg/kg/day in 1-2 doses) or Azithromycin (10 mg/kg on day 1, then 5 mg/kg/day for 4 days)</li>
</ul>
<p class="mt-2">Watchful waiting for 48-72 hours may be appropriate for mild cases in otherwise healthy children.</p>
<div class="mt-3 p-3 bg-gray-700 rounded-lg">
<div class="flex items-start">
<i class="fas fa-info-circle mt-1 mr-2 text-blue-400"></i>
<div>
<p class="text-sm">For a 12 kg child, the amoxicillin dose would be approximately 480-540 mg/day (240-270 mg per dose).</p>
<button class="mt-2 text-sm text-blue-400 hover:text-blue-300 flex items-center">
<i class="fas fa-calculator mr-1"></i>
<span>Open Dose Calculator</span>
</button>
</div>
</div>
</div>
<div class="mt-3 text-xs text-gray-400 flex items-center">
<i class="fas fa-book mr-1"></i>
<span>Nelson Textbook of Pediatrics, 21st Ed. (Pg. 1456-1458)</span>
</div>
</div>
</div>
</div>
</div>
<!-- Typing Indicator -->
<div id="typing-indicator" class="hidden bg-gray-800 rounded-xl p-4 max-w-3xl mx-auto">
<div class="flex items-start space-x-3">
<div class="w-8 h-8 rounded-full bg-gradient-to-r from-blue-500 to-green-500 flex items-center justify-center flex-shrink-0">
<i class="fas fa-child text-white"></i>
</div>
<div>
<h3 class="font-bold">NelsonGPT</h3>
<div class="mt-1 text-gray-300 typing-indicator">Thinking</div>
</div>
</div>
</div>
</main>
<!-- Input Area -->
<div class="bg-gray-800 p-4 sticky bottom-0">
<div class="max-w-3xl mx-auto">
<div class="relative">
<textarea
id="message-input"
class="w-full bg-gray-700 text-white rounded-xl pl-4 pr-12 py-3 focus:outline-none focus:ring-2 focus:ring-green-500 resize-none"
placeholder="Ask about pediatric conditions, treatments, or calculations..."
rows="1"
></textarea>
<button id="send-btn" class="absolute right-3 bottom-3 text-gray-400 hover:text-green-500">
<i class="fas fa-paper-plane text-xl"></i>
</button>
<button id="voice-btn" class="absolute right-12 bottom-3 text-gray-400 hover:text-blue-500 tooltip">
<i class="fas fa-microphone text-xl"></i>
<span class="tooltip-text">Voice input (coming soon)</span>
</button>
</div>
<div class="flex justify-between items-center mt-2 text-xs text-gray-500">
<div>
<button class="hover:text-gray-300 mr-3">
<i class="fas fa-eraser mr-1"></i>
<span>Clear</span>
</button>
<button class="hover:text-gray-300">
<i class="fas fa-history mr-1"></i>
<span>History</span>
</button>
</div>
<div>
<button class="hover:text-gray-300">
<i class="fas fa-shield-alt mr-1"></i>
<span>For educational use only</span>
</button>
</div>
</div>
</div>
</div>
<!-- Bottom Navigation -->
<nav class="bg-gray-800 border-t border-gray-700 flex justify-around py-2">
<button class="flex flex-col items-center p-2 text-green-500">
<i class="fas fa-comment-medical text-xl"></i>
<span class="text-xs mt-1">Chat</span>
</button>
<button class="flex flex-col items-center p-2 text-gray-400 hover:text-white">
<i class="fas fa-calculator text-xl"></i>
<span class="text-xs mt-1">Tools</span>
</button>
<button class="flex flex-col items-center p-2 text-gray-400 hover:text-white">
<i class="fas fa-book-medical text-xl"></i>
<span class="text-xs mt-1">Resources</span>
</button>
<button class="flex flex-col items-center p-2 text-gray-400 hover:text-white">
<i class="fas fa-user-md text-xl"></i>
<span class="text-xs mt-1">Profile</span>
</button>
</nav>
<!-- Tools Modal -->
<div id="tools-modal" class="hidden fixed inset-0 bg-black bg-opacity-70 z-50 flex items-center justify-center p-4">
<div class="bg-gray-800 rounded-xl max-w-md w-full max-h-[90vh] overflow-y-auto">
<div class="p-4 border-b border-gray-700 flex justify-between items-center">
<h3 class="font-bold text-lg">Clinical Tools</h3>
<button id="close-tools" class="text-gray-400 hover:text-white">
<i class="fas fa-times"></i>
</button>
</div>
<div class="p-4 space-y-4">
<div class="bg-gray-700 rounded-lg p-4 hover:bg-gray-600 transition cursor-pointer">
<div class="flex items-center space-x-3">
<div class="w-10 h-10 rounded-full bg-blue-900 flex items-center justify-center">
<i class="fas fa-pills text-blue-400"></i>
</div>
<div>
<h4 class="font-bold">Dosage Calculator</h4>
<p class="text-sm text-gray-400">Weight-based pediatric medication dosing</p>
</div>
</div>
</div>
<div class="bg-gray-700 rounded-lg p-4 hover:bg-gray-600 transition cursor-pointer">
<div class="flex items-center space-x-3">
<div class="w-10 h-10 rounded-full bg-red-900 flex items-center justify-center">
<i class="fas fa-ambulance text-red-400"></i>
</div>
<div>
<h4 class="font-bold">Emergency Protocols</h4>
<p class="text-sm text-gray-400">Quick access to resuscitation guidelines</p>
</div>
</div>
</div>
<div class="bg-gray-700 rounded-lg p-4 hover:bg-gray-600 transition cursor-pointer">
<div class="flex items-center space-x-3">
<div class="w-10 h-10 rounded-full bg-green-900 flex items-center justify-center">
<i class="fas fa-baby text-green-400"></i>
</div>
<div>
<h4 class="font-bold">Milestone Tracker</h4>
<p class="text-sm text-gray-400">Developmental progress by age</p>
</div>
</div>
</div>
<div class="bg-gray-700 rounded-lg p-4 hover:bg-gray-600 transition cursor-pointer">
<div class="flex items-center space-x-3">
<div class="w-10 h-10 rounded-full bg-purple-900 flex items-center justify-center">
<i class="fas fa-chart-line text-purple-400"></i>
</div>
<div>
<h4 class="font-bold">Growth Charts</h4>
<p class="text-sm text-gray-400">Plot and interpret growth metrics</p>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
// DOM Elements
const messageInput = document.getElementById('message-input');
const sendBtn = document.getElementById('send-btn');
const chatContainer = document.getElementById('chat-container');
const typingIndicator = document.getElementById('typing-indicator');
const modelSelector = document.getElementById('model-selector');
const modelDropdown = document.getElementById('model-dropdown');
const toolsModal = document.getElementById('tools-modal');
const closeTools = document.getElementById('close-tools');
const voiceBtn = document.getElementById('voice-btn');
// Auto-resize textarea
messageInput.addEventListener('input', function() {
this.style.height = 'auto';
this.style.height = (this.scrollHeight) + 'px';
});
// Toggle model dropdown
modelSelector.addEventListener('click', function(e) {
e.stopPropagation();
modelDropdown.classList.toggle('hidden');
});
// Close dropdown when clicking outside
document.addEventListener('click', function() {
modelDropdown.classList.add('hidden');
});
// Send message
sendBtn.addEventListener('click', sendMessage);
messageInput.addEventListener('keydown', function(e) {
if (e.key === 'Enter' && !e.shiftKey) {
e.preventDefault();
sendMessage();
}
});
function sendMessage() {
const message = messageInput.value.trim();
if (!message) return;
// Add user message to chat
addMessageToChat('user', message);
messageInput.value = '';
messageInput.style.height = 'auto';
// Show typing indicator
typingIndicator.classList.remove('hidden');
chatContainer.scrollTop = chatContainer.scrollHeight;
// Simulate AI response after delay
setTimeout(() => {
typingIndicator.classList.add('hidden');
addMessageToChat('assistant', getSampleResponse(message));
chatContainer.scrollTop = chatContainer.scrollHeight;
}, 1500);
}
function addMessageToChat(role, content) {
const messageDiv = document.createElement('div');
messageDiv.className = `message-fade ${role === 'user' ? 'bg-gray-700 ml-auto' : 'bg-gray-800 mx-auto'} rounded-xl p-4 max-w-3xl`;
const messageHTML = `
<div class="flex items-start space-x-3">
<div class="w-8 h-8 rounded-full ${role === 'user' ? 'bg-gray-600' : 'bg-gradient-to-r from-blue-500 to-green-500'} flex items-center justify-center flex-shrink-0">
<i class="fas ${role === 'user' ? 'fa-user' : 'fa-child'} text-white"></i>
</div>
<div>
<h3 class="font-bold">${role === 'user' ? 'You' : 'NelsonGPT'}</h3>
<div class="prose prose-invert max-w-none mt-1">
${role === 'user' ? `<p>${content}</p>` : formatAssistantResponse(content)}
</div>
</div>
</div>
`;
messageDiv.innerHTML = messageHTML;
chatContainer.appendChild(messageDiv);
}
function formatAssistantResponse(content) {
// In a real app, this would parse markdown and add proper formatting
return `<p>${content}</p>
<div class="mt-3 text-xs text-gray-400 flex items-center">
<i class="fas fa-book mr-1"></i>
<span>Nelson Textbook of Pediatrics, 21st Ed. (Pg. 1234-1235)</span>
</div>`;
}
function getSampleResponse(query) {
const lowerQuery = query.toLowerCase();
if (lowerQuery.includes('otitis media')) {
return `For acute otitis media in children, the recommended first-line treatment is amoxicillin (80-90 mg/kg/day divided BID for 10 days). Alternatives for penicillin allergy include cefdinir or azithromycin. Pain management with ibuprofen or acetaminophen is also important. Consider watchful waiting for mild cases in children over 2 years.`;
} else if (lowerQuery.includes('asthma') || lowerQuery.includes('wheezing')) {
return `For acute asthma exacerbation in children:\n\n1. <strong>Mild</strong>: Inhaled SABA (albuterol 2-4 puffs q4-6h PRN)\n2. <strong>Moderate</strong>: SABA + oral prednisone (1-2 mg/kg/day for 3-5 days)\n3. <strong>Severe</strong>: Continuous SABA + IV steroids + consider magnesium sulfate\n\nAlways assess for signs of respiratory distress and provide oxygen if needed.`;
} else if (lowerQuery.includes('fever') && lowerQuery.includes('infant')) {
return `For infants with fever:\n\n- <strong>0-28 days</strong>: Full sepsis workup and hospitalization\n- <strong>29-60 days</strong>: CBC, blood culture, UA, CSF studies if ill-appearing\n- <strong>61-90 days</strong>: Clinical judgement, consider testing if high-risk\n\nAntipyretics (acetaminophen 10-15 mg/kg q4-6h) for comfort. Always evaluate for source and signs of serious bacterial infection.`;
} else if (lowerQuery.includes('dose') || lowerQuery.includes('dosage')) {
return `I can help calculate medication dosages. Please provide:\n\n1. Medication name\n2. Patient weight\n3. Age (if relevant)\n\nFor example: "What's the amoxicillin dose for a 15 kg 3-year-old?"\n\n<button class="mt-2 px-3 py-1 bg-blue-600 hover:bg-blue-700 rounded-lg text-sm flex items-center">
<i class="fas fa-calculator mr-2"></i>
<span>Open Dose Calculator</span>
</button>`;
} else {
return `I found this information about "${query}" in the Nelson Textbook of Pediatrics:\n\nPediatric management typically involves... (this would be the actual AI-generated response with citations in a production environment).\n\nWould you like me to provide more specific details about any aspect?`;
}
}
// Tools modal
document.querySelectorAll('[class*="fa-calculator"]').forEach(btn => {
btn.addEventListener('click', function(e) {
if (e.target.tagName === 'I' || e.target.tagName === 'SPAN') {
toolsModal.classList.remove('hidden');
}
});
});
closeTools.addEventListener('click', function() {
toolsModal.classList.add('hidden');
});
// PWA installation prompt
window.addEventListener('beforeinstallprompt', (e) => {
// Prevent the mini-infobar from appearing on mobile
e.preventDefault();
// Stash the event so it can be triggered later
deferredPrompt = e;
// Show install button (we could add this to UI)
console.log('PWA installation available');
});
// Register service worker
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('/service-worker.js').then(
(registration) => {
console.log('ServiceWorker registration successful');
},
(err) => {
console.log('ServiceWorker registration failed: ', err);
}
);
});
}
</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=drzeeIslam/my" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html> |