Update app.py
Browse files
app.py
CHANGED
|
@@ -14,7 +14,8 @@ messages = []
|
|
| 14 |
|
| 15 |
def chatbot(user_input):
|
| 16 |
global messages
|
| 17 |
-
|
|
|
|
| 18 |
|
| 19 |
found = []
|
| 20 |
query_words = user_input.lower().split()
|
|
@@ -32,7 +33,8 @@ def chatbot(user_input):
|
|
| 32 |
else:
|
| 33 |
reply = "I couldn’t find that in Sierra or engine manuals."
|
| 34 |
|
| 35 |
-
|
|
|
|
| 36 |
return messages
|
| 37 |
|
| 38 |
with gr.Blocks() as demo:
|
|
@@ -45,6 +47,6 @@ with gr.Blocks() as demo:
|
|
| 45 |
return bot_reply, ""
|
| 46 |
|
| 47 |
msg.submit(respond, [msg, chatbot_ui], [chatbot_ui, msg])
|
| 48 |
-
clear.click(lambda:
|
| 49 |
|
| 50 |
demo.launch()
|
|
|
|
| 14 |
|
| 15 |
def chatbot(user_input):
|
| 16 |
global messages
|
| 17 |
+
# Add user message in new format
|
| 18 |
+
messages.append({"role": "user", "content": user_input})
|
| 19 |
|
| 20 |
found = []
|
| 21 |
query_words = user_input.lower().split()
|
|
|
|
| 33 |
else:
|
| 34 |
reply = "I couldn’t find that in Sierra or engine manuals."
|
| 35 |
|
| 36 |
+
# Add assistant message in new format
|
| 37 |
+
messages.append({"role": "assistant", "content": reply})
|
| 38 |
return messages
|
| 39 |
|
| 40 |
with gr.Blocks() as demo:
|
|
|
|
| 47 |
return bot_reply, ""
|
| 48 |
|
| 49 |
msg.submit(respond, [msg, chatbot_ui], [chatbot_ui, msg])
|
| 50 |
+
clear.click(lambda: [], None, chatbot_ui, queue=False)
|
| 51 |
|
| 52 |
demo.launch()
|