Muhammadidrees commited on
Commit
261667e
Β·
verified Β·
1 Parent(s): 9b3de9c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -28
app.py CHANGED
@@ -84,9 +84,10 @@ def analyze(
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"
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
- "- 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,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: 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"
 
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"