Spaces:
Running
Running
it is about health and care make it on that and also add a LMM for chatbot which would give all information
Browse files- index.html +101 -49
index.html
CHANGED
|
@@ -61,47 +61,81 @@
|
|
| 61 |
lisinopril: "May cause cough. Monitor blood pressure and potassium levels."
|
| 62 |
}
|
| 63 |
};
|
| 64 |
-
|
| 65 |
-
// AI Model Configuration
|
| 66 |
class HealthAIModel {
|
| 67 |
constructor() {
|
| 68 |
-
this.
|
| 69 |
-
|
| 70 |
-
|
|
|
|
|
|
|
| 71 |
}
|
| 72 |
|
| 73 |
async generateResponse(prompt) {
|
| 74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
const lowerPrompt = prompt.toLowerCase();
|
| 76 |
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
return
|
| 83 |
-
} else if (lowerPrompt.includes('diabetes') || lowerPrompt.includes('blood sugar')) {
|
| 84 |
-
return healthKnowledge.conditions.diabetes;
|
| 85 |
-
} else if (lowerPrompt.includes('blood pressure') || lowerPrompt.includes('hypertension')) {
|
| 86 |
-
return healthKnowledge.conditions.hypertension;
|
| 87 |
-
} else if (lowerPrompt.includes('asthma') || lowerPrompt.includes('breathing')) {
|
| 88 |
-
return healthKnowledge.conditions.asthma;
|
| 89 |
-
} else if (lowerPrompt.includes('ibuprofen') || lowerPrompt.includes('advil')) {
|
| 90 |
-
return healthKnowledge.medications.ibuprofen;
|
| 91 |
-
} else if (lowerPrompt.includes('metformin')) {
|
| 92 |
-
return healthKnowledge.medications.metformin;
|
| 93 |
-
} else if (lowerPrompt.includes('lisinopril')) {
|
| 94 |
-
return healthKnowledge.medications.lisinopril;
|
| 95 |
}
|
| 96 |
|
| 97 |
-
// For general health questions
|
| 98 |
return `I recommend consulting a healthcare professional for personalized advice.
|
| 99 |
Based on general knowledge: ${prompt} may require medical attention if persistent
|
| 100 |
-
or severe. Would you like me to
|
| 101 |
}
|
| 102 |
}
|
| 103 |
-
|
| 104 |
-
// App Component
|
| 105 |
function App() {
|
| 106 |
const [currentPage, setCurrentPage] = useState('home');
|
| 107 |
|
|
@@ -212,7 +246,8 @@ function App() {
|
|
| 212 |
Your Personal <span className="text-amber-500">Health Guardian</span>
|
| 213 |
</h1>
|
| 214 |
<p className="text-lg text-gray-700 mb-8">
|
| 215 |
-
AI-powered health companion providing 24/7
|
|
|
|
| 216 |
</p>
|
| 217 |
<div className="flex space-x-4">
|
| 218 |
<button
|
|
@@ -231,8 +266,8 @@ function App() {
|
|
| 231 |
</div>
|
| 232 |
<div className="md:w-1/2 mt-10 md:mt-0 hero-image">
|
| 233 |
<img
|
| 234 |
-
src="http://static.photos/medical/1024x576/
|
| 235 |
-
alt="
|
| 236 |
className="rounded-xl shadow-2xl floating w-full max-w-md mx-auto"
|
| 237 |
/>
|
| 238 |
</div>
|
|
@@ -244,26 +279,26 @@ function App() {
|
|
| 244 |
<h2 className="text-3xl font-bold text-center mb-12">Our Services</h2>
|
| 245 |
<div className="grid grid-cols-1 md:grid-cols-3 gap-8">
|
| 246 |
<div className="feature-card bg-white text-green-800 p-6 rounded-xl shadow-lg hover:shadow-2xl transition-shadow">
|
| 247 |
-
|
| 248 |
-
<i data-feather="
|
| 249 |
</div>
|
| 250 |
-
<h3 className="text-xl font-bold mb-2 text-center">
|
| 251 |
-
<p className="text-center">
|
| 252 |
-
|
| 253 |
<div className="feature-card bg-white text-green-800 p-6 rounded-xl shadow-lg hover:shadow-2xl transition-shadow">
|
| 254 |
-
|
| 255 |
-
<i data-feather="
|
| 256 |
</div>
|
| 257 |
-
<h3 className="text-xl font-bold mb-2 text-center">
|
| 258 |
-
<p className="text-center">
|
| 259 |
-
|
| 260 |
<div className="feature-card bg-white text-green-800 p-6 rounded-xl shadow-lg hover:shadow-2xl transition-shadow">
|
| 261 |
-
|
| 262 |
-
<i data-feather="
|
| 263 |
</div>
|
| 264 |
-
<h3 className="text-xl font-bold mb-2 text-center">
|
| 265 |
-
<p className="text-center">
|
| 266 |
-
|
| 267 |
</div>
|
| 268 |
</div>
|
| 269 |
</section>
|
|
@@ -770,11 +805,28 @@ setMessages(prev => [...prev, botMsg]);
|
|
| 770 |
</script>
|
| 771 |
<script>feather.replace();</script>
|
| 772 |
<script>
|
| 773 |
-
// Initialize health monitoring
|
| 774 |
HealthAPI.init({
|
| 775 |
apiKey: 'health-public-key',
|
| 776 |
-
features: [
|
| 777 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 778 |
});
|
| 779 |
</script>
|
| 780 |
</body>
|
|
|
|
| 61 |
lisinopril: "May cause cough. Monitor blood pressure and potassium levels."
|
| 62 |
}
|
| 63 |
};
|
| 64 |
+
// LMM Health Model Configuration
|
|
|
|
| 65 |
class HealthAIModel {
|
| 66 |
constructor() {
|
| 67 |
+
this.apiUrl = 'https://api-inference.huggingface.co/models/microsoft/BioGPT-Large';
|
| 68 |
+
this.apiKey = 'hf_your_api_key_here'; // Replace with actual API key
|
| 69 |
+
this.context = `You are Dr. AI, an advanced medical assistant trained on the latest health data.
|
| 70 |
+
Provide accurate, evidence-based medical information while maintaining empathy.
|
| 71 |
+
Always recommend consulting a healthcare professional for diagnosis and treatment.`;
|
| 72 |
}
|
| 73 |
|
| 74 |
async generateResponse(prompt) {
|
| 75 |
+
try {
|
| 76 |
+
const response = await fetch(this.apiUrl, {
|
| 77 |
+
method: 'POST',
|
| 78 |
+
headers: {
|
| 79 |
+
'Authorization': `Bearer ${this.apiKey}`,
|
| 80 |
+
'Content-Type': 'application/json'
|
| 81 |
+
},
|
| 82 |
+
body: JSON.stringify({
|
| 83 |
+
inputs: `[Medical Context] ${this.context}\n[User Query] ${prompt}\n[Response]`,
|
| 84 |
+
parameters: {
|
| 85 |
+
max_length: 500,
|
| 86 |
+
temperature: 0.7,
|
| 87 |
+
top_p: 0.9
|
| 88 |
+
}
|
| 89 |
+
})
|
| 90 |
+
});
|
| 91 |
+
|
| 92 |
+
if (!response.ok) throw new Error('API request failed');
|
| 93 |
+
|
| 94 |
+
const result = await response.json();
|
| 95 |
+
|
| 96 |
+
// Fallback to local knowledge if API fails
|
| 97 |
+
if (!result || !result[0]?.generated_text) {
|
| 98 |
+
return this.getLocalResponse(prompt);
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
return result[0].generated_text.split('[Response]')[1] ||
|
| 102 |
+
"I couldn't generate a helpful response. Please try rephrasing your question.";
|
| 103 |
+
|
| 104 |
+
} catch (error) {
|
| 105 |
+
console.error("LMM Error:", error);
|
| 106 |
+
return this.getLocalResponse(prompt);
|
| 107 |
+
}
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
getLocalResponse(prompt) {
|
| 111 |
+
// Enhanced local knowledge base
|
| 112 |
+
const symptoms = {
|
| 113 |
+
headache: "Headaches can range from tension-type to migraines. Common causes include stress, dehydration, eye strain, or sinus issues. Try hydration, rest in a dark room, and OTC pain relievers if appropriate. Seek immediate care for sudden severe headache or with neurological symptoms.",
|
| 114 |
+
fever: "Fever is your body fighting infection. For adults: rest, hydrate, use fever reducers if >102°F. For children: monitor closely - seek care if <3mo with any fever or older children with high (>104°F) or prolonged (>3 days) fever.",
|
| 115 |
+
chestPain: "Chest pain requires evaluation. If sudden, severe, radiates to arm/jaw, with sweating/shortness of breath - call emergency services immediately. May indicate heart attack, pulmonary embolism, or other serious conditions."
|
| 116 |
+
};
|
| 117 |
+
|
| 118 |
+
const conditions = {
|
| 119 |
+
diabetes: "Diabetes management focuses on blood sugar control through diet (low glycemic foods), exercise, medication adherence, and regular monitoring. Complications can affect eyes, kidneys, and nerves - get regular checkups.",
|
| 120 |
+
hypertension: "High blood pressure often has no symptoms. Management includes DASH diet (low sodium, high potassium), regular exercise, stress reduction, and prescribed medications. Monitor at home and keep <130/80 mmHg."
|
| 121 |
+
};
|
| 122 |
+
|
| 123 |
const lowerPrompt = prompt.toLowerCase();
|
| 124 |
|
| 125 |
+
// Search prompt for health topics
|
| 126 |
+
for (const [key, value] of Object.entries(symptoms)) {
|
| 127 |
+
if (lowerPrompt.includes(key)) return value;
|
| 128 |
+
}
|
| 129 |
+
for (const [key, value] of Object.entries(conditions)) {
|
| 130 |
+
if (lowerPrompt.includes(key)) return value;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 131 |
}
|
| 132 |
|
|
|
|
| 133 |
return `I recommend consulting a healthcare professional for personalized advice.
|
| 134 |
Based on general knowledge: ${prompt} may require medical attention if persistent
|
| 135 |
+
or severe. Would you like me to help you find a specialist or schedule an appointment?`;
|
| 136 |
}
|
| 137 |
}
|
| 138 |
+
// App Component
|
|
|
|
| 139 |
function App() {
|
| 140 |
const [currentPage, setCurrentPage] = useState('home');
|
| 141 |
|
|
|
|
| 246 |
Your Personal <span className="text-amber-500">Health Guardian</span>
|
| 247 |
</h1>
|
| 248 |
<p className="text-lg text-gray-700 mb-8">
|
| 249 |
+
AI-powered health companion with advanced medical knowledge, providing 24/7 accurate health information,
|
| 250 |
+
symptom analysis, and personalized wellness recommendations powered by BioGPT-Large language model.
|
| 251 |
</p>
|
| 252 |
<div className="flex space-x-4">
|
| 253 |
<button
|
|
|
|
| 266 |
</div>
|
| 267 |
<div className="md:w-1/2 mt-10 md:mt-0 hero-image">
|
| 268 |
<img
|
| 269 |
+
src="http://static.photos/medical/1024x576/42"
|
| 270 |
+
alt="Advanced AI doctor consultation"
|
| 271 |
className="rounded-xl shadow-2xl floating w-full max-w-md mx-auto"
|
| 272 |
/>
|
| 273 |
</div>
|
|
|
|
| 279 |
<h2 className="text-3xl font-bold text-center mb-12">Our Services</h2>
|
| 280 |
<div className="grid grid-cols-1 md:grid-cols-3 gap-8">
|
| 281 |
<div className="feature-card bg-white text-green-800 p-6 rounded-xl shadow-lg hover:shadow-2xl transition-shadow">
|
| 282 |
+
<div className="bg-amber-100 w-16 h-16 rounded-full flex items-center justify-center mb-4 mx-auto">
|
| 283 |
+
<i data-feather="activity" className="text-amber-600 w-8 h-8"></i>
|
| 284 |
</div>
|
| 285 |
+
<h3 className="text-xl font-bold mb-2 text-center">Symptom Analysis</h3>
|
| 286 |
+
<p className="text-center">Advanced AI analyzes symptoms with medical accuracy and suggests possible conditions.</p>
|
| 287 |
+
</div>
|
| 288 |
<div className="feature-card bg-white text-green-800 p-6 rounded-xl shadow-lg hover:shadow-2xl transition-shadow">
|
| 289 |
+
<div className="bg-amber-100 w-16 h-16 rounded-full flex items-center justify-center mb-4 mx-auto">
|
| 290 |
+
<i data-feather="book-open" className="text-amber-600 w-8 h-8"></i>
|
| 291 |
</div>
|
| 292 |
+
<h3 className="text-xl font-bold mb-2 text-center">Medical Knowledge</h3>
|
| 293 |
+
<p className="text-center">Access to the latest research and evidence-based medical information.</p>
|
| 294 |
+
</div>
|
| 295 |
<div className="feature-card bg-white text-green-800 p-6 rounded-xl shadow-lg hover:shadow-2xl transition-shadow">
|
| 296 |
+
<div className="bg-amber-100 w-16 h-16 rounded-full flex items-center justify-center mb-4 mx-auto">
|
| 297 |
+
<i data-feather="heart" className="text-amber-600 w-8 h-8"></i>
|
| 298 |
</div>
|
| 299 |
+
<h3 className="text-xl font-bold mb-2 text-center">Personalized Care</h3>
|
| 300 |
+
<p className="text-center">Tailored health recommendations based on your specific needs and history.</p>
|
| 301 |
+
</div>
|
| 302 |
</div>
|
| 303 |
</div>
|
| 304 |
</section>
|
|
|
|
| 805 |
</script>
|
| 806 |
<script>feather.replace();</script>
|
| 807 |
<script>
|
| 808 |
+
// Initialize advanced health monitoring
|
| 809 |
HealthAPI.init({
|
| 810 |
apiKey: 'health-public-key',
|
| 811 |
+
features: [
|
| 812 |
+
'symptom_analysis',
|
| 813 |
+
'condition_information',
|
| 814 |
+
'treatment_options',
|
| 815 |
+
'wellness_recommendations'
|
| 816 |
+
],
|
| 817 |
+
model: 'BioGPT-Large',
|
| 818 |
+
userId: 'user-' + Math.random().toString(36).substr(2, 9),
|
| 819 |
+
consent: true
|
| 820 |
+
});
|
| 821 |
+
|
| 822 |
+
// Track health queries for continuous improvement
|
| 823 |
+
document.addEventListener('DOMContentLoaded', () => {
|
| 824 |
+
const chatInput = document.querySelector('.chat-input input');
|
| 825 |
+
if (chatInput) {
|
| 826 |
+
chatInput.addEventListener('focus', () => {
|
| 827 |
+
HealthAPI.logEvent('chat_interaction_started');
|
| 828 |
+
});
|
| 829 |
+
}
|
| 830 |
});
|
| 831 |
</script>
|
| 832 |
</body>
|