jaidesign commited on
Commit
794c426
·
verified ·
1 Parent(s): 11b9b87

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -9
app.py CHANGED
@@ -33,14 +33,17 @@ 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
- @tool
37
- # Extract current weather information from AccuWeather
38
- weather_info = weather_result.split('\n')[1] # The second line contains the current weather information
39
- print("Current Weather in Franconia, Virginia:", weather_info)
40
-
41
- # Combine the current time and weather information for the final answer
42
- final_answer(f"Current Time: {current_time}\nCurrent Weather: {weather_info}")
43
-
 
 
 
44
 
45
  final_answer = FinalAnswerTool()
46
 
@@ -63,7 +66,7 @@ with open("prompts.yaml", 'r') as stream:
63
 
64
  agent = CodeAgent(
65
  model=model,
66
- tools=[final_answer,weather_info,image_generation_tool,get_current_time_in_timezone,DuckDuckGoSearchTool()], ## add your tools here (don't remove final answer)
67
  max_steps=6,
68
  verbosity_level=1,
69
  grammar=None,
 
33
  except Exception as e:
34
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
35
 
36
+ @tool
37
+ def get_weather(city):
38
+ import requests
39
+ url = f"https://www.accuweather.com/{city}"
40
+ response = requests.get(url)
41
+ if response.status_code == 200:
42
+ data = response.json()
43
+ return data.get("weather", "No weather information available")
44
+ else:
45
+ return "Error: Unable to fetch weather data."
46
+
47
 
48
  final_answer = FinalAnswerTool()
49
 
 
66
 
67
  agent = CodeAgent(
68
  model=model,
69
+ tools=[final_answer,get_weather,image_generation_tool,get_current_time_in_timezone,DuckDuckGoSearchTool()], ## add your tools here (don't remove final answer)
70
  max_steps=6,
71
  verbosity_level=1,
72
  grammar=None,