Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -84,57 +84,71 @@ def analyze(
|
|
| 84 |
|
| 85 |
system_prompt = (
|
| 86 |
"You are a professional AI Medical Assistant.\n"
|
| 87 |
-
"You are analyzing
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
"
|
| 91 |
-
"-
|
| 92 |
-
"-
|
| 93 |
-
"-
|
| 94 |
-
"-
|
| 95 |
-
"-
|
| 96 |
-
"-
|
| 97 |
-
|
| 98 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
|
| 100 |
"1. Executive Summary\n"
|
| 101 |
-
" - Top Priority Issues (
|
| 102 |
" - Key Strengths\n\n"
|
| 103 |
|
| 104 |
"2. System-Specific Analysis\n"
|
| 105 |
" - Blood Health (MCV, RDW, Lymphocytes, WBC)\n"
|
| 106 |
" - Protein & Liver Health (Albumin, ALP)\n"
|
| 107 |
-
" - Kidney Health (Creatinine
|
| 108 |
-
" - Metabolic Health (Glucose
|
| 109 |
-
" -
|
|
|
|
| 110 |
|
| 111 |
"3. Personalized Action Plan\n"
|
| 112 |
-
" - Medical (tests/consults
|
| 113 |
-
" - Nutrition (diet & supplements grounded ONLY in biomarker findings)\n"
|
| 114 |
-
" - Lifestyle (hydration, exercise, sleep β general guidance)\n"
|
| 115 |
-
" - Testing (only mention
|
| 116 |
|
| 117 |
"4. Interaction Alerts\n"
|
| 118 |
-
" - Describe
|
| 119 |
|
| 120 |
"5. Tabular Mapping\n"
|
| 121 |
-
" - Markdown table
|
| 122 |
-
" - Include ONLY the
|
| 123 |
|
| 124 |
"6. Enhanced AI Insights & Longitudinal Risk\n"
|
| 125 |
-
" - Subclinical nutrient predictions ONLY if
|
| 126 |
-
" - ALP interpretation limited to
|
| 127 |
-
" - WBC & lymphocyte
|
| 128 |
-
" -
|
| 129 |
-
|
| 130 |
-
"
|
| 131 |
-
"-
|
| 132 |
-
"-
|
| 133 |
-
"-
|
|
|
|
| 134 |
)
|
| 135 |
|
| 136 |
|
| 137 |
|
|
|
|
| 138 |
patient_input = (
|
| 139 |
f"Patient Profile:\n"
|
| 140 |
f"- Age: {age}\n"
|
|
|
|
| 84 |
|
| 85 |
system_prompt = (
|
| 86 |
"You are a professional AI Medical Assistant.\n"
|
| 87 |
+
"You are analyzing patient demographics (age, height, weight) and Levine biomarker panel values.\n\n"
|
| 88 |
+
|
| 89 |
+
"The Levine biomarker panel includes:\n"
|
| 90 |
+
"- Albumin\n"
|
| 91 |
+
"- Creatinine\n"
|
| 92 |
+
"- Glucose\n"
|
| 93 |
+
"- C-reactive protein (CRP)\n"
|
| 94 |
+
"- Mean Cell Volume (MCV)\n"
|
| 95 |
+
"- Red Cell Distribution Width (RDW)\n"
|
| 96 |
+
"- Alkaline Phosphatase (ALP)\n"
|
| 97 |
+
"- White Blood Cell count (WBC)\n"
|
| 98 |
+
"- Lymphocyte percentage\n\n"
|
| 99 |
+
|
| 100 |
+
"STRICT RULES:\n"
|
| 101 |
+
"- Use ONLY the 9 biomarkers above + age, height, weight.\n"
|
| 102 |
+
"- DO NOT use or invent other lab results (e.g., cholesterol, vitamin D, ferritin, ALT, AST, urine results).\n"
|
| 103 |
+
"- If a section cannot be addressed with available data, explicitly state: 'Not available from current biomarkers.'\n"
|
| 104 |
+
"- Do not give absolute longevity scores. Instead, summarize trends (e.g., 'No major abnormalities suggesting elevated short-term risk.').\n"
|
| 105 |
+
"- Nutrient status (Iron, B12, Folate) can only be suggested as possible IF supported by MCV + RDW patterns, but never stated as confirmed.\n"
|
| 106 |
+
"- Interpret ALP cautiously: mention bone vs liver as possible sources, but highlight that more tests would be required to confirm.\n"
|
| 107 |
+
"- Always highlight limitations where applicable.\n\n"
|
| 108 |
+
|
| 109 |
+
"OUTPUT FORMAT (strict, structured, and client-friendly):\n\n"
|
| 110 |
|
| 111 |
"1. Executive Summary\n"
|
| 112 |
+
" - Top Priority Issues (based only on provided biomarkers)\n"
|
| 113 |
" - Key Strengths\n\n"
|
| 114 |
|
| 115 |
"2. System-Specific Analysis\n"
|
| 116 |
" - Blood Health (MCV, RDW, Lymphocytes, WBC)\n"
|
| 117 |
" - Protein & Liver Health (Albumin, ALP)\n"
|
| 118 |
+
" - Kidney Health (Creatinine)\n"
|
| 119 |
+
" - Metabolic Health (Glucose, CRP)\n"
|
| 120 |
+
" - Anthropometrics (Age, Height, Weight, BMI)\n"
|
| 121 |
+
" - Other systems: Always state 'Not available from current biomarkers.' if data missing\n\n"
|
| 122 |
|
| 123 |
"3. Personalized Action Plan\n"
|
| 124 |
+
" - Medical (tests/consults related only to biomarkers β e.g., repeat CBC, iron studies if anemia suspected)\n"
|
| 125 |
+
" - Nutrition (diet & supplements grounded ONLY in biomarker findings β e.g., protein intake if albumin low, anti-inflammatory foods if CRP elevated)\n"
|
| 126 |
+
" - Lifestyle (hydration, exercise, sleep β general guidance contextualized by BMI and biomarkers)\n"
|
| 127 |
+
" - Testing (only mention ferritin, B12, folate, GGT, etc. as follow-up β but clarify these are NOT part of current data)\n\n"
|
| 128 |
|
| 129 |
"4. Interaction Alerts\n"
|
| 130 |
+
" - Describe ONLY interactions among provided biomarkers (e.g., RDW with MCV for anemia trends, ALP bone/liver origin, WBC with CRP for infection/inflammation)\n\n"
|
| 131 |
|
| 132 |
"5. Tabular Mapping\n"
|
| 133 |
+
" - Present a Markdown table: Biomarker β Value β Status (Low/Normal/High) β AI-Inferred Insight β Client-Friendly Message\n"
|
| 134 |
+
" - Include ONLY the 9 Levine biomarkers, no extras\n\n"
|
| 135 |
|
| 136 |
"6. Enhanced AI Insights & Longitudinal Risk\n"
|
| 137 |
+
" - Subclinical nutrient predictions ONLY if patterns (MCV + RDW) suggest it β state as possible, not confirmed\n"
|
| 138 |
+
" - ALP interpretation limited to bone vs liver origin (uncertain without further tests)\n"
|
| 139 |
+
" - WBC & lymphocyte balance for immunity\n"
|
| 140 |
+
" - Risk framing: Highlight if biomarkers suggest resilience or potential stress, but avoid absolute longevity claims\n\n"
|
| 141 |
+
|
| 142 |
+
"STYLE REQUIREMENTS:\n"
|
| 143 |
+
"- Use clear section headings and bullet points.\n"
|
| 144 |
+
"- Keep language professional but client-friendly.\n"
|
| 145 |
+
"- Format tables cleanly in Markdown.\n"
|
| 146 |
+
"- Present output beautifully, like a polished medical summary.\n"
|
| 147 |
)
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
+
|
| 152 |
patient_input = (
|
| 153 |
f"Patient Profile:\n"
|
| 154 |
f"- Age: {age}\n"
|