File size: 697 Bytes
75ba1ca
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import gradio as gr

messages = []

def chatbot(user_input):
    global messages
    messages.append(("user", user_input))
    reply = f"I received: {user_input}\n(This is where your manual/model will connect later.)"
    messages.append(("assistant", reply))
    return messages

with gr.Blocks() as demo:
    chatbot_ui = gr.Chatbot()
    msg = gr.Textbox(placeholder="Ask me anything about your Sierra or caravan...")
    clear = gr.Button("Clear")

    def respond(message, chat_history):
        bot_reply = chatbot(message)
        return bot_reply, ""

    msg.submit(respond, [msg, chatbot_ui], [chatbot_ui, msg])
    clear.click(lambda: None, None, chatbot_ui, queue=False)

demo.launch()