Spaces:
Running
Running
Update app.py
Browse filesadded a tool that tells the world about my beautiful hometown of Chakwal.
app.py
CHANGED
@@ -9,14 +9,49 @@ from Gradio_UI import GradioUI
|
|
9 |
|
10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
11 |
@tool
|
12 |
-
def my_custom_tool(arg1:str, arg2:int)-> str:
|
13 |
-
|
14 |
-
|
|
|
|
|
15 |
Args:
|
16 |
-
arg1: the
|
17 |
-
arg2:
|
|
|
18 |
"""
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
@tool
|
22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
9 |
|
10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
11 |
@tool
|
12 |
+
def my_custom_tool(arg1: str, arg2: int) -> str:
|
13 |
+
"""
|
14 |
+
A tool that shares interesting facts about Chakwal, highlighting its flora, fauna, natural landscapes,
|
15 |
+
and cultural heritage. It also shows the current local time in Chakwal (Asia/Karachi timezone).
|
16 |
+
|
17 |
Args:
|
18 |
+
arg1: A custom note or additional message to include in the output.
|
19 |
+
arg2: The number of detailed facts to include about Chakwal (1 to 4).
|
20 |
+
(1: Flora only, 2: Flora & Fauna, 3: + Natural Landscapes, 4: + Cultural Heritage)
|
21 |
"""
|
22 |
+
messages = []
|
23 |
+
|
24 |
+
# Introduction about Chakwal
|
25 |
+
messages.append("Welcome to Chakwal, a city with a rich history, vibrant culture, and breathtaking natural beauty!")
|
26 |
+
|
27 |
+
# Facts about Chakwal's natural and cultural highlights
|
28 |
+
facts = [
|
29 |
+
("Flora", "The region boasts a diverse array of native plants, lush greenery, and seasonal wildflowers that add vibrant colors to the landscape."),
|
30 |
+
("Fauna", "Local wildlife includes a variety of bird species, reptiles, and small mammals that thrive in Chakwal's varied ecosystems."),
|
31 |
+
("Natural Landscapes", "Chakwal is surrounded by scenic hills, valleys, and water bodies, offering breathtaking views and numerous opportunities for outdoor adventures."),
|
32 |
+
("Cultural Heritage", "Deep-rooted traditions and lively festivals reflect Chakwal's rich cultural tapestry and historical significance.")
|
33 |
+
]
|
34 |
+
|
35 |
+
# Determine the number of facts to display (minimum 1, maximum 4)
|
36 |
+
num_facts = min(max(arg2, 1), len(facts))
|
37 |
+
for i in range(num_facts):
|
38 |
+
title, detail = facts[i]
|
39 |
+
messages.append(f"{title}: {detail}")
|
40 |
+
|
41 |
+
# Add current local time in Chakwal (using Asia/Karachi timezone)
|
42 |
+
try:
|
43 |
+
tz = pytz.timezone("Asia/Karachi")
|
44 |
+
local_time = datetime.datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S")
|
45 |
+
messages.append(f"Local Time in Chakwal (Asia/Karachi): {local_time}")
|
46 |
+
except Exception as e:
|
47 |
+
messages.append("Error fetching local time for Chakwal.")
|
48 |
+
|
49 |
+
# Include any custom note provided via arg1
|
50 |
+
if arg1:
|
51 |
+
messages.append(f"Note: {arg1}")
|
52 |
+
|
53 |
+
return "\n".join(messages)
|
54 |
+
|
55 |
|
56 |
@tool
|
57 |
def get_current_time_in_timezone(timezone: str) -> str:
|