allyyy commited on
Commit
6811eb5
·
verified ·
1 Parent(s): d6f5794

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +42 -28
app.py CHANGED
@@ -9,7 +9,7 @@ os.environ["TOKENIZERS_PARALLELISM"] = "false"
9
  filename = "output_topic_details.txt" # Path to the file storing destress-specific details
10
  retrieval_model_name = 'output/sentence-transformer-finetuned/'
11
 
12
- openai.api_key = os.environ["OPENAI_API_KEY"]
13
 
14
  system_message = "You are a comfort chatbot specialized in providing information on therapy, destressing activites, and student opportunities."
15
  # Initial system message to set the behavior of the assistant
@@ -90,7 +90,7 @@ def generate_response(user_query, relevant_segment):
90
  output_text = response['choices'][0]['message']['content'].strip()
91
 
92
  # Append assistant's message to messages list for context
93
- messages.append({"role": "assistant", "content": user_message})
94
 
95
  return output_text
96
 
@@ -116,31 +116,17 @@ iframe = '''
116
  '''
117
 
118
  iframe2 = '''
119
- <iframe style="border-radius:12px" src="https://open.spotify.com/embed/playlist/6wwxTePuIKYMqt6RCytB7X?utm_source=generator" width="100%" height="352" frameBorder="0" allowfullscreen="" allow="autoplay; clipboard-write; encrypted-media; fullscreen; picture-in-picture" loading="lazy"></iframe>
120
  '''
121
 
122
 
123
  # Define the welcome message and specific topics the chatbot can provide information about
124
  welcome_message = """
125
  # 🪷 Welcome to CalmConnect! 🪷
126
-
127
  ## Your AI-driven assistant for destressing and extracurricular opportunity queries. Created by Olivia W, Alice T, and Cindy W of the 2024 Kode With Klossy CITY Camp.
128
  """
129
 
130
  topics = """
131
-
132
- ### Feel Free to ask CalmBot (Our Therapist Bot) anything from the topics below!
133
- - Arts and Crafts (When asking for arts and crafts ideas, state whether you have 15 min, 30 min, 45 min, 1 hour, 1 hour and a half, 2 hours, 2 hours and a half, 3 hours or greater)
134
- - Destressing strategies (Breathing Exercises, stretches, etc.)
135
- - Mental Health
136
- - Identity (Sexual, Gender, etc.)
137
- - Bullying
138
- - Racism
139
- - Relationships (Family, Friends, etc.)
140
- - Abuse (Emotional, Physical, Sexual, Mental, etc.)
141
- - Support Resources
142
-
143
-
144
  ### If you are interested in the following below, click on our Student Opportunities Database!
145
  - Engineering
146
  - Technology / Computer Science
@@ -157,6 +143,20 @@ topics = """
157
  - Volunteering
158
  - Study Abroad
159
  """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
160
  # Create a Gradio HTML component
161
  def display_iframe():
162
  return iframe
@@ -182,20 +182,34 @@ theme = gr.themes.Monochrome(
182
 
183
  # Setup the Gradio Blocks interface with custom layout components
184
  with gr.Blocks(theme=theme) as demo:
 
185
  gr.Markdown(welcome_message) # Display the formatted welcome message
186
  with gr.Row():
187
- with gr.Row():
188
  gr.Markdown(topics) # Show the topics on the left side
189
- gr.HTML(display_iframe()) # Embed the iframe on the left side
190
- gr.HTML(display_iframe2())
191
- with gr.Row():
192
- with gr.Column():
193
- question = gr.Textbox(label="Your Request", placeholder="What would you like to talk about?")
194
- answer = gr.Textbox(label="CalmBot's Response", placeholder="CalmBot will respond here...", interactive=False, lines=17)
195
- submit_button = gr.Button("Submit")
196
- submit_button.click(fn=query_model, inputs=question, outputs=answer)
197
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
198
 
199
 
200
  # Launch the Gradio app to allow user interaction
201
- demo.launch(share=True)
 
9
  filename = "output_topic_details.txt" # Path to the file storing destress-specific details
10
  retrieval_model_name = 'output/sentence-transformer-finetuned/'
11
 
12
+ #openai.api_key = os.environ["OPENAI_API_KEY"]
13
 
14
  system_message = "You are a comfort chatbot specialized in providing information on therapy, destressing activites, and student opportunities."
15
  # Initial system message to set the behavior of the assistant
 
90
  output_text = response['choices'][0]['message']['content'].strip()
91
 
92
  # Append assistant's message to messages list for context
93
+ messages.append({"role": "assistant", "content": output_text})
94
 
95
  return output_text
96
 
 
116
  '''
117
 
118
  iframe2 = '''
119
+ <iframe style="border-radius:12px" src="https://open.spotify.com/embed/playlist/6wwxTePuIKYMqt6RCytB7X?utm_source=generator" width="100%" height="300" frameBorder="0" allowfullscreen="" allow="autoplay; clipboard-write; encrypted-media; fullscreen; picture-in-picture" loading="lazy"></iframe>
120
  '''
121
 
122
 
123
  # Define the welcome message and specific topics the chatbot can provide information about
124
  welcome_message = """
