gradio-chat-21 / app.py
akhaliq's picture
akhaliq HF Staff
Upload app.py with huggingface_hub
70a2929 verified
Raw
History Blame Contribute Delete
633 Bytes
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()