Spaces:
Sleeping
Sleeping
File size: 608 Bytes
16f5dc6 626c99e 507ea28 4287516 507ea28 1b3c154 4287516 626c99e 4287516 507ea28 6e9b888 4287516 1b3c154 507ea28 1b3c154 83d06b8 2fda303 1b3c154 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | import gradio as gr
def handle_chat(message, history):
if history is None:
history = []
history.append({"role": "user", "content": message})
history.append({"role": "assistant", "content": f"You said: {message}"})
return history, history
with gr.Blocks() as demo:
chatbot = gr.Chatbot(type="messages")
state = gr.State([])
with gr.Row():
msg = gr.Textbox(placeholder="Type a message...")
submit = gr.Button("Send")
submit.click(handle_chat, [msg, state], [chatbot, state])
msg.submit(handle_chat, [msg, state], [chatbot, state])
demo.launch()
|