125
  # 🪷 Welcome to CalmConnect! 🪷
 
126
  ## Your AI-driven assistant for destressing and extracurricular opportunity queries. Created by Olivia W, Alice T, and Cindy W of the 2024 Kode With Klossy CITY Camp.
127
  """
128
 
129
  topics = """
 
 
 
 
 
 
 
 
 
 
 
 
 
130
  ### If you are interested in the following below, click on our Student Opportunities Database!
131
  - Engineering
132
  - Technology / Computer Science
 
143
  - Volunteering
144
  - Study Abroad
145
  """
146
+
147
+ topics2= """
148
+ ### Feel Free to ask CalmBot (Our Therapist Bot) anything from the topics below!
149
+ - Arts and Crafts (When asking for arts and crafts ideas, state whether you have 15 min, 30 min, 45 min, 1 hour, 1 hour and a half, 2 hours, 2 hours and a half, 3 hours or greater)
150
+ - Destressing strategies (Breathing Exercises, stretches, etc.)
151
+ - Mental Health
152
+ - Identity (Sexual, Gender, etc.)
153
+ - Bullying
154
+ - Racism
155
+ - Relationships (Family, Friends, etc.)
156
+ - Abuse (Emotional, Physical, Sexual, Mental, etc.)
157
+ - Support Resources
158
+ """
159
+
160
  # Create a Gradio HTML component
161
  def display_iframe():
162
  return iframe
 
182
 
183
  # Setup the Gradio Blocks interface with custom layout components
184
  with gr.Blocks(theme=theme) as demo:
185
+ gr.Image("CalmConnect.jpg", show_label = False, show_share_button = False, show_download_button = False)
186
  gr.Markdown(welcome_message) # Display the formatted welcome message
187
  with gr.Row():
188
+ with gr.Column():
189
  gr.Markdown(topics) # Show the topics on the left side
190
+ gr.HTML(display_iframe()) # Embed the iframe on the left side
191
+ gr.HTML(display_iframe2()) # Embed the iframe on the right side
192
+ with gr.Column():
193
+ gr.Markdown(topics2) # Show the topics on the left side
194
+ with gr.Row():
195
+ with gr.Column():
196
+ question = gr.Textbox(label="You", placeholder="What do you want to talk to CalmBot about?")
197
+ answer = gr.Textbox(label="CalmBot's Response :D", placeholder="CalmBot will respond here..", interactive=False, lines=20)
198
+ submit_button = gr.Button("Submit")
199
+ submit_button.click(fn=query_model, inputs=question, outputs=answer)
200
+ with gr.Row():
201
+ big_block = gr.HTML("<button><a href='https://www.headspace.com/teens'>FREE: HEADSPACE FOR TEENS </a></button>")
202
+ big_block2 = gr.HTML("<button><a href='https://calmconnect-flower.replit.app/'>PLAY FLOWER GAME</a></button>")
203
+ big_block3 = gr.HTML("<button><a href='https://www.nyc.gov/site/doh/health/health-topics/teenspace.page'>NYC: TEENSPACE (free services)</a></button>")
204
+ big_block4 =gr.HTML("<button><a href='https://www.teenlife.com/blog/mental-health-resources-for-teens/'>TEEN MENTAL HEALTH RESOURCES (free services)</a></button>")
205
+
206
+
207
+
208
+ demo.launch()
209
+
210
+
211
+
212
 
213
 
214
  # Launch the Gradio app to allow user interaction
215
+ demo.launch(share=True)