rivapereira123 commited on
Commit
31eb794
Β·
verified Β·
1 Parent(s): 2e60899

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +49 -44
app.py CHANGED
@@ -118,30 +118,36 @@ def get_system_stats() -> str:
118
 
119
  def create_optimized_gradio_interface():
120
  with gr.Blocks(
121
- css=get_custom_css(),
 
 
 
 
 
 
 
 
 
 
 
 
 
122
  title="πŸ₯ Optimized Gaza First Aid Assistant",
123
  theme=gr.themes.Soft(primary_hue="blue", secondary_hue="green", neutral_hue="slate")
124
  ) as interface:
125
-
126
- # Track the selected role
127
  user_role = gr.State()
128
 
129
- # === STEP 1: Start Screen (Role Selection) ===
130
-
131
- with gr.Group(visible=True) as role_selection_group:
132
  role_title = gr.Markdown("### πŸ§‘β€βš•οΈ Select Your Role to Begin")
133
- with gr.Row():
134
- with gr.Column():
135
- volunteer_btn = gr.Button("πŸ™‹ I'm a Volunteer", size="lg")
136
- with gr.Column():
137
- organizer_btn = gr.Button("πŸ“‹ I'm an Event Organizer", size="lg")
138
 
139
-
140
  divider = gr.Markdown("---")
141
 
142
- # === STEP 2: Main UI (initially hidden) ===
143
  with gr.Column(visible=False) as main_ui:
144
-
145
  with gr.Row(elem_classes=["main-container"]):
146
  create_header_section()
147
 
@@ -170,7 +176,6 @@ def create_optimized_gradio_interface():
170
  with gr.Row(elem_classes=["main-container"]):
171
  create_example_scenarios(query_input)
172
 
173
- # === Interactions ===
174
  submit_btn.click(
175
  process_medical_query_with_progress,
176
  inputs=query_input,
@@ -218,45 +223,45 @@ def create_optimized_gradio_interface():
218
  outputs=stats_display
219
  )
220
 
221
- # === STEP 3: Button logic to reveal main interface ===
222
-
223
  def set_user_role(role):
224
  return (
225
- role, # set user_role state
226
  gr.update(visible=True), # show main UI
227
  gr.update(visible=False), # hide role title
228
  gr.update(visible=False), # hide volunteer_btn
229
  gr.update(visible=False), # hide organizer_btn
230
- gr.update(visible=False), # hide whole group
231
- )
232
-
233
- volunteer_btn.click(
234
- lambda: set_user_role("volunteer"),
235
- outputs=[
236
- user_role,
237
- main_ui,
238
- role_title,
239
- volunteer_btn,
240
- organizer_btn,
241
- role_selection_group
242
- ]
243
  )
244
-
245
- organizer_btn.click(
246
- lambda: set_user_role("organizer"),
247
- outputs=[
248
- user_role,
249
- main_ui,
250
- role_title,
251
- volunteer_btn,
252
- organizer_btn,
253
- role_selection_group
254
- ]
255
- )
256
-
 
 
 
 
 
 
 
 
 
 
 
 
257
  return interface
258
 
259
 
 
260
  def main():
261
  logger.info("πŸš€ Starting Optimized Gaza First Aid Assistant")
262
 
 
118
 
119
  def create_optimized_gradio_interface():
120
  with gr.Blocks(
121
+ css=get_custom_css() + """
122
+ #role-selection-box {
123
+ display: flex;
124
+ flex-direction: column;
125
+ align-items: center;
126
+ justify-content: center;
127
+ height: 90vh;
128
+ gap: 1rem;
129
+ }
130
+ .gr-button {
131
+ width: 350px;
132
+ font-size: 1.1rem;
133
+ }
134
+ """,
135
  title="πŸ₯ Optimized Gaza First Aid Assistant",
136
  theme=gr.themes.Soft(primary_hue="blue", secondary_hue="green", neutral_hue="slate")
137
  ) as interface:
138
+
 
139
  user_role = gr.State()
140
 
141
+ # Role Selection UI
142
+ with gr.Column(elem_id="role-selection-box", visible=True) as role_selection_group:
 
143
  role_title = gr.Markdown("### πŸ§‘β€βš•οΈ Select Your Role to Begin")
144
+ volunteer_btn = gr.Button("πŸ‘― I'm a Volunteer")
145
+ organizer_btn = gr.Button("πŸ“‹ I'm an Event Organizer")
 
 
 
146
 
 
147
  divider = gr.Markdown("---")
148
 
149
+ # Main UI (Hidden at first)
150
  with gr.Column(visible=False) as main_ui:
 
151
  with gr.Row(elem_classes=["main-container"]):
152
  create_header_section()
153
 
 
176
  with gr.Row(elem_classes=["main-container"]):
177
  create_example_scenarios(query_input)
178
 
 
179
  submit_btn.click(
180
  process_medical_query_with_progress,
181
  inputs=query_input,
 
223
  outputs=stats_display
224
  )
225
 
226
+ # Button Logic
 
227
  def set_user_role(role):
228
  return (
229
+ role,
230
  gr.update(visible=True), # show main UI
231
  gr.update(visible=False), # hide role title
232
  gr.update(visible=False), # hide volunteer_btn
233
  gr.update(visible=False), # hide organizer_btn
234
+ gr.update(visible=False) # hide full group
 
 
 
 
 
 
 
 
 
 
 
 
235
  )
236
+
237
+ volunteer_btn.click(
238
+ lambda: set_user_role("volunteer"),
239
+ outputs=[
240
+ user_role,
241
+ main_ui,
242
+ role_title,
243
+ volunteer_btn,
244
+ organizer_btn,
245
+ role_selection_group
246
+ ]
247
+ )
248
+
249
+ organizer_btn.click(
250
+ lambda: set_user_role("organizer"),
251
+ outputs=[
252
+ user_role,
253
+ main_ui,
254
+ role_title,
255
+ volunteer_btn,
256
+ organizer_btn,
257
+ role_selection_group
258
+ ]
259
+ )
260
+
261
  return interface
262
 
263
 
264
+
265
  def main():
266
  logger.info("πŸš€ Starting Optimized Gaza First Aid Assistant")
267