Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -82,56 +82,59 @@ def analyze(
|
|
| 82 |
except Exception:
|
| 83 |
bmi = "N/A"
|
| 84 |
|
| 85 |
-
# Structured system prompt (no estimates; follow sections exactly)
|
| 86 |
system_prompt = (
|
| 87 |
"You are a professional AI Medical Assistant.\n"
|
| 88 |
-
"You are analyzing patient demographics (age, height, weight) and Levine biomarker panel values.\n"
|
| 89 |
-
"
|
| 90 |
-
|
| 91 |
-
"
|
| 92 |
-
"-
|
| 93 |
-
"-
|
| 94 |
-
"-
|
| 95 |
-
"- Do not
|
| 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 µmol/L)\n"
|
| 108 |
" - Metabolic Health (Glucose mmol/L, CRP)\n"
|
| 109 |
-
" - Other
|
| 110 |
-
|
| 111 |
"3. Personalized Action Plan\n"
|
| 112 |
-
" - Medical (tests/consults
|
| 113 |
-
" - Nutrition (diet & supplements
|
| 114 |
-
" - Lifestyle (hydration, exercise, sleep
|
| 115 |
-
" - Testing (follow-up
|
| 116 |
-
|
| 117 |
"4. Interaction Alerts\n"
|
| 118 |
-
" -
|
| 119 |
-
|
| 120 |
"5. Tabular Mapping\n"
|
| 121 |
-
" -
|
| 122 |
-
|
|
|
|
| 123 |
"6. Enhanced AI Insights & Longitudinal Risk\n"
|
| 124 |
-
" - Subclinical nutrient predictions
|
| 125 |
-
" -
|
| 126 |
" - WBC & lymphocyte trends for immunity\n"
|
| 127 |
-
" - Predictive longevity risk profile limited to trends in
|
| 128 |
-
|
| 129 |
-
"
|
| 130 |
-
"- Never hallucinate
|
| 131 |
-
"- Always state
|
|
|
|
| 132 |
)
|
| 133 |
|
| 134 |
|
|
|
|
| 135 |
patient_input = (
|
| 136 |
f"Patient Profile:\n"
|
| 137 |
f"- Age: {age}\n"
|
|
|
|
| 82 |
except Exception:
|
| 83 |
bmi = "N/A"
|
| 84 |
|
|
|
|
| 85 |
system_prompt = (
|
| 86 |
"You are a professional AI Medical Assistant.\n"
|
| 87 |
+
"You are analyzing ONLY patient demographics (age, height, weight) and Levine biomarker panel values.\n"
|
| 88 |
+
"The Levine biomarker panel includes: Albumin, Creatinine, Glucose, CRP, MCV, RDW, ALP, WBC, and Lymphocyte %.\n\n"
|
| 89 |
+
|
| 90 |
+
"STRICT RULES (NO HALLUCINATIONS):\n"
|
| 91 |
+
"- Use ONLY the above 9 biomarkers plus age, height, weight.\n"
|
| 92 |
+
"- DO NOT invent or assume values for labs not provided (e.g., cholesterol, triglycerides, HDL/LDL, vitamin D, ferritin, hormones, ALT, AST, GGT).\n"
|
| 93 |
+
"- If a requested marker or system cannot be evaluated with given data, explicitly state: 'Not available from current biomarkers.'\n"
|
| 94 |
+
"- Do not provide absolute longevity predictions. Instead, phrase as: 'No major abnormalities in biomarkers that would suggest elevated short-term risk.'\n"
|
| 95 |
+
"- Nutrient deficiencies (iron, B12, folate, copper) may ONLY be suggested as possibilities IF supported by MCV and RDW patterns, not stated as fact.\n"
|
| 96 |
+
"- Interpret ALP cautiously: mention bone vs liver origin as possibilities, but state that further tests are required for confirmation.\n"
|
| 97 |
+
|
| 98 |
+
"OUTPUT FORMAT (strictly follow, no extra commentary):\n\n"
|
| 99 |
+
|
| 100 |
"1. Executive Summary\n"
|
| 101 |
+
" - Top Priority Issues (from provided biomarkers only)\n"
|
| 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 µmol/L)\n"
|
| 108 |
" - Metabolic Health (Glucose mmol/L, CRP)\n"
|
| 109 |
+
" - Other systems: Always state 'Not available from current biomarkers' if data missing\n\n"
|
| 110 |
+
|
| 111 |
"3. Personalized Action Plan\n"
|
| 112 |
+
" - Medical (tests/consults limited to follow-up labs relevant to Levine biomarkers)\n"
|
| 113 |
+
" - Nutrition (diet & supplements grounded ONLY in biomarker findings)\n"
|
| 114 |
+
" - Lifestyle (hydration, exercise, sleep — general guidance)\n"
|
| 115 |
+
" - Testing (only mention: ferritin, vitamin D, GGT, or related labs as follow-up — but clarify these are NOT available in current data)\n\n"
|
| 116 |
+
|
| 117 |
"4. Interaction Alerts\n"
|
| 118 |
+
" - Describe only interactions among the provided biomarkers (e.g., anemia ↔ infection cycle, ALP bone/liver uncertainty)\n\n"
|
| 119 |
+
|
| 120 |
"5. Tabular Mapping\n"
|
| 121 |
+
" - Markdown table with columns: Biomarker → Value → Status (Low/Normal/High) → AI-Inferred Insight → Client-Friendly Message\n"
|
| 122 |
+
" - Include ONLY the provided biomarkers, no extras\n\n"
|
| 123 |
+
|
| 124 |
"6. Enhanced AI Insights & Longitudinal Risk\n"
|
| 125 |
+
" - Subclinical nutrient predictions ONLY if suggested by MCV/RDW trends (must be cautious)\n"
|
| 126 |
+
" - ALP interpretation limited to possible bone vs liver origin, with limitation statement\n"
|
| 127 |
" - WBC & lymphocyte trends for immunity\n"
|
| 128 |
+
" - Predictive longevity risk profile limited to trends in biomarkers (avoid absolute statements)\n\n"
|
| 129 |
+
|
| 130 |
+
"FINAL REMINDERS:\n"
|
| 131 |
+
"- Never hallucinate or invent data.\n"
|
| 132 |
+
"- Always explicitly state when data is 'Not available from current biomarkers.'\n"
|
| 133 |
+
"- Keep language professional, structured, and client-friendly.\n"
|
| 134 |
)
|
| 135 |
|
| 136 |
|
| 137 |
+
|
| 138 |
patient_input = (
|
| 139 |
f"Patient Profile:\n"
|
| 140 |
f"- Age: {age}\n"
|