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 +51 -41
index.html
CHANGED
|
@@ -528,8 +528,7 @@ useEffect(() => {
|
|
| 528 |
const aiModel = new HealthAIModel();
|
| 529 |
feather.replace();
|
| 530 |
}, []);
|
| 531 |
-
|
| 532 |
-
const handleSendMessage = () => {
|
| 533 |
if (!newMessage.trim()) return;
|
| 534 |
|
| 535 |
// Add user message
|
|
@@ -537,20 +536,19 @@ feather.replace();
|
|
| 537 |
setMessages([...messages, userMsg]);
|
| 538 |
setNewMessage('');
|
| 539 |
setIsTyping(true);
|
|
|
|
| 540 |
// AI response generation
|
| 541 |
-
setTimeout(() => {
|
| 542 |
let response;
|
| 543 |
if (aiMode) {
|
| 544 |
try {
|
| 545 |
-
|
| 546 |
-
|
| 547 |
-
context: "You are Dr. AI, a helpful and professional medical assistant providing accurate health information."
|
| 548 |
-
});
|
| 549 |
} catch (error) {
|
| 550 |
response = "I'm having trouble processing your request. Please try again or switch to support mode.";
|
| 551 |
console.error("AI Model Error:", error);
|
| 552 |
}
|
| 553 |
-
} else {
|
| 554 |
// Standard support responses
|
| 555 |
response = "Thank you for your message. A support representative will respond shortly.";
|
| 556 |
}
|
|
@@ -561,12 +559,11 @@ feather.replace();
|
|
| 561 |
sender: 'bot',
|
| 562 |
isAI: aiMode
|
| 563 |
};
|
| 564 |
-
setMessages(prev => [...prev, botMsg]);
|
| 565 |
setIsTyping(false);
|
| 566 |
}, 1500);
|
| 567 |
};
|
| 568 |
-
|
| 569 |
-
return (
|
| 570 |
<div className="pt-20 min-h-screen">
|
| 571 |
<div id="chat-background" className="fixed inset-0 -z-10"></div>
|
| 572 |
<div className="container mx-auto px-4 py-8">
|
|
@@ -651,16 +648,30 @@ setMessages(prev => [...prev, botMsg]);
|
|
| 651 |
</div>
|
| 652 |
<div className="mt-2 flex justify-between items-center">
|
| 653 |
<div className="flex space-x-2">
|
| 654 |
-
|
| 655 |
-
|
| 656 |
-
|
| 657 |
-
|
| 658 |
-
|
| 659 |
-
|
| 660 |
-
|
| 661 |
-
|
| 662 |
-
|
| 663 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 664 |
<button
|
| 665 |
onClick={() => setAiMode(!aiMode)}
|
| 666 |
className="text-xs flex items-center px-2 py-1 rounded-full transition-colors"
|
|
@@ -680,53 +691,52 @@ setMessages(prev => [...prev, botMsg]);
|
|
| 680 |
<button
|
| 681 |
className="bg-white bg-opacity-90 hover:bg-opacity-100 rounded-lg p-4 shadow-md flex flex-col items-center transition-all hover:shadow-lg"
|
| 682 |
onClick={() => {
|
| 683 |
-
setNewMessage("I'm experiencing headaches and
|
| 684 |
document.querySelector('input').focus();
|
| 685 |
}}
|
| 686 |
>
|
| 687 |
<div className="w-12 h-12 bg-indigo-100 rounded-full flex items-center justify-center mb-2">
|
| 688 |
-
<i data-feather="
|
| 689 |
-
</div>
|
| 690 |
-
<span className="text-sm font-medium">
|
| 691 |
</button>
|
| 692 |
<button
|
| 693 |
className="bg-white bg-opacity-90 hover:bg-opacity-100 rounded-lg p-4 shadow-md flex flex-col items-center transition-all hover:shadow-lg"
|
| 694 |
onClick={() => {
|
| 695 |
-
setNewMessage("
|
| 696 |
document.querySelector('input').focus();
|
| 697 |
}}
|
| 698 |
>
|
| 699 |
<div className="w-12 h-12 bg-purple-100 rounded-full flex items-center justify-center mb-2">
|
| 700 |
-
<i data-feather="
|
| 701 |
-
</div>
|
| 702 |
-
<span className="text-sm font-medium">
|
| 703 |
</button>
|
| 704 |
<button
|
| 705 |
className="bg-white bg-opacity-90 hover:bg-opacity-100 rounded-lg p-4 shadow-md flex flex-col items-center transition-all hover:shadow-lg"
|
| 706 |
onClick={() => {
|
| 707 |
-
setNewMessage("
|
| 708 |
document.querySelector('input').focus();
|
| 709 |
}}
|
| 710 |
>
|
| 711 |
<div className="w-12 h-12 bg-pink-100 rounded-full flex items-center justify-center mb-2">
|
| 712 |
-
<i data-feather="
|
| 713 |
-
</div>
|
| 714 |
-
<span className="text-sm font-medium">
|
| 715 |
</button>
|
| 716 |
<button
|
| 717 |
className="bg-white bg-opacity-90 hover:bg-opacity-100 rounded-lg p-4 shadow-md flex flex-col items-center transition-all hover:shadow-lg"
|
| 718 |
onClick={() => {
|
| 719 |
-
|
| 720 |
-
setNewMessage("I need to speak with a human support representative.");
|
| 721 |
document.querySelector('input').focus();
|
| 722 |
}}
|
| 723 |
-
>
|
| 724 |
-
<div className="w-12 h-12 bg-
|
| 725 |
-
<i data-feather="
|
|
|
|
|
|
|
|
|
|
| 726 |
</div>
|
| 727 |
-
<span className="text-sm font-medium">Human Support</span>
|
| 728 |
-
</button>
|
| 729 |
-
</div>
|
| 730 |
</div>
|
| 731 |
</div>
|
| 732 |
);
|
|
|
|
| 528 |
const aiModel = new HealthAIModel();
|
| 529 |
feather.replace();
|
| 530 |
}, []);
|
| 531 |
+
const handleSendMessage = async () => {
|
|
|
|
| 532 |
if (!newMessage.trim()) return;
|
| 533 |
|
| 534 |
// Add user message
|
|
|
|
| 536 |
setMessages([...messages, userMsg]);
|
| 537 |
setNewMessage('');
|
| 538 |
setIsTyping(true);
|
| 539 |
+
|
| 540 |
// AI response generation
|
| 541 |
+
setTimeout(async () => {
|
| 542 |
let response;
|
| 543 |
if (aiMode) {
|
| 544 |
try {
|
| 545 |
+
const aiModel = new HealthAIModel();
|
| 546 |
+
response = await aiModel.generateResponse(newMessage);
|
|
|
|
|
|
|
| 547 |
} catch (error) {
|
| 548 |
response = "I'm having trouble processing your request. Please try again or switch to support mode.";
|
| 549 |
console.error("AI Model Error:", error);
|
| 550 |
}
|
| 551 |
+
} else {
|
| 552 |
// Standard support responses
|
| 553 |
response = "Thank you for your message. A support representative will respond shortly.";
|
| 554 |
}
|
|
|
|
| 559 |
sender: 'bot',
|
| 560 |
isAI: aiMode
|
| 561 |
};
|
| 562 |
+
setMessages(prev => [...prev, botMsg]);
|
| 563 |
setIsTyping(false);
|
| 564 |
}, 1500);
|
| 565 |
};
|
| 566 |
+
return (
|
|
|
|
| 567 |
<div className="pt-20 min-h-screen">
|
| 568 |
<div id="chat-background" className="fixed inset-0 -z-10"></div>
|
| 569 |
<div className="container mx-auto px-4 py-8">
|
|
|
|
| 648 |
</div>
|
| 649 |
<div className="mt-2 flex justify-between items-center">
|
| 650 |
<div className="flex space-x-2">
|
| 651 |
+
<button
|
| 652 |
+
className="text-xs bg-indigo-100 text-indigo-800 px-2 py-1 rounded-full hover:bg-indigo-200 transition-colors"
|
| 653 |
+
onClick={() => {
|
| 654 |
+
setNewMessage("What are common symptoms I should watch for?");
|
| 655 |
+
document.querySelector('input').focus();
|
| 656 |
+
}}
|
| 657 |
+
>
|
| 658 |
+
Symptoms
|
| 659 |
+
</button>
|
| 660 |
+
<button
|
| 661 |
+
className="text-xs bg-purple-100 text-purple-800 px-2 py-1 rounded-full hover:bg-purple-200 transition-colors"
|
| 662 |
+
onClick={() => {
|
| 663 |
+
setNewMessage("Tell me about common medications and their uses");
|
| 664 |
+
document.querySelector('input').focus();
|
| 665 |
+
}}
|
| 666 |
+
>
|
| 667 |
+
Medications
|
| 668 |
+
</button>
|
| 669 |
+
<button
|
| 670 |
+
className="text-xs bg-green-100 text-green-800 px-2 py-1 rounded-full hover:bg-green-200 transition-colors"
|
| 671 |
+
>
|
| 672 |
+
Conditions
|
| 673 |
+
</button>
|
| 674 |
+
</div>
|
| 675 |
<button
|
| 676 |
onClick={() => setAiMode(!aiMode)}
|
| 677 |
className="text-xs flex items-center px-2 py-1 rounded-full transition-colors"
|
|
|
|
| 691 |
<button
|
| 692 |
className="bg-white bg-opacity-90 hover:bg-opacity-100 rounded-lg p-4 shadow-md flex flex-col items-center transition-all hover:shadow-lg"
|
| 693 |
onClick={() => {
|
| 694 |
+
setNewMessage("I'm experiencing headaches, dizziness, and fatigue. What could be causing these symptoms?");
|
| 695 |
document.querySelector('input').focus();
|
| 696 |
}}
|
| 697 |
>
|
| 698 |
<div className="w-12 h-12 bg-indigo-100 rounded-full flex items-center justify-center mb-2">
|
| 699 |
+
<i data-feather="activity" className="text-indigo-500"></i>
|
| 700 |
+
</div>
|
| 701 |
+
<span className="text-sm font-medium">Symptom Check</span>
|
| 702 |
</button>
|
| 703 |
<button
|
| 704 |
className="bg-white bg-opacity-90 hover:bg-opacity-100 rounded-lg p-4 shadow-md flex flex-col items-center transition-all hover:shadow-lg"
|
| 705 |
onClick={() => {
|
| 706 |
+
setNewMessage("Can you explain different types of diabetes and their management?");
|
| 707 |
document.querySelector('input').focus();
|
| 708 |
}}
|
| 709 |
>
|
| 710 |
<div className="w-12 h-12 bg-purple-100 rounded-full flex items-center justify-center mb-2">
|
| 711 |
+
<i data-feather="heart" className="text-purple-500"></i>
|
| 712 |
+
</div>
|
| 713 |
+
<span className="text-sm font-medium">Conditions</span>
|
| 714 |
</button>
|
| 715 |
<button
|
| 716 |
className="bg-white bg-opacity-90 hover:bg-opacity-100 rounded-lg p-4 shadow-md flex flex-col items-center transition-all hover:shadow-lg"
|
| 717 |
onClick={() => {
|
| 718 |
+
setNewMessage("What should I know about common medications like ibuprofen, metformin, and lisinopril?");
|
| 719 |
document.querySelector('input').focus();
|
| 720 |
}}
|
| 721 |
>
|
| 722 |
<div className="w-12 h-12 bg-pink-100 rounded-full flex items-center justify-center mb-2">
|
| 723 |
+
<i data-feather="package" className="text-pink-500"></i>
|
| 724 |
+
</div>
|
| 725 |
+
<span className="text-sm font-medium">Medications</span>
|
| 726 |
</button>
|
| 727 |
<button
|
| 728 |
className="bg-white bg-opacity-90 hover:bg-opacity-100 rounded-lg p-4 shadow-md flex flex-col items-center transition-all hover:shadow-lg"
|
| 729 |
onClick={() => {
|
| 730 |
+
setNewMessage("What are the key components of a healthy lifestyle for chronic disease prevention?");
|
|
|
|
| 731 |
document.querySelector('input').focus();
|
| 732 |
}}
|
| 733 |
+
>
|
| 734 |
+
<div className="w-12 h-12 bg-green-100 rounded-full flex items-center justify-center mb-2">
|
| 735 |
+
<i data-feather="shield" className="text-green-500"></i>
|
| 736 |
+
</div>
|
| 737 |
+
<span className="text-sm font-medium">Wellness</span>
|
| 738 |
+
</button>
|
| 739 |
</div>
|
|
|
|
|
|
|
|
|
|
| 740 |
</div>
|
| 741 |
</div>
|
| 742 |
);
|