harryab commited on
Commit
6a98581
·
verified ·
1 Parent(s): 8707d1e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -31
app.py CHANGED
@@ -9,39 +9,19 @@ from Gradio_UI import GradioUI
9
 
10
  #Marathon training plan
11
  @tool
12
- def fetch_marathon_plan(goal_time: str) -> str:
13
- """Fetches a marathon training plan based on a goal time.
14
-
15
  Args:
16
- goal_time: Desired marathon completion time (e.g., '4:00', '3:30').
17
-
18
- Returns:
19
- A link to a training plan or summary of key details.
20
- """
21
- search_tool = DuckDuckGoSearchTool()
22
- query = f"marathon training plan {goal_time} site:runnersworld.com"
23
- results = search_tool.search(query)
24
-
25
- if results:
26
- return f"Here is a recommended training plan for {goal_time}: {results[0]['url']}"
27
- else:
28
- return f"Could not find a specific plan for {goal_time}, but you can check Runner's World for more details."
29
-
30
- @tool
31
- def fetch_european_marathons_2025() -> str:
32
- """Fetches a list of marathons in Europe for 2025.
33
-
34
- Returns:
35
- A link to a webpage or a summary of key details.
36
  """
37
- search_tool = DuckDuckGoSearchTool()
38
- query = "marathons in Europe 2025 site:marathonrunnersdiary.com"
39
- results = search_tool.search(query)
40
-
41
- if results:
42
- return f"Here is a list of marathons in Europe for 2025: {results[0]['url']}"
43
- else:
44
- return "Could not find any marathons for 2025 in Europe, but you can check Marathon Runner's Diary for more details."
45
 
46
  final_answer = FinalAnswerTool()
47
 
 
9
 
10
  #Marathon training plan
11
  @tool
12
+ def get_current_time_in_timezone(timezone: str) -> str:
13
+ """A tool that fetches the current local time in a specified timezone.
 
14
  Args:
15
+ timezone: A string representing a valid timezone (e.g., 'America/New_York').
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  """
17
+ try:
18
+ # Create timezone object
19
+ tz = pytz.timezone(timezone)
20
+ # Get current time in that timezone
21
+ local_time = datetime.datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S")
22
+ return f"The current local time in {timezone} is: {local_time}"
23
+ except Exception as e:
24
+ return f"Error fetching time for timezone '{timezone}': {str(e)}"
25
 
26
  final_answer = FinalAnswerTool()
27