Spaces:
Runtime error
Runtime error
| 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() | |