Update app.py
Browse files
app.py
CHANGED
|
@@ -286,6 +286,13 @@ def get_prompts_by_gender(gender):
|
|
| 286 |
# updates.append(gr.update(visible=False))
|
| 287 |
# return updates
|
| 288 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 289 |
def get_prompt_from_theme(gender, theme):
|
| 290 |
return get_prompts_by_gender(gender)[theme], gr.update(visible=False)
|
| 291 |
|
|
@@ -516,10 +523,13 @@ with gr.Blocks(css=css) as demo:
|
|
| 516 |
)
|
| 517 |
|
| 518 |
show_prompts_btn.click(
|
| 519 |
-
fn=lambda: gr.update(visible=True),
|
| 520 |
-
|
| 521 |
-
|
| 522 |
outputs=theme_buttons
|
|
|
|
|
|
|
|
|
|
| 523 |
)
|
| 524 |
|
| 525 |
|
|
|
|
| 286 |
# updates.append(gr.update(visible=False))
|
| 287 |
# return updates
|
| 288 |
|
| 289 |
+
def update_theme_buttons(gender):
|
| 290 |
+
prompts = man_prompts if gender == "man" else woman_prompts
|
| 291 |
+
updates = []
|
| 292 |
+
for theme in prompts.keys():
|
| 293 |
+
updates.append(gr.update(value=theme, visible=True))
|
| 294 |
+
return updates
|
| 295 |
+
|
| 296 |
def get_prompt_from_theme(gender, theme):
|
| 297 |
return get_prompts_by_gender(gender)[theme], gr.update(visible=False)
|
| 298 |
|
|
|
|
| 523 |
)
|
| 524 |
|
| 525 |
show_prompts_btn.click(
|
| 526 |
+
# fn=lambda: gr.update(visible=True),
|
| 527 |
+
fn=update_theme_buttons,
|
| 528 |
+
inputs=gender_selector,
|
| 529 |
outputs=theme_buttons
|
| 530 |
+
).then(
|
| 531 |
+
lambda: gr.update(visible=True),
|
| 532 |
+
outputs=prompt_suggestions
|
| 533 |
)
|
| 534 |
|
| 535 |
|