### ROUND 1 ### import gradio as gr def echo(message, history): return message demo = gr.ChatInterface(fn=echo, type="messages", examples=["hello", "hola", "merhaba"], title="Echo Bot") demo.launch() ## ROUND 2 ### # import random # import gradio as gr # def random_response(message, history): # return random.choice(["Yes", "No"]) # demo = gr.ChatInterface(random_response, type="messages", autofocus=True) # if __name__ == "__main__": # demo.launch() ### ROUND 3 ### # def yes(message, history): # return "yes" # def vote(data: gr.LikeData): # if data.liked: # print("You upvoted this response: " + data.value["value"]) # else: # print("You downvoted this response: " + data.value["value"]) # with gr.Blocks() as demo: # chatbot = gr.Chatbot(placeholder="Your Personal Yes-Man
Ask Me Anything") # chatbot.like(vote, None, None) # gr.ChatInterface(fn=yes, type="messages", chatbot=chatbot) # demo.launch() ### ROUND 4 ### # import time # import gradio as gr # def slow_echo(message, history): # for i in range(len(message)): # time.sleep(0.05) # yield "You typed: " + message[: i + 1] # demo = gr.ChatInterface( # slow_echo, # type="messages", # save_history=True, # ) # if __name__ == "__main__": # demo.launch()