File size: 810 Bytes
8782521
9aa0f04
 
7db4c73
8782521
 
 
 
 
 
 
 
 
 
 
 
9aa0f04
7db4c73
8782521
 
 
 
8c39b5c
7db4c73
8782521
 
 
 
 
 
 
9aa0f04
8782521
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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()