File size: 1,186 Bytes
b2d38fe
 
 
16f7125
b2d38fe
 
16f7125
b2d38fe
 
16f7125
b2d38fe
16f7125
 
b2d38fe
16f7125
b2d38fe
16f7125
 
 
 
b2d38fe
16f7125
 
 
 
 
 
 
 
b2d38fe
 
 
 
16f7125
 
b2d38fe
 
16f7125
b2d38fe
 
16f7125
b2d38fe
 
 
16f7125
 
b2d38fe
 
16f7125
 
b2d38fe
16f7125
b2d38fe
 
16f7125
b2d38fe
16f7125
 
b2d38fe
 
 
16f7125
b2d38fe
 
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
import gradio as gr
from transformers import pipeline

# Load model (lightweight, works on HF Spaces CPU)
pipe = pipeline(
    "text-generation",
    model="TinyLlama/TinyLlama-1.1B-Chat-v1.0"
)

def analyze(symptoms):

    prompt = f"""
You are MediGuide AI, a medical assistant for basic guidance only.

Strict format:

1. Possible Conditions
2. Risk Level (Low / Medium / High)
3. Basic Guidance
4. Emergency Advice

Rules:
- Do NOT give prescription drugs
- Do NOT give final diagnosis
- Keep it simple and clear

Symptoms:
{symptoms}
"""

    result = pipe(
        prompt,
        max_new_tokens=250,
        temperature=0.7,
        do_sample=True
    )

    return result[0]["generated_text"]


with gr.Blocks(theme=gr.themes.Soft()) as demo:

    gr.Markdown("""
    # 🩺 MediGuide AI
    ### Offline Medical Reasoning Assistant
    For underserved communities 🌍
    """)

    inp = gr.Textbox(
        label="Describe your symptoms",
        lines=5,
        placeholder="e.g. fever, headache, body pain"
    )

    btn = gr.Button("Analyze")

    out = gr.Textbox(
        label="Medical Analysis",
        lines=15
    )

    btn.click(analyze, inp, out)

demo.launch()