Spaces:
Build error
Build error
| import gradio as gr | |
| def respond(message, chat_history): | |
| bot_reply = "You said: " + message # Replace with your chatbot logic | |
| chat_history = chat_history or [] | |
| chat_history.append(("You", message)) | |
| chat_history.append(("Bot", bot_reply)) | |
| return "", chat_history | |
| def say_hello(chat_history): | |
| chat_history = chat_history or [] | |
| chat_history.append(("Bot", "Hello! How can I help?")) | |
| return chat_history | |
| def clear(): | |
| return [] | |
| with gr.Blocks() as demo: | |
| with gr.Row(): | |
| with gr.Column(scale=1): | |
| gr.Markdown("## Sidebar") | |
| hello_btn = gr.Button("Say Hello") | |
| clear_btn = gr.Button("Clear Chat") | |
| with gr.Column(scale=4): | |
| chatbot = gr.Chatbot() | |
| msg = gr.Textbox(placeholder="Type a message") | |
| send = gr.Button("Send") | |
| send.click(respond, inputs=[msg, chatbot], outputs=[msg, chatbot]) | |
| hello_btn.click(say_hello, inputs=chatbot, outputs=chatbot) | |
| clear_btn.click(clear, outputs=chatbot) | |
| demo.launch() | |