Debanjan455 commited on
Commit
872a75f
·
verified ·
1 Parent(s): f8ebc45

use and ai model for the chat and change the colour

Browse files
Files changed (1) hide show
  1. index.html +27 -25
index.html CHANGED
@@ -415,7 +415,7 @@ useEffect(() => {
415
  });
416
 
417
  // Initialize Vanta.js background
418
- VANTA.GLOBE({
419
  el: "#chat-background",
420
  mouseControls: true,
421
  touchControls: true,
@@ -424,10 +424,18 @@ useEffect(() => {
424
  minWidth: 200.00,
425
  scale: 1.00,
426
  scaleMobile: 1.00,
427
- color: aiMode ? 0x7c3aed : 0x3b82f6,
428
  backgroundColor: 0xf8fafc,
429
  size: 0.8
430
  });
 
 
 
 
 
 
 
 
431
  feather.replace();
432
  }, []);
433
 
@@ -443,23 +451,16 @@ feather.replace();
443
  setTimeout(() => {
444
  let response;
445
  if (aiMode) {
446
- // Enhanced AI responses
447
- const responses = {
448
- symptoms: "Based on your symptoms, I'm analyzing possible conditions. Please provide more details like duration and severity.",
449
- medications: "I can check for drug interactions. Please list all medications including dosage.",
450
- wellness: "For better wellness, I recommend a balanced diet, regular exercise and 7-9 hours of sleep. Would you like a personalized plan?"
451
- };
452
-
453
- if (newMessage.toLowerCase().includes('symptom') || newMessage.toLowerCase().includes('pain')) {
454
- response = responses.symptoms;
455
- } else if (newMessage.toLowerCase().includes('medication') || newMessage.toLowerCase().includes('pill')) {
456
- response = responses.medications;
457
- } else if (newMessage.toLowerCase().includes('wellness') || newMessage.toLowerCase().includes('health')) {
458
- response = responses.wellness;
459
- } else {
460
- response = "I'm analyzing your query with my medical knowledge base. Please provide any additional details that might help.";
461
  }
462
- } else {
463
  // Standard support responses
464
  response = "Thank you for your message. A support representative will respond shortly.";
465
  }
@@ -516,10 +517,10 @@ setMessages(prev => [...prev, botMsg]);
516
  <div
517
  className={`max-w-xs md:max-w-md rounded-lg p-3 ${
518
  msg.sender === 'user'
519
- ? 'bg-indigo-100 text-gray-800 rounded-br-none'
520
  : msg.isAI
521
- ? 'bg-purple-100 text-gray-800 rounded-bl-none'
522
- : 'bg-blue-100 text-gray-800 rounded-bl-none'
523
  }`}
524
  >
525
  <p>{msg.text}</p>
@@ -574,9 +575,9 @@ setMessages(prev => [...prev, botMsg]);
574
  onClick={() => setAiMode(!aiMode)}
575
  className="text-xs flex items-center px-2 py-1 rounded-full transition-colors"
576
  style={{
577
- backgroundColor: aiMode ? 'rgba(99, 102, 241, 0.1)' : 'rgba(156, 163, 175, 0.1)',
578
- color: aiMode ? 'rgb(99, 102, 241)' : 'rgb(156, 163, 175)'
579
- }}
580
  >
581
  <i data-feather={aiMode ? "cpu" : "user"} className="w-3 h-3 mr-1"></i>
582
  {aiMode ? 'AI Mode' : 'Support'}
@@ -712,6 +713,7 @@ setMessages(prev => [...prev, botMsg]);
712
  // Render the app
713
  ReactDOM.render(<App />, document.getElementById('root'));
714
  </script>
715
- <script>feather.replace();</script>
 
716
  </body>
717
  </html>
 
415
  });
416
 
417
  // Initialize Vanta.js background
418
+ VANTA.GLOBE({
419
  el: "#chat-background",
420
  mouseControls: true,
421
  touchControls: true,
 
424
  minWidth: 200.00,
425
  scale: 1.00,
426
  scaleMobile: 1.00,
427
+ color: aiMode ? 0x10b981 : 0xf59e0b,
428
  backgroundColor: 0xf8fafc,
429
  size: 0.8
430
  });
431
+
432
+ // Initialize AI model
433
+ const aiModel = new window.AIModel({
434
+ modelName: 'gpt-3.5-turbo',
435
+ apiKey: 'sk-your-api-key-here',
436
+ temperature: 0.7,
437
+ maxTokens: 150
438
+ });
439
  feather.replace();
440
  }, []);
441
 
 
451
  setTimeout(() => {
452
  let response;
453
  if (aiMode) {
454
+ try {
455
+ response = await aiModel.generateResponse({
456
+ prompt: `As a medical AI assistant, respond to this health query: "${newMessage}"`,
457
+ context: "You are Dr. AI, a helpful and professional medical assistant providing accurate health information."
458
+ });
459
+ } catch (error) {
460
+ response = "I'm having trouble processing your request. Please try again or switch to support mode.";
461
+ console.error("AI Model Error:", error);
 
 
 
 
 
 
 
462
  }
463
+ } else {
464
  // Standard support responses
465
  response = "Thank you for your message. A support representative will respond shortly.";
466
  }
 
517
  <div
518
  className={`max-w-xs md:max-w-md rounded-lg p-3 ${
519
  msg.sender === 'user'
520
+ ? 'bg-green-100 text-gray-800 rounded-br-none'
521
  : msg.isAI
522
+ ? 'bg-amber-50 text-gray-800 rounded-bl-none border border-amber-200'
523
+ : 'bg-blue-50 text-gray-800 rounded-bl-none border border-blue-200'
524
  }`}
525
  >
526
  <p>{msg.text}</p>
 
575
  onClick={() => setAiMode(!aiMode)}
576
  className="text-xs flex items-center px-2 py-1 rounded-full transition-colors"
577
  style={{
578
+ backgroundColor: aiMode ? 'rgba(16, 185, 129, 0.1)' : 'rgba(245, 158, 11, 0.1)',
579
+ color: aiMode ? 'rgb(16, 185, 129)' : 'rgb(245, 158, 11)'
580
+ }}
581
  >
582
  <i data-feather={aiMode ? "cpu" : "user"} className="w-3 h-3 mr-1"></i>
583
  {aiMode ? 'AI Mode' : 'Support'}
 
713
  // Render the app
714
  ReactDOM.render(<App />, document.getElementById('root'));
715
  </script>
716
+ <script src="https://cdn.jsdelivr.net/npm/ai-model@latest/dist/ai-model.min.js"></script>
717
+ <script>feather.replace();</script>
718
  </body>
719
  </html>