gugukaka commited on
Commit
7f4931c
·
verified ·
1 Parent(s): 2e4d0ba

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -0
app.py CHANGED
@@ -12,6 +12,40 @@ import requests
12
  import pytz
13
  import yaml
14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
  @tool
17
  def get_current_time_in_timezone(timezone: str) -> str:
@@ -98,6 +132,7 @@ agent = CodeAgent(
98
  image_generation_tool,
99
  get_current_time_in_timezone,
100
  get_current_weather, # ✅ new weather tool
 
101
  DuckDuckGoSearchTool(),
102
  ],
103
  max_steps=6,
 
12
  import pytz
13
  import yaml
14
 
15
+ @tool
16
+ def get_travel_duration(start_location: str, destination_location: str, transportation_mode: Optional[str] = None) -> str:
17
+ """
18
+ Get travel time between two places.
19
+
20
+ Args:
21
+ start_location: Place from which you start your drive.
22
+ destination_location: Place of arrival.
23
+ transportation_mode: Transportation mode, e.g. 'walking', 'driving', 'bicycling', 'transit','motobike'.
24
+ """
25
+ import os
26
+ import googlemaps
27
+ from datetime import datetime
28
+
29
+ gmaps = googlemaps.Client(os.getenv("AIzaSyAFjYCOmBgyvaNNFSk1rW71hX1nWbrR6Ew"))
30
+
31
+ if transportation_mode is None:
32
+ transportation_mode = "motobike"
33
+
34
+ try:
35
+ directions_result = gmaps.directions(
36
+ start_location,
37
+ destination_location,
38
+ mode = transportation_mode,
39
+ departure_time = datetime(2026, 6, 6, 11, 0)
40
+
41
+ )
42
+ if len(directions_result) ==0:
43
+ return "No way found between these places with the required transportation mode."
44
+ return directions_result[0]['legs'][0]["duration"]["text"]
45
+ except Exception as e:
46
+ print(e)
47
+ return e
48
+
49
 
50
  @tool
51
  def get_current_time_in_timezone(timezone: str) -> str:
 
132
  image_generation_tool,
133
  get_current_time_in_timezone,
134
  get_current_weather, # ✅ new weather tool
135
+ get_travel_duration,
136
  DuckDuckGoSearchTool(),
137
  ],
138
  max_steps=6,