SmrithiGajendran commited on
Commit
308f112
Β·
verified Β·
1 Parent(s): 1c29ec0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -40
app.py CHANGED
@@ -107,33 +107,35 @@ def respond(message, history,country):
107
  # Create a custom Gradio interface using Blocks
108
  with gr.Blocks() as demo:
109
  gr.Markdown("# 🌟 UMatter - Youth Mental Health Support Hub")
110
-
111
  with gr.Tabs():
112
-
113
-
114
- country_dropdown = gr.Dropdown(
115
- choices=[
116
- "United States",
117
- "India",
118
- "Canada",
119
- "United Kingdom",
120
- "Australia",
121
- "Germany",
122
- "France",
123
- "Japan",
124
- "Mexico",
125
- "Brazil",
126
- "South Korea"
127
- ],
128
- value="United States",
129
- label="Select Your Country"
130
- )
 
 
131
  gr.ChatInterface(
132
- fn=respond,
133
- additional_inputs=[country_dropdown],
134
- title="UMatter Chat",
135
- description="Talk to me about anything mental health 😁"
136
- )
137
  # Tab 2: Our brand new private journal space
138
  with gr.TabItem("πŸ“– My Private Journal"):
139
  gr.Markdown("### πŸ”’ Your Secure Personal Space")
@@ -162,21 +164,21 @@ with gr.Blocks() as demo:
162
 
163
  def save_journal_entry(text):
164
  if not text.strip():
165
- return gr.update(value="⚠️ Cannot save an empty entry!"), gr.update()
166
-
167
-
168
- journal_storage.append(text)
169
-
170
-
171
- preview_title = text[:20] + "..." if len(text) > 20 else text
172
-
173
- # Update the dropdown list with the new entry preview
174
- return (
175
- gr.update(value=""), # Clear the writing textbox
176
- gr.update(value="βœ… Entry saved successfully!"),
177
- gr.update(choices=journal_storage, value=text)
178
  )
179
 
 
 
 
 
 
 
 
 
 
180
 
181
 
182
  save_btn.click(
@@ -184,13 +186,12 @@ save_btn.click(
184
  inputs=journal_input,
185
  outputs=[journal_input, status_output, history_dropdown]
186
  )
187
-
188
  def view_journal_entry(selected_text):
189
  if not selected_text:
190
  return gr.update()
191
  return gr.update(value=selected_text)
192
 
193
- view_btn.click(
194
  fn=view_journal_entry,
195
  inputs=history_dropdown,
196
  outputs=journal_input
 
107
  # Create a custom Gradio interface using Blocks
108
  with gr.Blocks() as demo:
109
  gr.Markdown("# 🌟 UMatter - Youth Mental Health Support Hub")
110
+
111
  with gr.Tabs():
112
+
113
+ with gr.TabItem("πŸ’¬ Support Chat"):
114
+
115
+ country_dropdown = gr.Dropdown(
116
+ choices=[
117
+ "United States",
118
+ "India",
119
+ "Canada",
120
+ "United Kingdom",
121
+ "Australia",
122
+ "Germany",
123
+ "France",
124
+ "Japan",
125
+ "Mexico",
126
+ "Brazil",
127
+ "South Korea"
128
+ ],
129
+ value="United States",
130
+ label="Select Your Country"
131
+ )
132
+
133
  gr.ChatInterface(
134
+ fn=respond,
135
+ additional_inputs=[country_dropdown],
136
+ title="UMatter Chat",
137
+ description="Talk to me about anything mental health 😁"
138
+ )
139
  # Tab 2: Our brand new private journal space
140
  with gr.TabItem("πŸ“– My Private Journal"):
141
  gr.Markdown("### πŸ”’ Your Secure Personal Space")
 
164
 
165
  def save_journal_entry(text):
166
  if not text.strip():
167
+ return (
168
+ gr.update(),
169
+ gr.update(value="⚠️ Cannot save an empty entry!"),
170
+ gr.update()
 
 
 
 
 
 
 
 
 
171
  )
172
 
173
+ journal_storage.append(text)
174
+
175
+ preview_title = text[:20] + "..." if len(text) > 20 else text
176
+
177
+ return (
178
+ gr.update(value=""),
179
+ gr.update(value="βœ… Entry saved successfully!"),
180
+ gr.update(choices=journal_storage, value=text)
181
+ )
182
 
183
 
184
  save_btn.click(
 
186
  inputs=journal_input,
187
  outputs=[journal_input, status_output, history_dropdown]
188
  )
 
189
  def view_journal_entry(selected_text):
190
  if not selected_text:
191
  return gr.update()
192
  return gr.update(value=selected_text)
193
 
194
+ view_btn.click(
195
  fn=view_journal_entry,
196
  inputs=history_dropdown,
197
  outputs=journal_input