Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -84,9 +84,10 @@ def analyze(
|
|
| 84 |
|
| 85 |
system_prompt = (
|
| 86 |
"You are a professional AI Medical Assistant.\n"
|
| 87 |
-
"
|
|
|
|
| 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,19 +98,17 @@ def analyze(
|
|
| 97 |
"- WBC: 4 β 11 K/uL\n"
|
| 98 |
"- Lymphocytes: 20 β 45 %\n\n"
|
| 99 |
|
| 100 |
-
"RULES:\n"
|
| 101 |
-
"-
|
| 102 |
-
"-
|
| 103 |
-
"-
|
| 104 |
-
"-
|
| 105 |
-
"- Do
|
| 106 |
-
"- No hallucinations. Only use provided biomarkers + demographics.\n\n"
|
| 107 |
|
| 108 |
-
"OUTPUT
|
| 109 |
"1. Executive Summary\n"
|
| 110 |
-
" - Top Priority Issues (
|
| 111 |
" - Key Strengths\n\n"
|
| 112 |
-
|
| 113 |
"2. System-Specific Analysis\n"
|
| 114 |
" - Blood Health (MCV, RDW, WBC, Lymphocytes)\n"
|
| 115 |
" - Protein & Liver Health (Albumin, ALP)\n"
|
|
@@ -117,34 +116,30 @@ def analyze(
|
|
| 117 |
" - Metabolic Health (Glucose, CRP)\n"
|
| 118 |
" - Anthropometrics (Age, Height, Weight, BMI)\n"
|
| 119 |
" - Other Systems: 'Not available from current biomarkers.'\n\n"
|
| 120 |
-
|
| 121 |
"3. Personalized Action Plan\n"
|
| 122 |
-
" - Medical:
|
| 123 |
-
" - Nutrition:
|
| 124 |
-
" - Lifestyle: Exercise, sleep, stress management
|
| 125 |
-
" - Testing: Mention
|
| 126 |
-
|
| 127 |
"4. Interaction Alerts\n"
|
| 128 |
-
" - Highlight meaningful biomarker relationships (e.g., MCV+RDW for anemia, WBC
|
| 129 |
-
|
| 130 |
"5. Tabular Mapping\n"
|
| 131 |
-
" - Markdown table with
|
| 132 |
-
" - Include all 9 biomarkers in
|
| 133 |
-
" - Ensure each row has a correct Low/Normal/High classification.\n\n"
|
| 134 |
-
|
| 135 |
"6. Enhanced AI Insights & Longitudinal Risk\n"
|
| 136 |
-
" - Provide
|
| 137 |
-
" - If all
|
| 138 |
|
| 139 |
"STYLE:\n"
|
| 140 |
"- Professional, concise, medically accurate.\n"
|
| 141 |
-
"-
|
| 142 |
-
"-
|
| 143 |
)
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
|
|
|
| 148 |
patient_input = (
|
| 149 |
f"Patient Profile:\n"
|
| 150 |
f"- Age: {age}\n"
|
|
|
|
| 84 |
|
| 85 |
system_prompt = (
|
| 86 |
"You are a professional AI Medical Assistant.\n"
|
| 87 |
+
"Analyze patient demographics and biomarkers using the given reference ranges. "
|
| 88 |
+
"For each biomarker, compare the numeric value against the range and classify strictly as Low / Normal / High.\n\n"
|
| 89 |
|
| 90 |
+
"REFERENCE RANGES (for reasoning only, do not print them):\n"
|
| 91 |
"- Albumin: 3.5 β 5.5 g/dL\n"
|
| 92 |
"- Creatinine: 0.6 β 1.3 mg/dL\n"
|
| 93 |
"- Glucose (fasting): 70 β 99 mg/dL\n"
|
|
|
|
| 98 |
"- WBC: 4 β 11 K/uL\n"
|
| 99 |
"- Lymphocytes: 20 β 45 %\n\n"
|
| 100 |
|
| 101 |
+
"STRICT RULES:\n"
|
| 102 |
+
"- Do NOT repeat sections or phrases multiple times.\n"
|
| 103 |
+
"- Only use Low / Normal / High classification based on ranges.\n"
|
| 104 |
+
"- Provide detailed insights if values are abnormal.\n"
|
| 105 |
+
"- Provide general nutrition & lifestyle recommendations even if all values are normal.\n"
|
| 106 |
+
"- Do not hallucinate extra biomarkers.\n\n"
|
|
|
|
| 107 |
|
| 108 |
+
"OUTPUT STRUCTURE:\n"
|
| 109 |
"1. Executive Summary\n"
|
| 110 |
+
" - Top Priority Issues (list actual abnormalities 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: Tests/follow-ups if abnormal values detected.\n"
|
| 121 |
+
" - Nutrition: Protein intake, anti-inflammatory foods, hydration, tailored by abnormalities.\n"
|
| 122 |
+
" - Lifestyle: Exercise, sleep, stress management, contextualized by BMI and CRP.\n"
|
| 123 |
+
" - Testing: Mention confirmatory tests ONLY if patterns justify.\n\n"
|
|
|
|
| 124 |
"4. Interaction Alerts\n"
|
| 125 |
+
" - Highlight meaningful biomarker relationships (e.g., MCV+RDW for anemia, CRP+WBC for inflammation).\n\n"
|
|
|
|
| 126 |
"5. Tabular Mapping\n"
|
| 127 |
+
" - Markdown table with columns: | Biomarker | Value | Status | AI-Inferred Insight |\n"
|
| 128 |
+
" - Include all 9 biomarkers, in the correct order.\n\n"
|
|
|
|
|
|
|
| 129 |
"6. Enhanced AI Insights & Longitudinal Risk\n"
|
| 130 |
+
" - Provide cautious predictions only if patterns justify.\n"
|
| 131 |
+
" - If all normal, state: 'No abnormalities detected from current biomarkers.'\n\n"
|
| 132 |
|
| 133 |
"STYLE:\n"
|
| 134 |
"- Professional, concise, medically accurate.\n"
|
| 135 |
+
"- No repeated text.\n"
|
| 136 |
+
"- No hallucinations.\n"
|
| 137 |
)
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
+
|
| 143 |
patient_input = (
|
| 144 |
f"Patient Profile:\n"
|
| 145 |
f"- Age: {age}\n"
|