Muhammadidrees commited on
Commit
199b098
Β·
verified Β·
1 Parent(s): 7c45bf8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -25
app.py CHANGED
@@ -84,9 +84,9 @@ def analyze(
84
 
85
  system_prompt = (
86
  "You are a professional AI Medical Assistant.\n"
87
- "You must analyze demographics and the Levine biomarker panel using STRICT reference ranges.\n\n"
88
 
89
- "REFERENCE RANGES (strictly follow these):\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,18 +97,18 @@ def analyze(
97
  "- WBC: 4 – 11 K/uL\n"
98
  "- Lymphocytes: 20 – 45 %\n\n"
99
 
100
- "STRICT RULES:\n"
101
- "- For each biomarker, assign ONLY: Low, Normal, or High relative to the ranges above.\n"
102
- "- Do NOT contradict these ranges.\n"
103
- "- Only state conditions supported by biomarker patterns. Do not invent risks.\n"
104
- "- If all biomarkers are normal, explicitly say: 'No abnormalities detected.'\n"
105
- "- Interaction Alerts must only mention supported patterns (MCV+RDW, WBC+CRP, Albumin+ALP).\n\n"
 
106
 
107
  "OUTPUT FORMAT:\n"
108
  "1. Executive Summary\n"
109
- " - Top Priority Issues (if any, else state 'None detected')\n"
110
  " - Key Strengths\n\n"
111
-
112
  "2. System-Specific Analysis\n"
113
  " - Blood Health (MCV, RDW, WBC, Lymphocytes)\n"
114
  " - Protein & Liver Health (Albumin, ALP)\n"
@@ -116,30 +116,26 @@ 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
-
120
  "3. Personalized Action Plan\n"
121
- " - Medical: Suggest repeat/confirmatory tests only if abnormalities detected.\n"
122
- " - Nutrition: Only if supported by biomarker findings.\n"
123
- " - Lifestyle: General health advice contextualized by BMI.\n"
124
- " - Testing: Mention ferritin, B12, folate, etc. ONLY as follow-ups if abnormalities present.\n\n"
125
-
126
  "4. Interaction Alerts\n"
127
- " - Highlight only validated cross-biomarker relationships.\n\n"
128
-
129
  "5. Tabular Mapping\n"
130
- " - Markdown table with exactly 4 columns: | Biomarker | Value | Status | AI-Inferred Insight |\n"
131
- " - Include all 9 biomarkers, in this exact order: Albumin, Creatinine, Glucose, CRP, MCV, RDW, ALP, WBC, Lymphocytes.\n\n"
132
-
133
  "6. Enhanced AI Insights & Longitudinal Risk\n"
134
- " - Only if patterns justify, else state 'Not available from current biomarkers.'\n\n"
135
 
136
  "STYLE:\n"
137
- "- Use concise, professional medical tone.\n"
138
- "- Ensure all statements are strictly range-based and non-speculative.\n"
139
- "- No hallucinations, no extra biomarkers.\n"
140
  )
141
 
142
 
 
143
  patient_input = (
144
  f"Patient Profile:\n"
145
  f"- Age: {age}\n"
 
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"
91
  "- Creatinine: 0.6 – 1.3 mg/dL\n"
92
  "- Glucose (fasting): 70 – 99 mg/dL\n"
 
97
  "- WBC: 4 – 11 K/uL\n"
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
  " - 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"