File size: 1,291 Bytes
e078a92
 
4e9df50
 
 
 
 
 
 
 
 
e078a92
4e9df50
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr

def chat_bot(name, feeling="good", greeting="Hello", style="normal"):
    if feeling == "good":
        response = "That's great to hear!"
    elif feeling == "okay":
        response = "Hope things get better soon!"
    elif feeling == "bad":
        response = "I'm sorry to hear that. Is there anything I can do to help?"
    else:
        response = "Invalid feeling! Please choose 'good', 'okay', or 'bad'."

    if style == "normal":
        return f"{greeting} {name}!! {response}"
    elif style == "bold":
        return f"**{greeting} {name}!!** {response}"
    elif style == "italic":
        return f"*{greeting} {name}!!* {response}"
    else:
        return "Invalid style! Please choose 'normal', 'bold', or 'italic'."

iface = gr.Interface(fn=chat_bot, 
                     inputs=[
                         "text", 
                         gr.inputs.Radio(["good", "okay", "bad"], label="How are you feeling?"),
                         gr.inputs.Radio(["Hello", "Hi", "Hola"], label="Select Greeting")
                     ], 
                     outputs=["text", "text"], 
                     title="Chat Bot Interface",
                     description="Interact with the chat bot by providing your name, feeling, and greeting.")

iface.launch()