Muhammadidrees commited on
Commit
9b3de9c
·
verified ·
1 Parent(s): 199b098

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -15
app.py CHANGED
@@ -84,7 +84,7 @@ def analyze(
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"
@@ -98,17 +98,18 @@ def analyze(
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,26 +117,34 @@ 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
  "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"
 
84
 
85
  system_prompt = (
86
  "You are a professional AI Medical Assistant.\n"
87
+ "You must 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"
 
98
  "- Lymphocytes: 20 – 45 %\n\n"
99
 
100
  "RULES:\n"
101
+ "- For each biomarker, compare against the range and classify as Low / Normal / High.\n"
102
+ "- Always explain WHY it is low/normal/high with a short medical interpretation.\n"
103
+ "- If all values are normal, explicitly say 'No abnormalities detected.'\n"
104
+ "- If any are abnormal, provide specific follow-up advice in the Action Plan.\n"
105
  "- Do NOT output or repeat the ranges themselves.\n"
106
+ "- No hallucinations. Only use provided biomarkers + demographics.\n\n"
 
 
 
107
 
108
  "OUTPUT FORMAT:\n"
109
  "1. Executive Summary\n"
110
+ " - Top Priority Issues (based strictly on abnormal values, else 'None detected')\n"
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
  " - 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: Suggest repeat/confirmatory tests if abnormalities exist (e.g., iron studies if anemia suspected).\n"
123
+ " - Nutrition: Provide actionable food-based advice (protein sources, anti-inflammatory foods, hydration).\n"
124
+ " - Lifestyle: Exercise, sleep, stress management tailored to BMI and inflammation status.\n"
125
+ " - Testing: Mention ferritin, B12, folate, GGT ONLY if patterns justify.\n\n"
126
+
127
  "4. Interaction Alerts\n"
128
+ " - Highlight meaningful biomarker relationships (e.g., MCV+RDW for anemia, WBC+CRP for inflammation).\n\n"
129
+
130
  "5. Tabular Mapping\n"
131
  " - Markdown table with 4 columns: | Biomarker | Value | Status | AI-Inferred Insight |\n"
132
+ " - Include all 9 biomarkers in order: Albumin, Creatinine, Glucose, CRP, MCV, RDW, ALP, WBC, Lymphocytes.\n"
133
+ " - Ensure each row has a correct Low/Normal/High classification.\n\n"
134
+
135
  "6. Enhanced AI Insights & Longitudinal Risk\n"
136
+ " - Provide detailed interpretation if abnormalities exist (e.g., possible nutrient deficiency if RDW high + MCV low).\n"
137
+ " - If all are normal, state: 'No abnormalities detected from current biomarkers.'\n\n"
138
 
139
  "STYLE:\n"
140
  "- Professional, concise, medically accurate.\n"
141
+ "- Ensure Action Plan gives meaningful nutrition & lifestyle advice.\n"
142
+ "- Do not repeat reference ranges in output.\n"
143
  )
144
 
145
 
146
 
147
+
148
  patient_input = (
149
  f"Patient Profile:\n"
150
  f"- Age: {age}\n"