Muhammadidrees commited on
Commit
9a82969
·
verified ·
1 Parent(s): aaa2d4c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -12
app.py CHANGED
@@ -20,43 +20,39 @@ def analyze(
20
  except Exception:
21
  bmi = "N/A"
22
 
23
- # System-style instruction (non-medical)
24
  system_prompt = (
25
  """You are a wellness assistant.
26
  Do NOT provide medical insights, diagnoses, or test recommendations.
27
- Only use neutral, non-medical, wellness-oriented language (e.g., energy, balance, recovery, nutrition).
28
- Strictly follow the structure below and generate only these sections with no extra headings:
 
 
29
 
30
  Executive Summary
31
  - Longevity Vitality Score (out of 100)
32
  - Top Priority Areas for Optimization
33
  - Key Strengths
34
-
35
  2. System-Specific Overview
36
  - Blood & Energy Balance (MCV, RDW, WBC, Lymphocytes)
37
  - Protein & Recovery (Albumin, ALP)
38
  - Hydration & Recovery (Creatinine)
39
  - Energy Metabolism (Glucose, lnCRP)
40
- - Nutrient & Wellness Factors (Vitamin D, Iron, Copper, B12)
41
-
42
  3. Personalized Action Plan (Non-Medical)
43
  - General Recommendations (hydration, exercise, sleep, nutrition tracking)
44
  - Nutrient Balance (dietary diversity, protein adequacy, micronutrient-rich foods)
45
  - Lifestyle Optimization (stress management, movement, sleep patterns)
46
  - Monitoring (re-check certain markers over time for trends)
47
-
48
  4. Biomarker Interactions
49
  - How values relate to energy, recovery, and resilience (non-medical framing)
50
-
51
  5. Longevity Metrics
52
  - Vitality Performance Score
53
  - Energy, Recovery & Cognitive Trajectory
54
-
55
  6. Enhanced AI Insights & Longitudinal Trends
56
  - Predicted nutrient needs (iron, B12, folate, copper) framed as optimization
57
  - Patterns in WBC/lymphocyte values for general resilience
58
  - Predictive wellness trends (non-medical)
59
- """
60
  )
61
 
62
  # Construct profile input
@@ -85,12 +81,19 @@ Lab Values:
85
  # Call LLM
86
  result = pipe(
87
  prompt,
88
- max_new_tokens=1200,
89
  do_sample=True,
90
  temperature=0.6,
91
  return_full_text=False
92
  )
93
- return result[0]["generated_text"].strip()
 
 
 
 
 
 
 
94
 
95
  # Build Gradio UI
96
  with gr.Blocks() as demo:
 
20
  except Exception:
21
  bmi = "N/A"
22
 
23
+ # System-style instruction (non-medical, fixed headings)
24
  system_prompt = (
25
  """You are a wellness assistant.
26
  Do NOT provide medical insights, diagnoses, or test recommendations.
27
+ Only use neutral, non-medical, wellness-oriented language
28
+ (e.g., energy, balance, recovery, nutrition).
29
+
30
+ Strictly follow this structure, and start directly with "Executive Summary":
31
 
32
  Executive Summary
33
  - Longevity Vitality Score (out of 100)
34
  - Top Priority Areas for Optimization
35
  - Key Strengths
 
36
  2. System-Specific Overview
37
  - Blood & Energy Balance (MCV, RDW, WBC, Lymphocytes)
38
  - Protein & Recovery (Albumin, ALP)
39
  - Hydration & Recovery (Creatinine)
40
  - Energy Metabolism (Glucose, lnCRP)
 
 
41
  3. Personalized Action Plan (Non-Medical)
42
  - General Recommendations (hydration, exercise, sleep, nutrition tracking)
43
  - Nutrient Balance (dietary diversity, protein adequacy, micronutrient-rich foods)
44
  - Lifestyle Optimization (stress management, movement, sleep patterns)
45
  - Monitoring (re-check certain markers over time for trends)
 
46
  4. Biomarker Interactions
47
  - How values relate to energy, recovery, and resilience (non-medical framing)
 
48
  5. Longevity Metrics
49
  - Vitality Performance Score
50
  - Energy, Recovery & Cognitive Trajectory
 
51
  6. Enhanced AI Insights & Longitudinal Trends
52
  - Predicted nutrient needs (iron, B12, folate, copper) framed as optimization
53
  - Patterns in WBC/lymphocyte values for general resilience
54
  - Predictive wellness trends (non-medical)
55
+ """
56
  )
57
 
58
  # Construct profile input
 
81
  # Call LLM
82
  result = pipe(
83
  prompt,
84
+ max_new_tokens=3000,
85
  do_sample=True,
86
  temperature=0.6,
87
  return_full_text=False
88
  )
89
+
90
+ # Force output to start from "Executive Summary"
91
+ output_text = result[0]["generated_text"].strip()
92
+ if "Executive Summary" in output_text:
93
+ output_text = output_text.split("Executive Summary", 1)[-1]
94
+ output_text = "Executive Summary" + output_text
95
+
96
+ return output_text
97
 
98
  # Build Gradio UI
99
  with gr.Blocks() as demo: