File size: 2,141 Bytes
61de89b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import gradio as gr

def health_advice(weight, condition, mood):
    """
    Provide weight status and advice based on weight, condition, and mood.
    """
    try:
        weight = float(weight)
    except:
        return "Please enter a valid number for weight."

    # Determine weight status
    if weight < 50:
        weight_status = "Underweight"
    elif 50 <= weight <= 80:
        weight_status = "Normal"
    else:
        weight_status = "Overweight/Critical"

    # Advice based on mood and condition
    advice = ""
    
    if mood.lower() in ["happy", "good", "excited"]:
        if weight_status == "Underweight":
            advice += "You can eat protein-rich food, nuts, and maintain healthy meals.\n"
        elif weight_status == "Normal":
            advice += "Maintain your diet and continue staying active.\n"
        else:
            advice += "Focus on low-calorie, balanced meals and exercise.\n"
    elif mood.lower() in ["sad", "tired", "stressed"]:
        advice += "Try light exercise, meditate, and eat comfort foods in moderation.\n"
    else:
        advice += "Maintain a balanced diet and listen to your body.\n"

    # Add condition-based advice
    if condition.lower() in ["diabetes", "high sugar"]:
        advice += "Avoid sugary foods and monitor blood sugar levels.\n"
    elif condition.lower() in ["hypertension", "high blood pressure"]:
        advice += "Reduce salt intake and monitor blood pressure.\n"
    else:
        advice += "Follow a healthy lifestyle.\n"

    return f"Weight Status: {weight_status}\nAdvice:\n{advice}"

# Create Gradio interface
iface = gr.Interface(
    fn=health_advice,
    inputs=[
        gr.Textbox(label="Enter your weight (kg)", placeholder="e.g., 70"),
        gr.Textbox(label="Enter your condition", placeholder="e.g., healthy, diabetes"),
        gr.Textbox(label="How are you feeling today?", placeholder="e.g., happy, sad")
    ],
    outputs=gr.Textbox(label="Health Advice"),
    title="Health and Mood AI Advisor",
    description="Enter your weight, condition, and mood to get advice on your health and diet."
)

# Launch the app
iface.launch()