nandes007 commited on
Commit
2d3bf79
·
verified ·
1 Parent(s): 8c5c24b

add function get_current_time_in_timezone() to get historical data

Browse files
Files changed (1) hide show
  1. app.py +27 -5
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 my_custom_tool(arg1:str, arg2:int)-> 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
- """A tool that does nothing yet
 
 
15
  Args:
16
- arg1: the first argument
17
- arg2: the second argument
 
 
 
18
  """
19
- return "What magic will you build ?"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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: