bfn-tech commited on
Commit
97582ee
·
verified ·
1 Parent(s): ae7a494

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -0
app.py CHANGED
@@ -4,6 +4,7 @@ import requests
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
 
7
 
8
  from Gradio_UI import GradioUI
9
 
@@ -18,6 +19,25 @@ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
18
  """
19
  return "What magic will you build ?"
20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  @tool
22
  def get_current_time_in_timezone(timezone: str) -> str:
23
  """A tool that fetches the current local time in a specified timezone.
 
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
7
+ from geopy.geocoders import Nominatim
8
 
9
  from Gradio_UI import GradioUI
10
 
 
19
  """
20
  return "What magic will you build ?"
21
 
22
+ @tool
23
+ def my_weather_app(location:str, date:str) -> str:
24
+ """This is a tool that fetches the weather condition of a particular day using its location and date.
25
+ Args:
26
+ location: A string that represents the location (e.g., "Abuja").
27
+ date: A string representing the date (yyyy-mm-dd)
28
+ """
29
+ location = geolocator.geocode(location)
30
+ if location:
31
+ try:
32
+ response = requests.get(f"https://api.open-meteo.com/v1/forecast?latitude={location.latitude}&longitude={location.longitude}&hourly=temperature_2m&start_date={date}&end_date={date}")
33
+ data = response.json()
34
+ return data['hourly']['temperature']
35
+ except error:
36
+ return "Error"
37
+ else:
38
+ return ("Location not found")
39
+
40
+
41
  @tool
42
  def get_current_time_in_timezone(timezone: str) -> str:
43
  """A tool that fetches the current local time in a specified timezone.