anasmkh's picture
Update app.py
9130c7f verified
raw
history blame
516 Bytes
def chat(message, history):
history = history or []
history.append({"role": "user", "content": message})
response = generator(history)[-1]["generated_text"]
history.append({"role": "assistant", "content": response})
return history
with gr.Blocks() as demo:
chatbot = gr.Chatbot()
message = gr.Textbox()
clear = gr.ClearButton([message, chatbot])
message.submit(chat, [message, chatbot], chatbot)
clear.click(lambda: None, None, chatbot, queue=False)
demo.launch()