Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -209,26 +209,33 @@ def get_response(query):
|
|
| 209 |
return response
|
| 210 |
|
| 211 |
with gr.Blocks() as iface:
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 220 |
chatbot = gr.Chatbot()
|
| 221 |
-
msg = gr.Textbox()
|
|
|
|
| 222 |
clear = gr.ClearButton([msg, chatbot])
|
| 223 |
-
|
| 224 |
-
|
| 225 |
def respond(message, chat_history):
|
| 226 |
bot_message = get_response(message)
|
| 227 |
-
chat_history.append(
|
|
|
|
|
|
|
| 228 |
time.sleep(2)
|
| 229 |
return "", chat_history
|
| 230 |
|
| 231 |
-
submit.
|
|
|
|
| 232 |
|
| 233 |
if __name__ == "__main__":
|
| 234 |
iface.launch()
|
|
|
|
| 209 |
return response
|
| 210 |
|
| 211 |
with gr.Blocks() as iface:
|
| 212 |
+
gr.Markdown(
|
| 213 |
+
"""
|
| 214 |
+
# Anjibot
|
| 215 |
+
### Hi friend! I'm Anjibot, CS Group A AI Course Rep.
|
| 216 |
+
|
| 217 |
+
#### As you interact with me, please note:
|
| 218 |
+
- Our chats are not private.
|
| 219 |
+
- I'm still undergoing training (I'm not perfect).
|
| 220 |
+
- I'm not ChatGPT (My knowledge base is limited to class-related issues).
|
| 221 |
+
- I'm British ;)
|
| 222 |
+
""")
|
| 223 |
+
|
| 224 |
chatbot = gr.Chatbot()
|
| 225 |
+
msg = gr.Textbox(placeholder="Type your question here", label="User")
|
| 226 |
+
submit = gr.Button("Submit")
|
| 227 |
clear = gr.ClearButton([msg, chatbot])
|
| 228 |
+
|
|
|
|
| 229 |
def respond(message, chat_history):
|
| 230 |
bot_message = get_response(message)
|
| 231 |
+
chat_history.append(
|
| 232 |
+
(f"**You:** {message}", f"**Anjibot:** {bot_message}")
|
| 233 |
+
)
|
| 234 |
time.sleep(2)
|
| 235 |
return "", chat_history
|
| 236 |
|
| 237 |
+
submit.click(respond, [msg, chatbot], [msg, chatbot])
|
| 238 |
+
msg.submit(respond, [msg, chatbot], [msg, chatbot])
|
| 239 |
|
| 240 |
if __name__ == "__main__":
|
| 241 |
iface.launch()
|