Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,32 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
def
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
def chat_bot(name, feeling="good", greeting="Hello", style="normal"):
|
4 |
+
if feeling == "good":
|
5 |
+
response = "That's great to hear!"
|
6 |
+
elif feeling == "okay":
|
7 |
+
response = "Hope things get better soon!"
|
8 |
+
elif feeling == "bad":
|
9 |
+
response = "I'm sorry to hear that. Is there anything I can do to help?"
|
10 |
+
else:
|
11 |
+
response = "Invalid feeling! Please choose 'good', 'okay', or 'bad'."
|
12 |
|
13 |
+
if style == "normal":
|
14 |
+
return f"{greeting} {name}!! {response}"
|
15 |
+
elif style == "bold":
|
16 |
+
return f"**{greeting} {name}!!** {response}"
|
17 |
+
elif style == "italic":
|
18 |
+
return f"*{greeting} {name}!!* {response}"
|
19 |
+
else:
|
20 |
+
return "Invalid style! Please choose 'normal', 'bold', or 'italic'."
|
21 |
+
|
22 |
+
iface = gr.Interface(fn=chat_bot,
|
23 |
+
inputs=[
|
24 |
+
"text",
|
25 |
+
gr.inputs.Radio(["good", "okay", "bad"], label="How are you feeling?"),
|
26 |
+
gr.inputs.Radio(["Hello", "Hi", "Hola"], label="Select Greeting")
|
27 |
+
],
|
28 |
+
outputs=["text", "text"],
|
29 |
+
title="Chat Bot Interface",
|
30 |
+
description="Interact with the chat bot by providing your name, feeling, and greeting.")
|
31 |
+
|
32 |
+
iface.launch()
|