dizzafizza1 commited on
Commit
d478935
1 Parent(s): 94ac879

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +46 -1
app.py CHANGED
@@ -1,6 +1,10 @@
1
  import streamlit as st
2
  import datetime
3
  import time
 
 
 
 
4
 
5
  # Task Management
6
  tasks = []
@@ -173,6 +177,45 @@ def resources():
173
  unsafe_allow_html=True,
174
  )
175
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
176
  def main():
177
  st.set_page_config(page_title="ADHD Toolkit", layout="wide")
178
 
@@ -196,7 +239,7 @@ def main():
196
  """,
197
  unsafe_allow_html=True,
198
  )
199
- menu = ["Home", "Task Management", "Time Management", "Habit Tracking", "Workplace Strategies", "Resources"]
200
  choice = st.sidebar.selectbox("Select a section", menu)
201
 
202
  # Set up main content area
@@ -234,6 +277,8 @@ def main():
234
  workplace_strategies()
235
  elif choice == "Resources":
236
  resources()
 
 
237
 
238
  if __name__ == "__main__":
239
  main()
 
1
  import streamlit as st
2
  import datetime
3
  import time
4
+ import openai
5
+
6
+ # Set up OpenAI API key
7
+ openai.api_key = os.environ.get("OPENAI_API_KEY")
8
 
9
  # Task Management
10
  tasks = []
 
177
  unsafe_allow_html=True,
178
  )
179
 
180
+ # AI-based Personalization
181
+ def get_chatgpt_response(prompt):
182
+ response = openai.ChatCompletion.create(
183
+ model="gpt-3.5-turbo",
184
+ messages=[
185
+ {"role": "system", "content": "You are a helpful assistant providing personalized recommendations for managing ADHD."},
186
+ {"role": "user", "content": prompt}
187
+ ]
188
+ )
189
+ return response.choices[0].message['content'].strip()
190
+
191
+ def personalization():
192
+ st.markdown(
193
+ f"""
194
+ <div class="main">
195
+ <h2>Personalization</h2>
196
+ <p>Get personalized recommendations for managing ADHD based on your responses.</p>
197
+ </div>
198
+ """,
199
+ unsafe_allow_html=True,
200
+ )
201
+
202
+ age = st.number_input("What is your age?", min_value=1, max_value=100, value=25, step=1)
203
+ occupation = st.text_input("What is your occupation?")
204
+ challenges = st.text_area("What are the main challenges you face with ADHD?")
205
+
206
+ if st.button("Get Personalized Recommendations"):
207
+ prompt = f"I am {age} years old, working as a {occupation}. The main challenges I face with ADHD are: {challenges}. Can you provide personalized recommendations for managing ADHD in my daily life and work?"
208
+ recommendations = get_chatgpt_response(prompt)
209
+ st.markdown(
210
+ f"""
211
+ <div class="main">
212
+ <h3>Personalized Recommendations:</h3>
213
+ <p>{recommendations}</p>
214
+ </div>
215
+ """,
216
+ unsafe_allow_html=True,
217
+ )
218
+
219
  def main():
220
  st.set_page_config(page_title="ADHD Toolkit", layout="wide")
221
 
 
239
  """,
240
  unsafe_allow_html=True,
241
  )
242
+ menu = ["Home", "Task Management", "Time Management", "Habit Tracking", "Workplace Strategies", "Resources", "Personalization"]
243
  choice = st.sidebar.selectbox("Select a section", menu)
244
 
245
  # Set up main content area
 
277
  workplace_strategies()
278
  elif choice == "Resources":
279
  resources()
280
+ elif choice == "Personalization":
281
+ personalization()
282
 
283
  if __name__ == "__main__":
284
  main()