Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -32,6 +32,15 @@ def echo(message, history):
|
|
| 32 |
#use random to select choices
|
| 33 |
chat_answer = random.choice(choices)
|
| 34 |
return chat_answer
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
with gr.Blocks() as demo:
|
| 37 |
gr.Markdown("## 💬 Mean Chatbot")
|
|
@@ -61,6 +70,18 @@ with gr.Blocks() as demo:
|
|
| 61 |
</button>
|
| 62 |
</a>
|
| 63 |
""")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
|
| 65 |
demo.launch(debug=True)
|
| 66 |
#added code for blocks
|
|
|
|
| 32 |
#use random to select choices
|
| 33 |
chat_answer = random.choice(choices)
|
| 34 |
return chat_answer
|
| 35 |
+
|
| 36 |
+
def show_info(topic):
|
| 37 |
+
responses = {
|
| 38 |
+
"Puberty": "Puberty is when your body begins to change into an adult body.",
|
| 39 |
+
"Periods": "A period is a natural process where the body sheds the uterine lining.",
|
| 40 |
+
"Hormones": "Hormones are chemicals that regulate body functions, mood, and growth.",
|
| 41 |
+
"Self-care": "Self-care means taking time to rest, eat well, and manage stress."
|
| 42 |
+
}
|
| 43 |
+
return responses.get(topic, "Select a topic to see more info.")
|
| 44 |
|
| 45 |
with gr.Blocks() as demo:
|
| 46 |
gr.Markdown("## 💬 Mean Chatbot")
|
|
|
|
| 70 |
</button>
|
| 71 |
</a>
|
| 72 |
""")
|
| 73 |
+
gr.Markdown("### 📚 Learn About Topics")
|
| 74 |
+
|
| 75 |
+
dropdown = gr.Dropdown(
|
| 76 |
+
choices=["Puberty", "Periods", "Hormones", "Self-care"],
|
| 77 |
+
label="Choose a topic",
|
| 78 |
+
interactive=True
|
| 79 |
+
)
|
| 80 |
+
|
| 81 |
+
output = gr.Textbox(label="Info", lines=4, interactive=False)
|
| 82 |
+
|
| 83 |
+
# Show response when a choice is made
|
| 84 |
+
dropdown.change(fn=show_info, inputs=dropdown, outputs=output)
|
| 85 |
|
| 86 |
demo.launch(debug=True)
|
| 87 |
#added code for blocks
|