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