Spaces:
Sleeping
Sleeping
| import random | |
| import gradio as gr | |
| #Magic 8 Ball responses | |
| responses = [ | |
| "Without a doubt.", | |
| "Ask again later.", | |
| "Outlook not so good.", | |
| "Yes – definitely!", | |
| "Better not tell you now.", | |
| "My sources say no.", | |
| "Signs point to yes.", | |
| "Cannot predict now.", | |
| "Absolutely not.", | |
| "Most likely.", | |
| ] | |
| #response function | |
| def magic_8_ball(question): | |
| if question.strip() == "": | |
| return "Please ask a yes/no question!" | |
| return random.choice(responses) | |
| #Make the Gradio interface | |
| chatbot = gr.Interface( | |
| fn=magic_8_ball, | |
| inputs=gr.Textbox(label="Ask the Magic 8 Ball a Yes/No Question:"), | |
| outputs=gr.Textbox(label="Magic 8 Ball says..."), | |
| title="Magic 8 Ball Chatbot", | |
| description="Ask a yes/no question and reveal your fate!" | |
| ) | |
| chatbot.launch() | |