Update app.py
Browse files
app.py
CHANGED
|
@@ -8,11 +8,31 @@ with gr.Blocks() as demo:
|
|
| 8 |
clear = gr.ClearButton([msg, chatbot])
|
| 9 |
|
| 10 |
def respond(message, chat_history):
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
return "", chat_history
|
| 15 |
|
| 16 |
msg.submit(respond, [msg, chatbot])
|
| 17 |
|
| 18 |
-
demo.launch()
|
|
|
|
| 8 |
clear = gr.ClearButton([msg, chatbot])
|
| 9 |
|
| 10 |
def respond(message, chat_history):
|
| 11 |
+
user_input = message.lower()
|
| 12 |
+
|
| 13 |
+
# Topic-based responses
|
| 14 |
+
if "technology" in user_input:
|
| 15 |
+
bot_message = "Sure, let's talk about technology. What specific aspect are you interested in?"
|
| 16 |
+
|
| 17 |
+
elif "science" in user_input:
|
| 18 |
+
bot_message = "Science is fascinating! What scientific topic would you like to discuss?"
|
| 19 |
+
|
| 20 |
+
elif "healthcare" in user_input:
|
| 21 |
+
bot_message = "Healthcare is crucial. How can I assist you in the healthcare domain?"
|
| 22 |
+
|
| 23 |
+
elif "education" in user_input:
|
| 24 |
+
bot_message = "Education is important. What educational topic are you curious about?"
|
| 25 |
+
|
| 26 |
+
elif "sports" in user_input:
|
| 27 |
+
bot_message = "Sports are exciting! What sport or team are you a fan of?"
|
| 28 |
+
|
| 29 |
+
else:
|
| 30 |
+
bot_message = "Welcome! I'm Glo AI. How can I assist you today?"
|
| 31 |
+
|
| 32 |
+
chat_history.append(bot_message)
|
| 33 |
+
time.sleep(2) # Simulating a brief delay for a more natural conversation
|
| 34 |
return "", chat_history
|
| 35 |
|
| 36 |
msg.submit(respond, [msg, chatbot])
|
| 37 |
|
| 38 |
+
demo.launch()
|