Spaces:
Sleeping
Sleeping
add function get_current_time_in_timezone() to get historical data
Browse files
app.py
CHANGED
@@ -9,14 +9,36 @@ 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
|
13 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
14 |
-
"""
|
|
|
|
|
15 |
Args:
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
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 historical_event_explorer(query :str, year: int = None)-> str: #it's import to specify the return type
|
13 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
14 |
+
"""
|
15 |
+
A tool to explore historical events based on a year or keyword.
|
16 |
+
|
17 |
Args:
|
18 |
+
query: A keyword to search for historical events (e.g., "war", "invetion").
|
19 |
+
year: An optional year to filter events by a specific time period.
|
20 |
+
|
21 |
+
Returns:
|
22 |
+
A string containing relevant historical events or a message if no results are found.
|
23 |
"""
|
24 |
+
# Example dataset of historical events
|
25 |
+
historical_data = {
|
26 |
+
1492: "Christopher Columbus reached the Americas.",
|
27 |
+
1776: "The United States Declaration of Independence was adopted.",
|
28 |
+
1865: "The American Civil War ended.",
|
29 |
+
1923: "The Republic of Turkey was established.",
|
30 |
+
1969: "Apollo 11 landed on the Moon.",
|
31 |
+
"war": "Notable wars include WWI (1914-1918) and WWII (1939-1945).",
|
32 |
+
"invention": "Key inventions include the printing press (1440),
|
33 |
+
}
|
34 |
+
|
35 |
+
# Check if the query mathces a year of keyword
|
36 |
+
if year is not None and year in historical_data:
|
37 |
+
return f"In {year}, {historical_data[year]}"
|
38 |
+
elif query in historical_data:
|
39 |
+
return historical_data:
|
40 |
+
else:
|
41 |
+
return "No historical events found for the given query."
|
42 |
|
43 |
@tool
|
44 |
def get_current_time_in_timezone(timezone: str) -> str:
|