Spaces:
Sleeping
Sleeping
add weather
Browse files
app.py
CHANGED
|
@@ -33,6 +33,19 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 33 |
except Exception as e:
|
| 34 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
final_answer = FinalAnswerTool()
|
| 38 |
|
|
|
|
| 33 |
except Exception as e:
|
| 34 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 35 |
|
| 36 |
+
@tool
|
| 37 |
+
def weather(location:str)-> str: #it's import to specify the return type
|
| 38 |
+
"""A tool that fetches the curent weather in a specfied location
|
| 39 |
+
Args:
|
| 40 |
+
location: A string representing the current location
|
| 41 |
+
"""
|
| 42 |
+
WEATHER = os.getenv('WEATHER')
|
| 43 |
+
url = f"http://api.weatherapi.com/v1/current.json?key={WEATHER}&q={location}&aqi=no"
|
| 44 |
+
payload = {}
|
| 45 |
+
headers = {}
|
| 46 |
+
response = requests.request("GET", url, headers=headers, data=payload)
|
| 47 |
+
return response
|
| 48 |
+
|
| 49 |
|
| 50 |
final_answer = FinalAnswerTool()
|
| 51 |
|