File size: 4,339 Bytes
169a857
 
85f95e2
 
 
 
 
d6de8a6
 
 
 
 
 
 
 
 
 
85f95e2
d6de8a6
 
85f95e2
 
 
 
169a857
85f95e2
26be19c
 
 
85f95e2
26be19c
 
 
 
85f95e2
26be19c
 
 
 
 
 
 
 
 
 
8ff769b
4a36084
4ba1637
26be19c
4ba1637
92d474a
596c9cc
 
92d474a
 
26be19c
34bafcf
 
26be19c
 
 
8ff769b
26be19c
 
 
 
 
 
 
1a3054c
85f95e2
243d164
 
 
 
9088c2f
 
692edde
9088c2f
 
 
 
 
 
 
 
 
 
 
 
 
692edde
9088c2f
 
 
 
 
 
 
 
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import gradio as gr

def get_health_advice(query):
    responses = {
        "fever": "🌑️ For fever, take Paracetamol, rest well, and stay hydrated.",
        "cold": "🀧 Use steam inhalation, warm fluids, and over-the-counter cold medicine.",
        "headache": "πŸ’Š Try Ibuprofen, stay in a quiet place, and drink plenty of water.",
        "cough": "🀧 For cough, try honey and ginger tea, or use a cough suppressant if needed.",
        "stomach ache": "🍡 Drink chamomile tea or take an antacid to soothe the stomach.",
        "sore throat": "🧴 Gargle with warm salt water, and try throat lozenges or warm tea.",
        "fatigue": "πŸ’€ Rest well, stay hydrated, and eat a balanced diet to replenish energy.",
        "nausea": "πŸ₯„ Ginger tea or peppermint can help with nausea, and avoid heavy foods.",
        "dizziness": "πŸ§‘β€βš•οΈ If feeling dizzy, sit down, hydrate, and avoid sudden movements. Seek medical attention if it persists.",
        "back pain": "πŸ’ͺ Stretch and use a hot pack on the back. Over-the-counter pain relievers may help.",
        "allergy": "🀧 For mild allergies, take antihistamines or use nasal sprays for relief.",
        "hair fall": "πŸ’‡β€β™‚οΈ For hair fall, try a balanced diet, use mild shampoos, and consider consulting a dermatologist. Regular scalp massage and reducing stress may help as well.",
        "diabetes": "🍏 For diabetes, maintain a balanced diet with low sugar intake, exercise regularly, monitor blood sugar levels, and follow your doctor's advice for medication."
    }
    
    # Check if the query contains any of the conditions listed in responses
    for keyword in responses:
        if keyword in query.lower():
            return responses[keyword]
    return "⚠️ Sorry, I couldn't recognize your condition. Please consult a healthcare professional."

with gr.Blocks(css="""
    .gradio-container {
        background-color: #ffffff;
        font-family: 'Segoe UI', sans-serif;
    }
    h1 {
        color: #2ecc71;
        text-align: center;
        margin-bottom: 0;
    }
    h2 {
        color: #444;
        text-align: center;
        font-weight: normal;
        margin-top: 0;
    }
    .textbox input, .textbox textarea {
        font-size: 16px;
        padding: 12px;
        border-radius: 10px;
        border: 1px solid #ffcc80;  /* Light orange border */
        background: linear-gradient(135deg, #d1e8e2, #80cbc4);  /* Light to dark gradient background */
        color: black;  /* Change text color to black */
    }
    /* When the input field is focused (clicked), change its background to red */
    .textbox input:focus, .textbox textarea:focus {
        border-color: #ff7043;  /* Darker orange border on focus */
        background-color: #ffcccc !important;  /* Red background when focused */
        outline: none;  /* Remove default outline */
    }
    .response-box textarea {
        background-color: #e0f7fa;  /* Light blue background */
        color: #000000;  /* Black text */
        font-size: 16px;
        padding: 12px;
        border-radius: 10px;
        border: 1px solid #ffcc80;  /* Light orange border */
    }
    .submit-btn button {
        background-color: #2ecc71;
        color: white;
        font-size: 16px;
        border-radius: 10px;
        padding: 10px 24px;
        border: none;
    }
    /* Removed hover effect completely */
    .submit-btn button:hover {
        background-color: #2ecc71;  /* Same color as the button (no hover effect) */
    }
""") as demo:

    gr.Markdown("## 🩺 MediGuide")
    gr.Markdown("### Your AI Health Assistant – Ask any health-related question")

    with gr.Row():
        with gr.Column():
            user_input = gr.Textbox(
                label="Enter your health question:",
                placeholder="e.g., What medicine should I take for cold?",
                lines=3,
                elem_classes="textbox"
            )
            submit_btn = gr.Button("Get Advice", elem_classes="submit-btn")
        with gr.Column():
            output = gr.Textbox(
                label="MediGuide Advice:",
                lines=3,
                interactive=False,
                elem_classes="response-box"
            )

    submit_btn.click(fn=get_health_advice, inputs=user_input, outputs=output)

demo.launch()