Nitien commited on
Commit
ae5fbaf
·
verified ·
1 Parent(s): 4b73dc8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -11
app.py CHANGED
@@ -19,21 +19,23 @@ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
19
  return "What magic will you build ?"
20
 
21
  @tool
22
- def get_weather(city:str)-> str: #it's import to specify the return type
23
- """ A tool to Fetch weather of a given city
24
  Args:
25
- city: name of the city (string)
26
- returns: weather information of the City as string.
27
  """
28
  if not city or city.strip() == "":
29
  return "No Data Found"
30
 
31
- url_https = f"https://wttr.in/{city}?format=3"
32
- resp=requests.get(url_https)
33
- if resp.status() == 200:
34
- return resp
35
- else:
36
- return "No Data Found"
 
 
 
37
 
38
  @tool
39
  def get_current_time_in_timezone(timezone: str) -> str:
@@ -72,7 +74,7 @@ with open("prompts.yaml", 'r') as stream:
72
 
73
  agent = CodeAgent(
74
  model=model,
75
- tools=[get_weather,final_answer], ## add your tools here (don't remove final answer)
76
  max_steps=6,
77
  verbosity_level=1,
78
  grammar=None,
 
19
  return "What magic will you build ?"
20
 
21
  @tool
22
+ def get_city_weather(city:str)-> str: #it's import to specify the return type
23
+ """ A tool to Fetch weather of a given arg city
24
  Args:
25
+ city: city name as string (e.g., 'London').
 
26
  """
27
  if not city or city.strip() == "":
28
  return "No Data Found"
29
 
30
+ url_https = f"https://wttr.in/{city}?format=3"
31
+ try:
32
+ resp=requests.get(url_https)
33
+ if resp.status() == 200:
34
+ return resp
35
+ else:
36
+ return "No Data Found"
37
+ except Exception as e:
38
+ return f"Error fetching weather information: {str(e)}"
39
 
40
  @tool
41
  def get_current_time_in_timezone(timezone: str) -> str:
 
74
 
75
  agent = CodeAgent(
76
  model=model,
77
+ tools=[get_city_weather,final_answer], ## add your tools here (don't remove final answer)
78
  max_steps=6,
79
  verbosity_level=1,
80
  grammar=None,