Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -224,35 +224,12 @@ def reset_inputs():
|
|
224 |
)
|
225 |
|
226 |
def update_visibility(chatbot_mode):
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
gr.update(visible=
|
231 |
-
|
232 |
-
gr.update(visible=
|
233 |
-
gr.update(visible=False), # activity_markdown
|
234 |
-
gr.update(visible=False), # activity_group
|
235 |
-
)
|
236 |
-
elif chatbot_mode == "Food/Attractions":
|
237 |
-
return (
|
238 |
-
gr.update(visible=False), # packing_markdown
|
239 |
-
gr.update(visible=False), # packing_group
|
240 |
-
gr.update(visible=True), # food_markdown
|
241 |
-
gr.update(visible=True), # food_group
|
242 |
-
gr.update(visible=True), # activity_markdown
|
243 |
-
gr.update(visible=True), # activity_group
|
244 |
-
)
|
245 |
-
else:
|
246 |
-
# Show all if chatbot_mode is empty or not specified
|
247 |
-
return (
|
248 |
-
gr.update(visible=True),
|
249 |
-
gr.update(visible=True),
|
250 |
-
gr.update(visible=True),
|
251 |
-
gr.update(visible=True),
|
252 |
-
gr.update(visible=True),
|
253 |
-
gr.update(visible=True),
|
254 |
-
)
|
255 |
-
|
256 |
|
257 |
with gr.Blocks(theme=theme) as demo:
|
258 |
with gr.Row():
|
@@ -282,8 +259,6 @@ with gr.Blocks(theme=theme) as demo:
|
|
282 |
choices=["Warm/Dry (May to October)", "Cool/Wet (November to April)"],
|
283 |
label="Season:"
|
284 |
)
|
285 |
-
|
286 |
-
gr.Markdown("### Luggage", visible = True)
|
287 |
|
288 |
with gr.Group(visible=True) as packing_group:
|
289 |
#gr.Markdown("### Luggage")
|
@@ -295,9 +270,7 @@ with gr.Blocks(theme=theme) as demo:
|
|
295 |
minimum=10, maximum=100, step=10, value=20,
|
296 |
label="What is the size of your luggage (liters)?"
|
297 |
)
|
298 |
-
|
299 |
-
gr.Markdown("### Food", visible = True)
|
300 |
-
|
301 |
with gr.Group(visible=True) as food_group:
|
302 |
#gr.Markdown("### Food")
|
303 |
food_prefs = gr.Dropdown(
|
@@ -305,28 +278,18 @@ with gr.Blocks(theme=theme) as demo:
|
|
305 |
multiselect=True,
|
306 |
label="What are your food preferences?"
|
307 |
)
|
308 |
-
|
309 |
-
|
310 |
-
gr.Markdown("### Activities", visible = True)
|
311 |
-
with gr.Group(visible=True) as activity_group:
|
312 |
#gr.Markdown("### Activities")
|
313 |
activity = gr.Dropdown(
|
314 |
choices=["Outdoor & Nature", "Indoor", "Museums", "Shopping", "Relaxation"],
|
315 |
multiselect=True,
|
316 |
label="What are your activity preferences?"
|
317 |
)
|
318 |
-
|
319 |
chatbot_mode.change(
|
320 |
fn=update_visibility,
|
321 |
inputs=[chatbot_mode],
|
322 |
-
outputs=[
|
323 |
-
packing_markdown,
|
324 |
-
packing_group,
|
325 |
-
food_markdown,
|
326 |
-
food_group,
|
327 |
-
activity_markdown,
|
328 |
-
activity_group
|
329 |
-
]
|
330 |
)
|
331 |
|
332 |
reset_btn = gr.Button("Reset All", variant="secondary")
|
|
|
224 |
)
|
225 |
|
226 |
def update_visibility(chatbot_mode):
|
227 |
+
if chatbot_mode == "Packing":
|
228 |
+
return gr.update(visible=True), gr.update(visible=False)
|
229 |
+
elif chatbot_mode == "Food/Attractions":
|
230 |
+
return gr.update(visible=False), gr.update(visible=True)
|
231 |
+
else:
|
232 |
+
return gr.update(visible=True), gr.update(visible=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
233 |
|
234 |
with gr.Blocks(theme=theme) as demo:
|
235 |
with gr.Row():
|
|
|
259 |
choices=["Warm/Dry (May to October)", "Cool/Wet (November to April)"],
|
260 |
label="Season:"
|
261 |
)
|
|
|
|
|
262 |
|
263 |
with gr.Group(visible=True) as packing_group:
|
264 |
#gr.Markdown("### Luggage")
|
|
|
270 |
minimum=10, maximum=100, step=10, value=20,
|
271 |
label="What is the size of your luggage (liters)?"
|
272 |
)
|
273 |
+
|
|
|
|
|
274 |
with gr.Group(visible=True) as food_group:
|
275 |
#gr.Markdown("### Food")
|
276 |
food_prefs = gr.Dropdown(
|
|
|
278 |
multiselect=True,
|
279 |
label="What are your food preferences?"
|
280 |
)
|
281 |
+
|
|
|
|
|
|
|
282 |
#gr.Markdown("### Activities")
|
283 |
activity = gr.Dropdown(
|
284 |
choices=["Outdoor & Nature", "Indoor", "Museums", "Shopping", "Relaxation"],
|
285 |
multiselect=True,
|
286 |
label="What are your activity preferences?"
|
287 |
)
|
288 |
+
|
289 |
chatbot_mode.change(
|
290 |
fn=update_visibility,
|
291 |
inputs=[chatbot_mode],
|
292 |
+
outputs=[packing_group, food_group]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
293 |
)
|
294 |
|
295 |
reset_btn = gr.Button("Reset All", variant="secondary")
|