Spaces:
Sleeping
Sleeping
Commit
ยท
ef89b24
1
Parent(s):
c39aa67
Add funny listener dropdown
Browse filesReplace textbox with dropdown of fun listeners:
- Just me (default, no special context)
- My confused grandmother
- A skeptical robot
- An alien visiting Earth
- A zombie (short attention span)
- A very smart fox
- A stressed CEO
- A distracted gamer
๐ค Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
app.py
CHANGED
|
@@ -161,11 +161,21 @@ def create_app():
|
|
| 161 |
)
|
| 162 |
|
| 163 |
with gr.Row():
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 169 |
)
|
| 170 |
|
| 171 |
explain_btn = gr.Button(
|
|
@@ -234,21 +244,25 @@ def create_app():
|
|
| 234 |
)
|
| 235 |
|
| 236 |
# Event handler
|
| 237 |
-
def process_and_explain(topic, persona_with_emoji, gen_audio,
|
| 238 |
# Extract persona name (remove emoji prefix)
|
| 239 |
persona_name = persona_with_emoji.split(" ", 1)[1] if " " in persona_with_emoji else persona_with_emoji
|
|
|
|
|
|
|
|
|
|
|
|
|
| 240 |
return explain_topic(topic, persona_name, audience, gen_audio)
|
| 241 |
|
| 242 |
explain_btn.click(
|
| 243 |
fn=process_and_explain,
|
| 244 |
-
inputs=[topic_input, persona_dropdown, audio_checkbox,
|
| 245 |
outputs=[explanation_output, audio_output, sources_output, steps_output, mcp_output],
|
| 246 |
)
|
| 247 |
|
| 248 |
# Also trigger on Enter key in topic input
|
| 249 |
topic_input.submit(
|
| 250 |
fn=process_and_explain,
|
| 251 |
-
inputs=[topic_input, persona_dropdown, audio_checkbox,
|
| 252 |
outputs=[explanation_output, audio_output, sources_output, steps_output, mcp_output],
|
| 253 |
)
|
| 254 |
|
|
|
|
| 161 |
)
|
| 162 |
|
| 163 |
with gr.Row():
|
| 164 |
+
# Funny listener options (don't overlap with personas)
|
| 165 |
+
listener_choices = [
|
| 166 |
+
"๐ค Just me",
|
| 167 |
+
"๐ต My confused grandmother",
|
| 168 |
+
"๐ค A skeptical robot",
|
| 169 |
+
"๐ฝ An alien visiting Earth",
|
| 170 |
+
"๐ง A zombie (short attention span)",
|
| 171 |
+
"๐ฆ A very smart fox",
|
| 172 |
+
"๐ A stressed CEO",
|
| 173 |
+
"๐ฎ A distracted gamer",
|
| 174 |
+
]
|
| 175 |
+
audience_dropdown = gr.Dropdown(
|
| 176 |
+
choices=listener_choices,
|
| 177 |
+
value=listener_choices[0],
|
| 178 |
+
label="๐ค Who's listening?",
|
| 179 |
)
|
| 180 |
|
| 181 |
explain_btn = gr.Button(
|
|
|
|
| 244 |
)
|
| 245 |
|
| 246 |
# Event handler
|
| 247 |
+
def process_and_explain(topic, persona_with_emoji, gen_audio, audience_with_emoji):
|
| 248 |
# Extract persona name (remove emoji prefix)
|
| 249 |
persona_name = persona_with_emoji.split(" ", 1)[1] if " " in persona_with_emoji else persona_with_emoji
|
| 250 |
+
# Extract audience (remove emoji prefix), skip if "Just me"
|
| 251 |
+
audience = ""
|
| 252 |
+
if audience_with_emoji and "Just me" not in audience_with_emoji:
|
| 253 |
+
audience = audience_with_emoji.split(" ", 1)[1] if " " in audience_with_emoji else audience_with_emoji
|
| 254 |
return explain_topic(topic, persona_name, audience, gen_audio)
|
| 255 |
|
| 256 |
explain_btn.click(
|
| 257 |
fn=process_and_explain,
|
| 258 |
+
inputs=[topic_input, persona_dropdown, audio_checkbox, audience_dropdown],
|
| 259 |
outputs=[explanation_output, audio_output, sources_output, steps_output, mcp_output],
|
| 260 |
)
|
| 261 |
|
| 262 |
# Also trigger on Enter key in topic input
|
| 263 |
topic_input.submit(
|
| 264 |
fn=process_and_explain,
|
| 265 |
+
inputs=[topic_input, persona_dropdown, audio_checkbox, audience_dropdown],
|
| 266 |
outputs=[explanation_output, audio_output, sources_output, steps_output, mcp_output],
|
| 267 |
)
|
| 268 |
|