toolkit-ads-gen / gradio_app.py
lgaleana's picture
Add gradio chatbot
0646af4
raw
history blame
617 Bytes
import gradio as gr
import random
import time
from typing import List
with gr.Blocks() as demo:
chatbot = gr.Chatbot()
msg = gr.Textbox()
clear = gr.Button("Clear")
def respond(message: str, chat_history: List):
print(type(message))
print(type(chat_history))
bot_message = random.choice(["How are you?", "I love you", "I'm very hungry"])
chat_history.append((message, bot_message))
time.sleep(1)
return "", chat_history
msg.submit(respond, [msg, chatbot], [msg, chatbot])
clear.click(lambda: None, None, chatbot, queue=False)
demo.launch()