sanyadureja commited on
Commit
739ba1a
1 Parent(s): 4e729eb

updated app.py

Browse files

Deployed the new version

Files changed (1) hide show
  1. app.py +90 -16
app.py CHANGED
@@ -1,18 +1,52 @@
1
  import base64
 
 
2
  import streamlit as st
3
  import plotly.express as px
4
  import pandas as pd
5
  import requests, random
6
  from streamlit_lottie import st_lottie
7
  from streamlit_option_menu import option_menu
8
-
 
9
  #AI Integration
10
  import anthropic
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
- # Retrieve API key from Hugging Face secrets
13
- claude_api_key = "api-key"
 
 
 
 
14
 
15
- # Initialize ClaudeAI client
16
  client = anthropic.Client(api_key=claude_api_key)
17
 
18
  def anxiety_management_guide(mood, feeling_description, current_stress_level, recent_events):
@@ -35,8 +69,15 @@ def anxiety_management_guide(mood, feeling_description, current_stress_level, re
35
  ]
36
  )
37
 
 
38
  # Set page config (must be the first Streamlit command)
39
- st.set_page_config(page_title="Anxiety Relief App", page_icon=":relieved:", layout="centered")
 
 
 
 
 
 
40
 
41
  # Data for mental health (sampled)
42
  data = {
@@ -126,7 +167,7 @@ def main():
126
  "background-color": "rgba(0, 0, 0, 0.8)", # More opaque background
127
  "transition": "background-color 0.3s ease, transform 0.2s"
128
  },
129
- "nav-link-selected": {"background-color": "#04AA6D", "color": "#fff", "transform": "scale(1.1)"}
130
  }
131
  )
132
 
@@ -319,18 +360,33 @@ def show_main_page():
319
  st.plotly_chart(fig_selected)
320
 
321
  st.write("---")
322
- st.markdown('<p style="text-align: center;">© 2024 Anxiety Relief Platform. All rights reserved.</p>', unsafe_allow_html=True)
323
 
324
  def soothing_sounds():
325
  st.header("🎵 Calm Down with Soothing Sounds")
 
326
  sound_options = {
327
- "Rain": "https://example.com/rain_sound.mp3",
328
- "Ocean Waves": "https://example.com/ocean_waves.mp3",
329
- "Forest": "https://example.com/forest.mp3"
 
 
 
 
330
  }
331
  selected_sound = st.selectbox("Choose a sound to relax:", list(sound_options.keys()))
332
- if st.button("Play Sound"):
333
- st.audio(sound_options[selected_sound])
 
 
 
 
 
 
 
 
 
 
334
 
335
  def interactive_journal():
336
  if 'journal_entries' not in st.session_state:
@@ -386,7 +442,25 @@ def show_calm_space():
386
 
387
  if selected_challenge:
388
  st.write(f"**Today's Challenge:** {challenges[selected_challenge]}")
389
- st.write("Set a reminder to complete this challenge today. Remember, consistency is key to building habits and improving your mental well-being.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
390
 
391
  st.write("---")
392
 
@@ -423,7 +497,7 @@ def show_calm_space():
423
 
424
 
425
  st.write("---")
426
- st.markdown('<p style="text-align: center;">© 2024 Anxiety Relief Platform. All rights reserved.</p>', unsafe_allow_html=True)
427
 
428
 
429
 
@@ -432,7 +506,7 @@ def show_about_and_feedback():
432
  st.title("About Us & Feedback")
433
 
434
  st.write("""
435
- **Welcome to Our Anxiety Relief Platform!**
436
 
437
  We are dedicated to promoting mental wellness through interactive and accessible tools. Our mission is to provide a supportive environment where individuals can explore effective techniques for managing anxiety and improving overall mental well-being.
438
  """)
@@ -500,7 +574,7 @@ def show_about_and_feedback():
500
 
501
 
502
  st.write("---")
503
- st.markdown('<p style="text-align: center;">© 2024 Anxiety Relief Platform. All rights reserved.</p>', unsafe_allow_html=True)
504
 
505
 
506
 
 
1
  import base64
2
+ import datetime
3
+ import time
4
  import streamlit as st
5
  import plotly.express as px
6
  import pandas as pd
7
  import requests, random
8
  from streamlit_lottie import st_lottie
9
  from streamlit_option_menu import option_menu
10
+ import os
11
+ from dotenv import load_dotenv
12
  #AI Integration
13
  import anthropic
14
+ import datetime
15
+ import datetime
16
+ # CSS for Scroll to Top Button
17
+ scroll_to_top = """
18
+ <style>
19
+ #scrollButton {
20
+ position: fixed;
21
+ bottom: 20px;
22
+ right: 20px;
23
+ z-index: 99;
24
+ font-size: 18px;
25
+ border: none;
26
+ outline: none;
27
+ background-color: rgb(4, 170, 109);
28
+ color: white;
29
+ cursor: pointer;
30
+ padding: 10px;
31
+ border-radius: 10px;
32
+ opacity: 0.7;
33
+ }
34
+
35
+ #scrollButton:hover {
36
+ background-color: rgb(4, 170, 109);
37
+ opacity: 1;
38
+ }
39
+ </style>
40
+ """
41
+
42
 
43
+ #Changes made by --Charvi Arora
44
+ #Added security
45
+ # Load environment variables from .env file
46
+ load_dotenv()
47
+ # Retrieve the API key
48
+ claude_api_key = os.getenv("CLAUDE_API_KEY")
49
 
 
50
  client = anthropic.Client(api_key=claude_api_key)
51
 
52
  def anxiety_management_guide(mood, feeling_description, current_stress_level, recent_events):
 
69
  ]
