Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -100,19 +100,16 @@ def analyze(
|
|
| 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 |
-
"- Use the reference ranges provided in the Patient Summary for all biomarker interpretations.\n"
|
| 104 |
-
"- Status (Low/Normal/High) must be defined strictly by whether the value falls below, within, or above the provided reference ranges.\n"
|
| 105 |
-
"- Analysis must always explain deviations with respect to these reference ranges.\n"
|
| 106 |
"- If a section cannot be addressed with available data, explicitly state: 'Not available from current biomarkers.'\n"
|
| 107 |
"- Do not give absolute longevity scores. Instead, summarize trends (e.g., 'No major abnormalities suggesting elevated short-term risk.').\n"
|
| 108 |
"- Nutrient status (Iron, B12, Folate) can only be suggested as possible IF supported by MCV + RDW patterns, but never stated as confirmed.\n"
|
| 109 |
"- Interpret ALP cautiously: mention bone vs liver as possible sources, but highlight that more tests would be required to confirm.\n"
|
| 110 |
"- Always highlight limitations where applicable.\n\n"
|
| 111 |
|
| 112 |
-
"OUTPUT FORMAT (strict, structured, and
|
| 113 |
|
| 114 |
"1. Executive Summary\n"
|
| 115 |
-
" - Top Priority Issues (based only on provided biomarkers
|
| 116 |
" - Key Strengths\n\n"
|
| 117 |
|
| 118 |
"2. System-Specific Analysis\n"
|
|
@@ -133,46 +130,43 @@ def analyze(
|
|
| 133 |
" - 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"
|
| 134 |
|
| 135 |
"5. Tabular Mapping\n"
|
| 136 |
-
" -
|
| 137 |
-
" -
|
| 138 |
-
" | Biomarker | Value | Status (Low/Normal/High) | Reference Range | AI-Inferred Insight |\n"
|
| 139 |
-
" - The Reference Range column must be populated with the ranges given in the Patient Summary.\n"
|
| 140 |
-
" - The first row after the header must begin directly with 'Albumin'.\n"
|
| 141 |
-
" - Do NOT add any index numbers (0,1,2...) or empty rows.\n"
|
| 142 |
-
" - Each biomarker must appear exactly once as a separate row.\n\n"
|
| 143 |
|
| 144 |
"6. Enhanced AI Insights & Longitudinal Risk\n"
|
| 145 |
-
" - Subclinical nutrient predictions ONLY if patterns (MCV + RDW) suggest it β state as possible, not confirmed
|
| 146 |
-
" - ALP interpretation limited to bone vs liver origin (uncertain without further tests)
|
| 147 |
-
" - WBC & lymphocyte balance for immunity
|
| 148 |
-
" - Risk framing: Highlight if biomarkers suggest resilience or potential stress, but avoid absolute longevity claims
|
| 149 |
|
| 150 |
"STYLE REQUIREMENTS:\n"
|
| 151 |
"- Use clear section headings and bullet points.\n"
|
| 152 |
-
"- Keep language professional
|
| 153 |
"- Format tables cleanly in Markdown.\n"
|
| 154 |
"- Present output beautifully, like a polished medical summary.\n"
|
| 155 |
)
|
| 156 |
|
| 157 |
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
|
|
|
|
|
|
| 176 |
|
| 177 |
prompt = system_prompt + "\n" + patient_input
|
| 178 |
|
|
@@ -257,4 +251,4 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 257 |
|
| 258 |
# Launch (HF Spaces expects this pattern)
|
| 259 |
if __name__ == "__main__":
|
| 260 |
-
demo.launch(server_name="0.0.0.0", server_port=int(os.environ.get("PORT", 7860)))
|
|
|
|
| 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"
|
|
|
|
| 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"
|
| 155 |
+
f"- Gender: {gender}\n"
|
| 156 |
+
f"- Height: {height} cm\n"
|
| 157 |
+
f"- Weight: {weight} kg\n"
|
| 158 |
+
f"- BMI: {bmi}\n\n"
|
| 159 |
+
"Lab Values:\n"
|
| 160 |
+
f"- Albumin: {albumin} g/dL\n"
|
| 161 |
+
f"- Creatinine: {creatinine} mg/dL\n"
|
| 162 |
+
f"- Glucose: {glucose} mg/dL\n"
|
| 163 |
+
f"- CRP: {crp} mg/L\n"
|
| 164 |
+
f"- MCV: {mcv} fL\n"
|
| 165 |
+
f"- RDW: {rdw} %\n"
|
| 166 |
+
f"- ALP: {alp} U/L\n"
|
| 167 |
+
f"- WBC: {wbc} K/uL\n"
|
| 168 |
+
f"- Lymphocytes: {lymph} %\n"
|
| 169 |
+
)
|
| 170 |
|
| 171 |
prompt = system_prompt + "\n" + patient_input
|
| 172 |
|
|
|
|
| 251 |
|
| 252 |
# Launch (HF Spaces expects this pattern)
|
| 253 |
if __name__ == "__main__":
|
| 254 |
+
demo.launch(server_name="0.0.0.0", server_port=int(os.environ.get("PORT", 7860)))
|