cranberry-task / app.py
thunder-007's picture
Create app.py
b8edde2
raw
history blame contribute delete
779 Bytes
import gradio as gr
import random
import time
from thunder_gpt import get_response
with gr.Blocks() as demo:
gr.Markdown("Chat bot for cranberry task")
chatbot = gr.Chatbot()
msg = gr.Textbox()
clear = gr.Button("Clear")
def user(user_message, history):
return "", history + [[user_message, None]]
def bot(history):
question = history[-1][0]
answer = get_response(question)
history[-1][1] = ""
for character in answer:
history[-1][1] += character
time.sleep(0.02)
yield history
msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(
bot, chatbot, chatbot
)
clear.click(lambda: None, None, chatbot, queue=False)
demo.queue()
demo.launch()