memn commited on
Commit
95f19e3
·
verified ·
1 Parent(s): 613e0cc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -34
app.py CHANGED
@@ -62,7 +62,7 @@ st.markdown("""
62
  """, unsafe_allow_html=True)
63
 
64
  # Set title and subtitle
65
- st.title("Welcome to Your Menstrual Cycle Story")
66
  st.subheader("Align with Your Body")
67
 
68
  # Input fields for user parameters
@@ -78,7 +78,7 @@ def determine_cycle_phase(days_menstruation, days_cycle, last_period_start_date)
78
  cycle_day = (today - last_period_start_date).days % days_cycle
79
 
80
  if cycle_day < days_menstruation:
81
- return "Menstruation Phase (Winter)"
82
  elif cycle_day < days_menstruation + (days_cycle - days_menstruation) // 2:
83
  return "Follicular Phase (Spring)"
84
  elif cycle_day < days_cycle - (days_cycle - days_menstruation) // 2:
@@ -87,50 +87,44 @@ def determine_cycle_phase(days_menstruation, days_cycle, last_period_start_date)
87
  return "Luteal Phase (Autumn)"
88
 
89
  # Submit button
90
- if st.button("Generate Story"):
91
- if days_menstruation and days_cycle and mood_past_3_days and goals_next_3_months and last_period_start_date:
92
  # Determine current cycle phase
93
  current_phase = determine_cycle_phase(days_menstruation, days_cycle, last_period_start_date)
94
 
95
  # Fetch relevant information from the PDF
 
96
  if "Menstruationsphase" in pdf_text and "Ernährung" in pdf_text:
97
  phase_info = pdf_text.split("Menstruationsphase")[1].split("Ernährung")[0]
98
  else:
99
  phase_info = "I am sorry I am only an Assistant and I advise you to call an expert."
100
 
101
- # Generate the story using Hugging Face's distilgpt2
102
- input_text = (f"Welcome to a journey of understanding your body. "
103
- f"With {days_menstruation} days of menstruation in a cycle of {days_cycle} days, "
104
- f"you've experienced {mood_past_3_days} in the past three days. "
105
- f"For the next three months, your goals are {goals_next_3_months}. "
106
- f"Currently, you are in the {current_phase}. Here is some information based on your current phase: {phase_info}. "
107
- f"Let me guide you through this beautiful phase with a story.")
 
 
 
 
 
 
 
 
 
 
 
108
 
109
- story = model(input_text, max_length=200, num_return_sequences=1)[0]['generated_text']
110
- st.write(story)
111
  else:
112
  st.error("Please fill in all the fields.")
113
 
114
- # Example knowledge base information
115
- st.header("Menstrual Cycle Knowledge Base")
116
- st.write("""
117
- The menstrual cycle is a natural process that occurs in the female body to prepare for a potential pregnancy. It consists of several phases:
118
- - **Menstrual Phase:** This is the phase where the uterine lining sheds, causing bleeding.
119
- - **Follicular Phase:** The body prepares for ovulation by growing follicles in the ovaries.
120
- - **Ovulation Phase:** An egg is released from the ovary, making it the most fertile phase.
121
- - **Luteal Phase:** The body prepares for a possible pregnancy or the next menstrual cycle.
122
-
123
- **Tips for Managing Different Phases:**
124
- - **Menstrual Phase:** Rest and engage in gentle activities like reading or journaling.
125
- - **Follicular Phase:** Plan new projects and gradually increase your activity.
126
- - **Ovulation Phase:** Use your high energy for social and professional networking.
127
- - **Luteal Phase:** Focus on completing tasks and integrate stress-reducing activities like yoga.
128
-
129
- Remember, your body and cycle are unique. Embrace and understand your cycle to align better with your body's natural rhythms.
130
- """)
131
-
132
-
133
-
134
  st.header("References")
135
  st.write("""
136
- This is a beta-version of 2024-06-02 and we are happy to assist you with the updated version. Greetings Nur M. """)
 
 
 
62
  """, unsafe_allow_html=True)
63
 
64
  # Set title and subtitle
65
+ st.title("Welcome to Your Menstrual Cycle Tracker")
66
  st.subheader("Align with Your Body")
67
 
68
  # Input fields for user parameters
 
78
  cycle_day = (today - last_period_start_date).days % days_cycle
79
 
80
  if cycle_day < days_menstruation:
81
+ return "Menstrual Phase (Winter)"
82
  elif cycle_day < days_menstruation + (days_cycle - days_menstruation) // 2:
83
  return "Follicular Phase (Spring)"
84
  elif cycle_day < days_cycle - (days_cycle - days_menstruation) // 2:
 
87
  return "Luteal Phase (Autumn)"
88
 
89
  # Submit button
90
+ if st.button("Tell Me About My Cycle"):
91
+ if days_menstruation and days_cycle and last_period_start_date:
92
  # Determine current cycle phase
93
  current_phase = determine_cycle_phase(days_menstruation, days_cycle, last_period_start_date)
94
 
95
  # Fetch relevant information from the PDF
96
+ phase_info = ""
97
  if "Menstruationsphase" in pdf_text and "Ernährung" in pdf_text:
98
  phase_info = pdf_text.split("Menstruationsphase")[1].split("Ernährung")[0]
99
  else:
100
  phase_info = "I am sorry I am only an Assistant and I advise you to call an expert."
101
 
102
+ # Display current phase information
103
+ st.subheader(f"Current Phase: {current_phase}")
104
+ st.write(phase_info)
105
+
106
+ # Knowledge base information
107
+ st.header("Menstrual Cycle Knowledge Base")
108
+ st.write("""
109
+ The menstrual cycle is a natural process that occurs in the female body to prepare for a potential pregnancy. It consists of several phases:
110
+ - **Menstrual Phase:** This is the phase where the uterine lining sheds, causing bleeding.
111
+ - **Follicular Phase:** The body prepares for ovulation by growing follicles in the ovaries.
112
+ - **Ovulation Phase:** An egg is released from the ovary, making it the most fertile phase.
113
+ - **Luteal Phase:** The body prepares for a possible pregnancy or the next menstrual cycle.
114
+
115
+ **Tips for Managing Different Phases:**
116
+ - **Menstrual Phase:** Rest and engage in gentle activities like reading or journaling.
117
+ - **Follicular Phase:** Plan new projects and gradually increase your activity.
118
+ - **Ovulation Phase:** Use your high energy for social and professional networking.
119
+ - **Luteal Phase:** Focus on completing tasks and integrate stress-reducing activities like yoga.
120
 
121
+ Remember, your body and cycle are unique. Embrace and understand your cycle to align better with your body's natural rhythms.
122
+ """)
123
  else:
124
  st.error("Please fill in all the fields.")
125
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
  st.header("References")
127
  st.write("""
128
+ This is a beta-version of 2024-06-02 and we are happy to assist you with the updated version.
129
+ Greetings Nur M.
130
+ """)