File size: 1,348 Bytes
bb793ce
0c1044c
6892643
d653402
0c1044c
 
 
 
3a64bb6
0c1044c
1e97cca
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
513d27b
1e97cca
 
 
0c1044c
3a64bb6
0c1044c
 
58e18c4
 
 
1e97cca
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import gradio as gr
import random
import time

with gr.Blocks() as demo:
    chatbot = gr.Chatbot()
    msg = gr.Textbox("Write your input here")
    clear = gr.ClearButton([msg, chatbot])

    def respond(message, chat_history):
        user_input = message.lower()

        # Topic-based responses
        if "technology" in user_input:
            bot_message = "Sure, let's talk about technology. What specific aspect are you interested in?"

        elif "science" in user_input:
            bot_message = "Science is fascinating! What scientific topic would you like to discuss?"

        elif "healthcare" in user_input:
            bot_message = "Healthcare is crucial. How can I assist you in the healthcare domain?"

        elif "education" in user_input:
            bot_message = "Education is important. What educational topic are you curious about?"

        elif "sports" in user_input:
            bot_message = "Sports are exciting! What sport or team are you a fan of?"

        else:
            bot_message = "Welcome! I'm Glo AI. How can I assist you today?"

        chat_history.append(bot_message)
        time.sleep(2)  # Simulating a brief delay for a more natural conversation
        return "", chat_history

    msg.submit(respond, [msg, chatbot])

from chat_app import launch_chat_app

launch_chat_app()
demo.launch()