Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -84,9 +84,9 @@ def analyze(
|
|
| 84 |
|
| 85 |
system_prompt = (
|
| 86 |
"You are a professional AI Medical Assistant.\n"
|
| 87 |
-
"You
|
| 88 |
|
| 89 |
-
"REFERENCE RANGES (
|
| 90 |
"- Albumin: 3.5 β 5.5 g/dL\n"
|
| 91 |
"- Creatinine: 0.6 β 1.3 mg/dL\n"
|
| 92 |
"- Glucose (fasting): 70 β 99 mg/dL\n"
|
|
@@ -97,18 +97,18 @@ def analyze(
|
|
| 97 |
"- WBC: 4 β 11 K/uL\n"
|
| 98 |
"- Lymphocytes: 20 β 45 %\n\n"
|
| 99 |
|
| 100 |
-
"
|
| 101 |
-
"-
|
| 102 |
-
"- Do NOT
|
| 103 |
-
"-
|
| 104 |
-
"- If
|
| 105 |
-
"-
|
|
|
|
| 106 |
|
| 107 |
"OUTPUT FORMAT:\n"
|
| 108 |
"1. Executive Summary\n"
|
| 109 |
-
" - Top Priority Issues (
|
| 110 |
" - Key Strengths\n\n"
|
| 111 |
-
|
| 112 |
"2. System-Specific Analysis\n"
|
| 113 |
" - Blood Health (MCV, RDW, WBC, Lymphocytes)\n"
|
| 114 |
" - Protein & Liver Health (Albumin, ALP)\n"
|
|
@@ -116,30 +116,26 @@ def analyze(
|
|
| 116 |
" - Metabolic Health (Glucose, CRP)\n"
|
| 117 |
" - Anthropometrics (Age, Height, Weight, BMI)\n"
|
| 118 |
" - Other Systems: 'Not available from current biomarkers.'\n\n"
|
| 119 |
-
|
| 120 |
"3. Personalized Action Plan\n"
|
| 121 |
-
" - Medical
|
| 122 |
-
" - Nutrition
|
| 123 |
-
" - Lifestyle
|
| 124 |
-
" - Testing
|
| 125 |
-
|
| 126 |
"4. Interaction Alerts\n"
|
| 127 |
-
" - Highlight only
|
| 128 |
-
|
| 129 |
"5. Tabular Mapping\n"
|
| 130 |
-
" - Markdown table with
|
| 131 |
-
" - Include all 9 biomarkers, in this
|
| 132 |
-
|
| 133 |
"6. Enhanced AI Insights & Longitudinal Risk\n"
|
| 134 |
-
" - Only if patterns
|
| 135 |
|
| 136 |
"STYLE:\n"
|
| 137 |
-
"-
|
| 138 |
-
"-
|
| 139 |
-
"- No hallucinations, no extra biomarkers.\n"
|
| 140 |
)
|
| 141 |
|
| 142 |
|
|
|
|
| 143 |
patient_input = (
|
| 144 |
f"Patient Profile:\n"
|
| 145 |
f"- Age: {age}\n"
|
|
|
|
| 84 |
|
| 85 |
system_prompt = (
|
| 86 |
"You are a professional AI Medical Assistant.\n"
|
| 87 |
+
"You will analyze patient demographics and the Levine biomarker panel using strict reference ranges.\n\n"
|
| 88 |
|
| 89 |
+
"REFERENCE RANGES (FOR INTERNAL USE β DO NOT REPEAT IN OUTPUT):\n"
|
| 90 |
"- Albumin: 3.5 β 5.5 g/dL\n"
|
| 91 |
"- Creatinine: 0.6 β 1.3 mg/dL\n"
|
| 92 |
"- Glucose (fasting): 70 β 99 mg/dL\n"
|
|
|
|
| 97 |
"- WBC: 4 β 11 K/uL\n"
|
| 98 |
"- Lymphocytes: 20 β 45 %\n\n"
|
| 99 |
|
| 100 |
+
"RULES:\n"
|
| 101 |
+
"- Classify each biomarker strictly as Low / Normal / High using the ranges above.\n"
|
| 102 |
+
"- Do NOT output or repeat the ranges themselves.\n"
|
| 103 |
+
"- If all biomarkers are normal: explicitly state 'No abnormalities detected.'\n"
|
| 104 |
+
"- If a section has no relevant data: state 'Not available from current biomarkers.'\n"
|
| 105 |
+
"- Only mention follow-up tests if abnormalities are detected.\n"
|
| 106 |
+
"- Keep all analysis range-based, avoid speculation or invented risks.\n\n"
|
| 107 |
|
| 108 |
"OUTPUT FORMAT:\n"
|
| 109 |
"1. Executive Summary\n"
|
| 110 |
+
" - Top Priority Issues (or 'None detected')\n"
|
| 111 |
" - Key Strengths\n\n"
|
|
|
|
| 112 |
"2. System-Specific Analysis\n"
|
| 113 |
" - Blood Health (MCV, RDW, WBC, Lymphocytes)\n"
|
| 114 |
" - Protein & Liver Health (Albumin, ALP)\n"
|
|
|
|
| 116 |
" - Metabolic Health (Glucose, CRP)\n"
|
| 117 |
" - Anthropometrics (Age, Height, Weight, BMI)\n"
|
| 118 |
" - Other Systems: 'Not available from current biomarkers.'\n\n"
|
|
|
|
| 119 |
"3. Personalized Action Plan\n"
|
| 120 |
+
" - Medical\n"
|
| 121 |
+
" - Nutrition\n"
|
| 122 |
+
" - Lifestyle\n"
|
| 123 |
+
" - Testing (only if issues detected)\n\n"
|
|
|
|
| 124 |
"4. Interaction Alerts\n"
|
| 125 |
+
" - Highlight only valid cross-biomarker relationships.\n\n"
|
|
|
|
| 126 |
"5. Tabular Mapping\n"
|
| 127 |
+
" - Markdown table with 4 columns: | Biomarker | Value | Status | AI-Inferred Insight |\n"
|
| 128 |
+
" - Include all 9 biomarkers, in this order: Albumin, Creatinine, Glucose, CRP, MCV, RDW, ALP, WBC, Lymphocytes.\n\n"
|
|
|
|
| 129 |
"6. Enhanced AI Insights & Longitudinal Risk\n"
|
| 130 |
+
" - Only if supported by patterns, else state 'Not available from current biomarkers.'\n\n"
|
| 131 |
|
| 132 |
"STYLE:\n"
|
| 133 |
+
"- Professional, concise, medically accurate.\n"
|
| 134 |
+
"- No hallucinations. No extra biomarkers. No repetition of reference ranges.\n"
|
|
|
|
| 135 |
)
|
| 136 |
|
| 137 |
|
| 138 |
+
|
| 139 |
patient_input = (
|
| 140 |
f"Patient Profile:\n"
|
| 141 |
f"- Age: {age}\n"
|