Spaces:
Sleeping
Sleeping
Chatbot ui
Browse files
main.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
def chatbot_response(user_input, history=[]):
|
4 |
+
# Simulate a bot response
|
5 |
+
bot_reply = "This is a simulated response."
|
6 |
+
|
7 |
+
# Update history
|
8 |
+
history.append({"user": user_input, "bot": bot_reply})
|
9 |
+
|
10 |
+
return bot_reply, history
|
11 |
+
|
12 |
+
# Gradio UI Setup
|
13 |
+
def gradio_interface():
|
14 |
+
with gr.Blocks() as chatbot_ui:
|
15 |
+
gr.Markdown("## Fake Chatbot UI")
|
16 |
+
user_input = gr.Textbox(label="User Input", placeholder="Type your message here...", lines=2)
|
17 |
+
chat_history = gr.Chatbot()
|
18 |
+
|
19 |
+
def respond(user_input, history):
|
20 |
+
bot_reply, history = chatbot_response(user_input, history)
|
21 |
+
return history, history
|
22 |
+
|
23 |
+
user_input.submit(respond, [user_input, chat_history], [chat_history, chat_history])
|
24 |
+
|
25 |
+
chatbot_ui.launch()
|
26 |
+
|
27 |
+
gradio_interface()
|