File size: 1,087 Bytes
e8d837a
462ce8f
 
e8d837a
 
 
 
 
 
 
 
 
b7e472f
e8d837a
462ce8f
 
 
e8d837a
 
 
 
 
 
 
 
 
 
 
 
 
462ce8f
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
#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()