File size: 2,233 Bytes
21306de e236309 304933a 678703b 304933a 5f04394 304933a 678703b 304933a e236309 304933a 5f04394 304933a 5f04394 304933a 5f04394 304933a 678703b 304933a 5f04394 304933a 5f04394 304933a e236309 304933a e236309 304933a 21306de 5f04394 304933a 21306de |
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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
import gradio as gr
# Define your chatbot function
def chatbot(input_text):
# Define some responses based on input_text
if "hello" in input_text.lower() or "hi" in input_text.lower():
response = "Hello! How can I help you?"
elif "how are you?" in input_text.lower():
response = "I'm just a chatbot, but thanks for asking!"
elif "who are you?" in input_text.lower():
response = "I'm a chatbot designed to assist you with various tasks and answer your questions."
elif "what's your name?" in input_text.lower():
response = "I'm just a chatbot, I don't have a name."
elif "I'm confused" in input_text.lower():
response = "It's alright. I'm here to help. What are you confused about?"
elif "bye" in input_text.lower():
response = "Goodbye! Have a great day!"
elif "can you assist me with something?" in input_text.lower():
response = "Of course! What do you need help with?"
elif "what are the symptoms of the common cold?" in input_text.lower():
response = "Common cold symptoms include runny nose, sore throat, and cough."
elif "thank you" in input_text.lower() or "thanks" in input_text.lower():
response = "You're welcome!"
elif "how's the weather today?" in input_text.lower():
response = "I'm not equipped to check the weather, but I hope it's nice wherever you are!"
elif "I'm feeling sad" in input_text.lower():
response = "I'm sorry to hear that. Is there anything specific I can do to help?"
elif "life is so frustrating!" in input_text.lower():
response = "I understand. Sometimes things can be challenging. Is there anything I can do to assist you?"
elif "tell me a joke" in input_text.lower():
response = "Sure, here's one: Why don't skeletons fight each other? They don't have the guts!"
else:
response = "I'm sorry, I didn't understand that."
return response
# Create the Gradio interface
chatbot_ui = gr.Interface(
fn=chatbot,
inputs = gr.Textbox(lines=20, label="Input Text"),
outputs = "text",
title="Simple Chatbot",
description="Type a message to chat with the bot."
)
# Launch the interface
chatbot_ui.launch()
|