jatinror commited on
Commit
914bbc0
·
verified ·
1 Parent(s): 0dc3c95
Files changed (1) hide show
  1. tools/weather_tool.py +42 -0
tools/weather_tool.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from smolagents import Tool
2
+ import random
3
+
4
+
5
+ class WeatherInfoTool(Tool):
6
+
7
+ name = "weather_info"
8
+
9
+ description = (
10
+ "Fetches weather information for a given location. "
11
+ "Use this tool when you need to know weather conditions "
12
+ "before planning outdoor events like fireworks."
13
+ )
14
+
15
+ inputs = {
16
+ "location": {
17
+ "type": "string",
18
+ "description": "The location to get weather information for."
19
+ }
20
+ }
21
+
22
+ output_type = "string"
23
+
24
+
25
+ def forward(self, location: str):
26
+
27
+ weather_conditions = [
28
+ {"condition": "Rainy", "temp_c": 15},
29
+ {"condition": "Clear", "temp_c": 25},
30
+ {"condition": "Windy", "temp_c": 20}
31
+ ]
32
+
33
+ data = random.choice(weather_conditions)
34
+
35
+ return (
36
+ f"Weather in {location}: "
37
+ f"{data['condition']}, "
38
+ f"{data['temp_c']}°C"
39
+ )
40
+
41
+
42
+ weather_info_tool = WeatherInfoTool()