File size: 516 Bytes
9130c7f a3445e5 1f2129b a3445e5 1f2129b a3445e5 |
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 |
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()
|