VaneshDev commited on
Commit
169a857
Β·
verified Β·
1 Parent(s): 0b08436

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +69 -0
app.py CHANGED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ # Function to provide health advice based on input
4
+ def health_bot(text):
5
+ text = text.lower()
6
+
7
+ if any(word in text for word in ["fever", "temperature", "high temp"]):
8
+ return (
9
+ "🩺 **Fever Advice**\n"
10
+ "- Take Paracetamol (500mg every 4–6 hours)\n"
11
+ "- Drink water and rest\n"
12
+ "- Use cold compresses\n"
13
+ "- See a doctor if it lasts >3 days"
14
+ )
15
+ elif any(word in text for word in ["cold", "cough", "sneeze", "blocked nose"]):
16
+ return (
17
+ "🀧 **Cold & Cough Advice**\n"
18
+ "- Use Cetirizine or decongestants\n"
19
+ "- Drink warm fluids\n"
20
+ "- Steam inhalation helps\n"
21
+ "- Rest well"
22
+ )
23
+ elif "headache" in text:
24
+ return (
25
+ "πŸ’† **Headache Advice**\n"
26
+ "- Take Ibuprofen or Paracetamol\n"
27
+ "- Rest in a quiet, dark room\n"
28
+ "- Avoid screens and loud noise"
29
+ )
30
+ elif any(word in text for word in ["stomach", "abdominal", "gas", "cramps"]):
31
+ return (
32
+ "🍽️ **Stomach Pain Advice**\n"
33
+ "- Use antacids or simethicone\n"
34
+ "- Drink warm water\n"
35
+ "- Avoid oily/spicy food\n"
36
+ "- If pain is sharp or lasts long, consult a doctor"
37
+ )
38
+ elif any(word in text for word in ["throat", "sore throat", "hoarse"]):
39
+ return (
40
+ "πŸ—£οΈ **Sore Throat Advice**\n"
41
+ "- Warm salt water gargle\n"
42
+ "- Drink warm tea with honey\n"
43
+ "- Lozenges or throat spray\n"
44
+ "- See a doctor if pain is severe"
45
+ )
46
+ elif any(word in text for word in ["diarrhea", "loose motion"]):
47
+ return (
48
+ "🚽 **Diarrhea Advice**\n"
49
+ "- Take ORS (oral rehydration salts)\n"
50
+ "- Avoid dairy and oily food\n"
51
+ "- Use Loperamide if needed\n"
52
+ "- Stay hydrated"
53
+ )
54
+ else:
55
+ return (
56
+ "❓ Sorry, I don't have advice for that yet.\n"
57
+ "Try asking about: fever, cold, cough, headache, stomach pain, sore throat, diarrhea."
58
+ )
59
+
60
+ # Gradio UI
61
+ demo = gr.Interface(
62
+ fn=health_bot,
63
+ inputs=gr.Textbox(label="Ask your health question"),
64
+ outputs=gr.Markdown(label="Advice"),
65
+ title="🧠 Smart Health Advisor",
66
+ description="Ask about common issues: fever, cold, stomach pain, etc. Get quick, simple advice. Not a substitute for a real doctor!"
67
+ )
68
+
69
+ demo.launch()