Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| history = [] | |
| def chat(message, history): | |
| history.append(("user", message)) | |
| bot_message = f"You said: {message}" | |
| history.append(("bot", bot_message)) | |
| return history, history | |
| with gr.Blocks() as demo: | |
| chatbot = gr.Chatbot(label="Chat") | |
| msg = gr.Textbox(label="Message", placeholder="Type here...", lines=1) | |
| clear = gr.Button("Clear") | |
| def respond(message, history): | |
| history.append((message, f"You said: {message}")) | |
| return "", history | |
| msg.submit(respond, [msg, chatbot], [msg, chatbot]) | |
| clear.click(lambda: None, None, chatbot, queue=False) | |
| demo.launch() |