Files changed (1) hide show
  1. app.py +59 -0
app.py ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ def health_advice(weight, condition, mood):
4
+ """
5
+ Provide weight status and advice based on weight, condition, and mood.
6
+ """
7
+ try:
8
+ weight = float(weight)
9
+ except:
10
+ return "Please enter a valid number for weight."
11
+
12
+ # Determine weight status
13
+ if weight < 50:
14
+ weight_status = "Underweight"
15
+ elif 50 <= weight <= 80:
16
+ weight_status = "Normal"
17
+ else:
18
+ weight_status = "Overweight/Critical"
19
+
20
+ # Advice based on mood and condition
21
+ advice = ""
22
+
23
+ if mood.lower() in ["happy", "good", "excited"]:
24
+ if weight_status == "Underweight":
25
+ advice += "You can eat protein-rich food, nuts, and maintain healthy meals.\n"
26
+ elif weight_status == "Normal":
27
+ advice += "Maintain your diet and continue staying active.\n"
28
+ else:
29
+ advice += "Focus on low-calorie, balanced meals and exercise.\n"
30
+ elif mood.lower() in ["sad", "tired", "stressed"]:
31
+ advice += "Try light exercise, meditate, and eat comfort foods in moderation.\n"
32
+ else:
33
+ advice += "Maintain a balanced diet and listen to your body.\n"
34
+
35
+ # Add condition-based advice
36
+ if condition.lower() in ["diabetes", "high sugar"]:
37
+ advice += "Avoid sugary foods and monitor blood sugar levels.\n"
38
+ elif condition.lower() in ["hypertension", "high blood pressure"]:
39
+ advice += "Reduce salt intake and monitor blood pressure.\n"
40
+ else:
41
+ advice += "Follow a healthy lifestyle.\n"
42
+
43
+ return f"Weight Status: {weight_status}\nAdvice:\n{advice}"
44
+
45
+ # Create Gradio interface
46
+ iface = gr.Interface(
47
+ fn=health_advice,
48
+ inputs=[
49
+ gr.Textbox(label="Enter your weight (kg)", placeholder="e.g., 70"),
50
+ gr.Textbox(label="Enter your condition", placeholder="e.g., healthy, diabetes"),
51
+ gr.Textbox(label="How are you feeling today?", placeholder="e.g., happy, sad")
52
+ ],
53
+ outputs=gr.Textbox(label="Health Advice"),
54
+ title="Health and Mood AI Advisor",
55
+ description="Enter your weight, condition, and mood to get advice on your health and diet."
56
+ )
57
+
58
+ # Launch the app
59
+ iface.launch()