Spaces:
Sleeping
Sleeping
Update app.py
Browse files32 unmodified lines33343536373816 unmodified lines5556575859606132 unmodified linesexcept Exception as e:return f"Error fetching time for timezone '{timezone}': {str(e)}"final_answer = FinalAnswerTool()16 unmodified linesagent = CodeAgent(model=model,tools=[final_answer], ## add your tools here (don't remove final answer)max_steps=6,verbosity_level=1,grammar=None,32 unmodified lines33343536373839404142434445464748495051525354555657585960616263646566676816 unmodified lines8586878889909132 unmodified linesexcept Exception as e:return f"Error fetching time for timezone '{timezone}': {str(e)}"@tooldef get_travel_duration(start_location: str, destination_location: str, transportation_mode: Optional[str] = None) -> str:"""Gets the travel time between two places.Args:start_location: the place from which you start your ridedestination_location: the place of arrivaltransportation_mode: The transportation mode, in 'driving', 'walking', 'bicycling', or 'transit'. Defaults to 'driving'."""import os # All imports are placed within the function, to allow for sharing to Hub.import googlemapsfrom datetime import datetimegmaps = googlemaps.Client(os.getenv("GMAPS_API_KEY"))if transportation_mode is None:transportation_mode = "driving"try:directions_result = gmaps.directions(start_location,destination_location,mode=transportation_mode,departure_time=datetime(2025, 6, 6, 11, 0), # At 11, date far in the future)if len(directions_result) == 0:return "No way found between these places with the required transportation mode."return directions_result[0]["legs"][0]["duration"]["text"]except Exception as e:print(e)return efinal_answer = FinalAnswerTool()16 unmodified linesagent = CodeAgent(model=model,tools=[final_answer], [get_travel_duration], ## add your tools here (don't remove final answer)max_steps=6,verbosity_level=1,grammar=None,
app.py+31-1