Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
|
| 3 |
+
messages = []
|
| 4 |
+
|
| 5 |
+
def chatbot(user_input):
|
| 6 |
+
global messages
|
| 7 |
+
messages.append(("user", user_input))
|
| 8 |
+
reply = f"I received: {user_input}\n(This is where your manual/model will connect later.)"
|
| 9 |
+
messages.append(("assistant", reply))
|
| 10 |
+
return messages
|
| 11 |
+
|
| 12 |
+
with gr.Blocks() as demo:
|
| 13 |
+
chatbot_ui = gr.Chatbot()
|
| 14 |
+
msg = gr.Textbox(placeholder="Ask me anything about your Sierra or caravan...")
|
| 15 |
+
clear = gr.Button("Clear")
|
| 16 |
+
|
| 17 |
+
def respond(message, chat_history):
|
| 18 |
+
bot_reply = chatbot(message)
|
| 19 |
+
return bot_reply, ""
|
| 20 |
+
|
| 21 |
+
msg.submit(respond, [msg, chatbot_ui], [chatbot_ui, msg])
|
| 22 |
+
clear.click(lambda: None, None, chatbot_ui, queue=False)
|
| 23 |
+
|
| 24 |
+
demo.launch()
|