Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -86,41 +86,59 @@ def respond(albumin, creatinine, glucose, crp, mcv, rdw, alp, wbc, lymphocytes,
|
|
| 86 |
return completion.choices[0].message.content
|
| 87 |
|
| 88 |
|
| 89 |
-
#
|
| 90 |
-
with gr.Blocks() as demo:
|
| 91 |
-
gr.Markdown(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
|
| 93 |
with gr.Row():
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
output = gr.Textbox(label="AI Health Report", lines=30)
|
| 114 |
-
|
| 115 |
-
btn = gr.Button("Generate Report")
|
| 116 |
-
btn.click(
|
| 117 |
-
respond,
|
| 118 |
inputs=[
|
| 119 |
-
|
| 120 |
-
|
|
|
|
| 121 |
],
|
| 122 |
-
outputs=
|
| 123 |
)
|
| 124 |
|
| 125 |
-
|
| 126 |
-
|
|
|
|
| 86 |
return completion.choices[0].message.content
|
| 87 |
|
| 88 |
|
| 89 |
+
# --- Gradio Interface ---
|
| 90 |
+
with gr.Blocks(title="馃К Biomarker Medical Insight Chatbot") as demo:
|
| 91 |
+
gr.Markdown(
|
| 92 |
+
"""
|
| 93 |
+
## 馃 AI-Powered Biomarker Report Generator
|
| 94 |
+
Enter the patient details and biomarkers below.
|
| 95 |
+
The AI will generate a **comprehensive medical report** with structured insights, risk assessment, and recommendations.
|
| 96 |
+
"""
|
| 97 |
+
)
|
| 98 |
+
|
| 99 |
+
# --- Basic Info ---
|
| 100 |
+
with gr.Row():
|
| 101 |
+
age = gr.Number(label="Age", value=45)
|
| 102 |
+
gender = gr.Radio(["Male", "Female"], label="Gender", value="Male")
|
| 103 |
+
|
| 104 |
+
with gr.Row():
|
| 105 |
+
height = gr.Number(label="Height (cm)", value=175)
|
| 106 |
+
weight = gr.Number(label="Weight (kg)", value=72)
|
| 107 |
+
|
| 108 |
+
# --- Biomarkers ---
|
| 109 |
+
gr.Markdown("### 馃Й Biomarker Inputs (Demo Values Pre-filled)")
|
| 110 |
+
with gr.Row():
|
| 111 |
+
albumin = gr.Number(label="Albumin (g/dL)", value=4.2)
|
| 112 |
+
creatinine = gr.Number(label="Creatinine (mg/dL)", value=1.1)
|
| 113 |
+
glucose = gr.Number(label="Glucose (mg/dL)", value=98)
|
| 114 |
|
| 115 |
with gr.Row():
|
| 116 |
+
crp = gr.Number(label="CRP (mg/L)", value=2.5)
|
| 117 |
+
mcv = gr.Number(label="MCV (fL)", value=90.5)
|
| 118 |
+
rdw = gr.Number(label="RDW (%)", value=13.2)
|
| 119 |
+
|
| 120 |
+
with gr.Row():
|
| 121 |
+
alp = gr.Number(label="ALP (U/L)", value=110)
|
| 122 |
+
wbc = gr.Number(label="WBC (x10^3/渭L)", value=6.8)
|
| 123 |
+
lymphocytes = gr.Number(label="Lymphocytes (%)", value=35)
|
| 124 |
+
|
| 125 |
+
with gr.Row():
|
| 126 |
+
hb = gr.Number(label="Hemoglobin (g/dL)", value=14.5)
|
| 127 |
+
pv = gr.Number(label="Plasma (PV) (mL)", value=3000)
|
| 128 |
+
|
| 129 |
+
# --- Submit + Output ---
|
| 130 |
+
submit_btn = gr.Button("馃摛 Generate Medical Report")
|
| 131 |
+
output_box = gr.HTML(label="馃 AI-Generated Medical Report (Rendered in Markup)")
|
| 132 |
+
|
| 133 |
+
submit_btn.click(
|
| 134 |
+
generate_report,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 135 |
inputs=[
|
| 136 |
+
age, gender, height, weight,
|
| 137 |
+
albumin, creatinine, glucose, crp, mcv,
|
| 138 |
+
rdw, alp, wbc, lymphocytes, hb, pv
|
| 139 |
],
|
| 140 |
+
outputs=output_box
|
| 141 |
)
|
| 142 |
|
| 143 |
+
demo.launch()
|
| 144 |
+
|