mgetz's picture
Copy-Paste of Original Training chatbot for just lesson 10 without lesson 11 changes.
e8d837a verified
#import the suite of gradio features
import gradio as gr
#import the random library
import random as rd
#return is what the chatbot's response will be
#echo function needs 2 parameters,
#the message that the user input,
#the history from the prior conversation
#this function will just respond exactly what the input was
def echo(message, history):
print("Hello, world!")
return message
#this is the list of possible choices for the random function
#this function will randomly respond 'yes' or 'no'
def yes_no(message, history):
response_list = ['yes', 'no']
print("User Message: ", message)
print("History: ", history)
return rd.choice(response_list)
# assign the chat interface to a variable, expects a function as an argument
#the second argument fixes an error message about not supporting tuples
chatbot = gr.ChatInterface(yes_no, type='messages', title="A simple chatbot", description="A cute lil' chatbot that can give quaint, basic responses. Created by Matt Getz for KWK", theme='earneleh/paris')
#launch the chat interface
chatbot.launch()