danielkorat commited on
Commit
82c85bd
·
verified ·
1 Parent(s): d66a66c

Update my_tools.py

Browse files
Files changed (1) hide show
  1. my_tools.py +2 -1
my_tools.py CHANGED
@@ -2,6 +2,7 @@ from smolagents import tool
2
  from typing import Optional
3
  import requests
4
  import pytz
 
5
 
6
  @tool
7
  def get_weather(location: str, celsius: Optional[bool] = False) -> str:
@@ -15,7 +16,7 @@ def get_weather(location: str, celsius: Optional[bool] = False) -> str:
15
  Returns:
16
  A string describing the current weather at the location.
17
  """
18
- api_key = "your_api_key" # Replace with your API key from https://weatherstack.com/
19
  units = "m" if celsius else "f" # 'm' for Celsius, 'f' for Fahrenheit
20
 
21
  url = f"http://api.weatherstack.com/current?access_key={api_key}&query={location}&units={units}"
 
2
  from typing import Optional
3
  import requests
4
  import pytz
5
+ import os
6
 
7
  @tool
8
  def get_weather(location: str, celsius: Optional[bool] = False) -> str:
 
16
  Returns:
17
  A string describing the current weather at the location.
18
  """
19
+ api_key = os.environ["WEATHER_API_KEY"] # Replace with your API key from https://weatherstack.com/
20
  units = "m" if celsius else "f" # 'm' for Celsius, 'f' for Fahrenheit
21
 
22
  url = f"http://api.weatherstack.com/current?access_key={api_key}&query={location}&units={units}"