File size: 742 Bytes
8540d02
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# app.py
import gradio as gr
from datetime import datetime
import pytz

# Pakistan timezone
pakistan_tz = pytz.timezone("Asia/Karachi")

def chatbot(message):
    message = message.lower()
    if "time" in message:
        now_pk = datetime.now(pakistan_tz)
        return f"The current time in Pakistan is: {now_pk.strftime('%I:%M %p')}"
    else:
        return "I can only tell you the current time in Pakistan. Try asking: 'What is the time?'"

iface = gr.Interface(
    fn=chatbot,
    inputs=gr.Textbox(lines=2, placeholder="Ask me the time in Pakistan..."),
    outputs="text",
    title="Pakistan Time Bot",
    description="A simple bot that tells you the current time in Pakistan."
)

if __name__ == "__main__":
    iface.launch()