Spaces:
Running
Running
Upload tool
Browse files- requirements.txt +1 -1
- tool.py +5 -6
requirements.txt
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
-
git+https://github.com/huggingface/smolagents.git@enable-tools-huggingchat#egg=smolagents
|
2 |
googlemaps
|
|
|
|
|
|
1 |
googlemaps
|
2 |
+
smolagents
|
tool.py
CHANGED
@@ -4,12 +4,12 @@ from typing import Optional
|
|
4 |
class SimpleTool(Tool):
|
5 |
name = "get_travel_duration"
|
6 |
description = "Gets the travel time in car between two places."
|
7 |
-
inputs = {"start_location":{"type":"string","description":"the place from which you start your ride"},"destination_location":{"type":"string","description":"the place of arrival"},"transportation_mode":{"type":"string","nullable":True,"description":"The transportation mode, in 'driving', 'walking', 'bicycling', or 'transit'.}}
|
8 |
output_type = "string"
|
9 |
|
10 |
-
def forward(self, start_location: str, destination_location: str, transportation_mode: Optional[
|
11 |
"""Gets the travel time in car between two places.
|
12 |
-
|
13 |
Args:
|
14 |
start_location: the place from which you start your ride
|
15 |
destination_location: the place of arrival
|
@@ -17,9 +17,8 @@ class SimpleTool(Tool):
|
|
17 |
"""
|
18 |
import googlemaps
|
19 |
import os
|
20 |
-
|
21 |
gmaps = googlemaps.Client(os.getenv("GMAPS_API_KEY"))
|
22 |
-
|
23 |
if transportation_mode is None:
|
24 |
transportation_mode = "transit"
|
25 |
try:
|
@@ -31,5 +30,5 @@ class SimpleTool(Tool):
|
|
31 |
)
|
32 |
return directions_result[0]["legs"][0]["duration"]["text"]
|
33 |
except Exception as e:
|
34 |
-
print(e
|
35 |
return e
|
|
|
4 |
class SimpleTool(Tool):
|
5 |
name = "get_travel_duration"
|
6 |
description = "Gets the travel time in car between two places."
|
7 |
+
inputs = {"start_location":{"type":"string","description":"the place from which you start your ride"},"destination_location":{"type":"string","description":"the place of arrival"},"transportation_mode":{"type":"string","nullable":True,"description":"The transportation mode, in 'driving', 'walking', 'bicycling', or 'transit'."}}
|
8 |
output_type = "string"
|
9 |
|
10 |
+
def forward(self, start_location: str, destination_location: str, transportation_mode: Optional[str] = None) -> str:
|
11 |
"""Gets the travel time in car between two places.
|
12 |
+
|
13 |
Args:
|
14 |
start_location: the place from which you start your ride
|
15 |
destination_location: the place of arrival
|
|
|
17 |
"""
|
18 |
import googlemaps
|
19 |
import os
|
20 |
+
from datetime import datetime
|
21 |
gmaps = googlemaps.Client(os.getenv("GMAPS_API_KEY"))
|
|
|
22 |
if transportation_mode is None:
|
23 |
transportation_mode = "transit"
|
24 |
try:
|
|
|
30 |
)
|
31 |
return directions_result[0]["legs"][0]["duration"]["text"]
|
32 |
except Exception as e:
|
33 |
+
print(e)
|
34 |
return e
|