Spaces:
Sleeping
Sleeping
File size: 714 Bytes
6aa7293 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
import gradio as gr
def respond(message, chat_history):
# Append the user message to the chat history
chat_history.append({"role": "user", "content": message})
# Echo back the user message as the assistant's response
chat_history.append({"role": "assistant", "content": message})
return "", chat_history # Return an empty string for the input box and the updated chat history
with gr.Blocks() as demo:
chatbot = gr.Chatbot(type="messages")
msg = gr.Textbox(label="User Input")
# Set up the event listener for the user's message submission
msg.submit(respond, [msg, chatbot], [msg, chatbot])
# Launch the Gradio app
if __name__ == "__main__":
demo.launch(show_error=True) |