Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -83,22 +83,23 @@ def get_wikipedia_facts(topic):
|
|
| 83 |
print("Error:", e)
|
| 84 |
return "Something went wrong. Please try again.", None, None
|
| 85 |
|
|
|
|
| 86 |
def surprise_topic(_):
|
| 87 |
topic = random.choice(random_topics)
|
| 88 |
return get_wikipedia_facts(topic)
|
| 89 |
|
| 90 |
-
# UI
|
| 91 |
with gr.Blocks(css="style.css") as demo:
|
| 92 |
gr.Markdown("""
|
| 93 |
# ☁️ Smart Wikipedia Fact Finder
|
| 94 |
-
Discover fun facts, a
|
| 95 |
|
| 96 |
Type a topic (like `quantum physics`) or click **🎲 Surprise me!**
|
| 97 |
""")
|
| 98 |
|
| 99 |
with gr.Row():
|
| 100 |
with gr.Column(scale=3):
|
| 101 |
-
topic_input = gr.Textbox(label="Enter a Topic", placeholder="e.g. Eiffel Tower")
|
| 102 |
with gr.Column(scale=1):
|
| 103 |
surprise_button = gr.Button("🎲 Surprise me!")
|
| 104 |
|
|
@@ -119,5 +120,6 @@ if __name__ == "__main__":
|
|
| 119 |
|
| 120 |
|
| 121 |
|
|
|
|
| 122 |
|
| 123 |
|
|
|
|
| 83 |
print("Error:", e)
|
| 84 |
return "Something went wrong. Please try again.", None, None
|
| 85 |
|
| 86 |
+
# Surprise function
|
| 87 |
def surprise_topic(_):
|
| 88 |
topic = random.choice(random_topics)
|
| 89 |
return get_wikipedia_facts(topic)
|
| 90 |
|
| 91 |
+
# Gradio UI
|
| 92 |
with gr.Blocks(css="style.css") as demo:
|
| 93 |
gr.Markdown("""
|
| 94 |
# ☁️ Smart Wikipedia Fact Finder
|
| 95 |
+
Discover fun facts, a related image, and AI-generated topic category!
|
| 96 |
|
| 97 |
Type a topic (like `quantum physics`) or click **🎲 Surprise me!**
|
| 98 |
""")
|
| 99 |
|
| 100 |
with gr.Row():
|
| 101 |
with gr.Column(scale=3):
|
| 102 |
+
topic_input = gr.Textbox(label="Enter a Topic", placeholder="e.g. Eiffel Tower, koalas, World War II")
|
| 103 |
with gr.Column(scale=1):
|
| 104 |
surprise_button = gr.Button("🎲 Surprise me!")
|
| 105 |
|
|
|
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
+
|
| 124 |
|
| 125 |
|