Ubik80 commited on
Commit
bbdf2e1
·
verified ·
1 Parent(s): 2c8aea7

Update tools.py

Browse files
Files changed (1) hide show
  1. tools.py +28 -0
tools.py CHANGED
@@ -1,4 +1,32 @@
1
  from smolagents import DuckDuckGoSearchTool
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  # Initialize the DuckDuckGo search tool
4
  search_tool = DuckDuckGoSearchTool()
 
1
  from smolagents import DuckDuckGoSearchTool
2
 
3
+ from smolagents import Tool
4
+ import random
5
+
6
+ class WeatherInfoTool(Tool):
7
+ name = "weather_info"
8
+ description = "Fetches dummy weather information for a given location."
9
+ inputs = {
10
+ "location": {
11
+ "type": "string",
12
+ "description": "The location to get weather information for."
13
+ }
14
+ }
15
+ output_type = "string"
16
+
17
+ def forward(self, location: str):
18
+ # Dummy weather data
19
+ weather_conditions = [
20
+ {"condition": "Rainy", "temp_c": 15},
21
+ {"condition": "Clear", "temp_c": 25},
22
+ {"condition": "Windy", "temp_c": 20}
23
+ ]
24
+ # Randomly select a weather condition
25
+ data = random.choice(weather_conditions)
26
+ return f"Weather in {location}: {data['condition']}, {data['temp_c']}°C"
27
+
28
+ # Initialize the tool
29
+ weather_info_tool = WeatherInfoTool()
30
+
31
  # Initialize the DuckDuckGo search tool
32
  search_tool = DuckDuckGoSearchTool()