70
  )
71
 
72
+
73
  # Set page config (must be the first Streamlit command)
74
+ st.set_page_config(page_title="SereniFi", page_icon=":relieved:", layout="centered")
75
+ st.markdown(scroll_to_top, unsafe_allow_html=True)
76
+ def scroll_to_top_button():
77
+ st.markdown('<a id="scrollButton" title="Go to top" href="#top">↑ Top</a>', unsafe_allow_html=True)
78
+ st.markdown('<div id="top"></div>', unsafe_allow_html=True)
79
+
80
+ scroll_to_top_button()
81
 
82
  # Data for mental health (sampled)
83
  data = {
 
167
  "background-color": "rgba(0, 0, 0, 0.8)", # More opaque background
168
  "transition": "background-color 0.3s ease, transform 0.2s"
169
  },
170
+ "nav-link-selected": {"background-color": "#04AA6D", "color": "#fff","font-size": "14px",}
171
  }
172
  )
173
 
 
360
  st.plotly_chart(fig_selected)
361
 
362
  st.write("---")
363
+ st.markdown('<p style="text-align: center;">© 2024 SereniFi. All rights reserved.</p>', unsafe_allow_html=True)
364
 
365
  def soothing_sounds():
366
  st.header("🎵 Calm Down with Soothing Sounds")
367
+ #Contributions made by Himanshi-M
368
  sound_options = {
369
+ "Rain": "https://cdn.pixabay.com/audio/2022/05/13/audio_257112ce99.mp3",
370
+ "Ocean Waves": "https://cdn.pixabay.com/audio/2022/06/07/audio_b9bd4170e4.mp3",
371
+ "Forest": "https://cdn.pixabay.com/audio/2022/03/10/audio_4dedf5bf94.mp3",
372
+ "Birds Chirping":"https://cdn.pixabay.com/audio/2022/03/09/audio_c610232c26.mp3",
373
+ "River Flowing":"https://cdn.pixabay.com/audio/2024/07/30/audio_319893354c.mp3",
374
+ "White Noise":"https://cdn.pixabay.com/audio/2022/03/12/audio_b4f7e5a4ff.mp3",
375
+ "Pink Noise": "https://cdn.pixabay.com/audio/2023/10/07/audio_df9c190caf.mp3"
376
  }
377
  selected_sound = st.selectbox("Choose a sound to relax:", list(sound_options.keys()))
378
+ # Organizing the button, checkbox and volume slider on the same row
379
+ col1, col2, col3 = st.columns([1,1,2])
380
+ with col1:
381
+ playbutton=st.button("Play Sound")
382
+ with col2:
383
+ # Looping Checkbox
384
+ loopcheckbox = st.checkbox("Loop Sound")
385
+
386
+ if playbutton:
387
+ # Rendering the audio player and JS in the app
388
+ with col3:
389
+ st.audio(sound_options[selected_sound], format="audio/mp3", loop=loopcheckbox)
390
 
391
  def interactive_journal():
392
  if 'journal_entries' not in st.session_state:
 
442
 
443
  if selected_challenge:
444
  st.write(f"**Today's Challenge:** {challenges[selected_challenge]}")
445
+ st.write("Remember, consistency is key to building habits and improving your mental well-being.")
446
+
447
+ #Progress Bar Feature added by suhaib-lone
448
+ if st.button("Start Progress"):
449
+ progress_bar=st.progress(0)
450
+ if selected_challenge == "Meditation" or selected_challenge == "journaling":
451
+ challenge_time=600
452
+ elif selected_challenge == "Yoga":
453
+ challenge_time=900
454
+ elif selected_challenge == "Breathing":
455
+ challenge_time=300
456
+ else:
457
+ challenge_time=1200
458
+ for i in range(challenge_time):
459
+ time.sleep(1)
460
+ progress_bar.progress((i+1)/challenge_time)
461
+ st.success("Ding! Ding! Time UP!")
462
+
463
+
464
 
465
  st.write("---")
466
 
 
497
 
498
 
499
  st.write("---")
500
+ st.markdown('<p style="text-align: center;">© 2024 SereniFi. All rights reserved.</p>', unsafe_allow_html=True)
501
 
502
 
503
 
 
506
  st.title("About Us & Feedback")
507
 
508
  st.write("""
509
+ **Welcome to SereniFi!**
510
 
511
  We are dedicated to promoting mental wellness through interactive and accessible tools. Our mission is to provide a supportive environment where individuals can explore effective techniques for managing anxiety and improving overall mental well-being.
512
  """)
 
574
 
575
 
576
  st.write("---")
577
+ st.markdown('<p style="text-align: center;">© 2024 SereniFi. All rights reserved.</p>', unsafe_allow_html=True)
578
 
579
 
580