File size: 1,739 Bytes
0f04201 fea02f6 63ec258 fea02f6 962f893 63ec258 7b96044 63ec258 7b96044 63ec258 fea02f6 0f04201 fea02f6 0f04201 fea02f6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
from langchain.tools import tool
from .common import vehicle, Speed
STATUS_TEMPLATE = """The current location is: {location}
Current coordinates: {lat}, {lon}
The current date and time: {date} {time}
The current destination is: {destination}"""
def vehicle_status() -> tuple[str, dict[str, str]]:
"""Get current vehicle status, which includes, location, date, time, destination.
Call this to get the current destination or location of the car/vehicle.
Returns:
dict[str, str]: The vehicle status. For example:
{
"location": "Luxembourg Gare, Luxembourg",
"lat": 49.6000,
"lon": 6.1333,
"date": "2025-03-29",
"time": "08:00:20",
"destination": "Kirchberg Campus, Kirchberg"
}
"""
# vs = {
# "location": "Luxembourg Gare, Luxembourg",
# "lat": 49.6000,
# "lon": 6.1333,
# "date": "2025-03-29",
# "time": "08:00:20",
# "destination": "Kirchberg Campus, Luxembourg"
# }
vs = vehicle.dict()
vs["lat"] = vs["location_coordinates"][0]
vs["lon"] = vs["location_coordinates"][1]
return STATUS_TEMPLATE.format(**vs), vs
@tool
def set_vehicle_speed(speed: Speed) -> str:
"""Set the speed of the vehicle.
Args:
speed (Speed): The speed of the vehicle. ("slow", "fast")
"""
vehicle.speed = speed
return f"The vehicle speed is set to {speed.value}."
@tool
def set_vehicle_destination(destination: str) -> str:
"""Set the destination of the vehicle.
Args:
destination (str): The destination of the vehicle.
"""
vehicle.destination = destination
return f"The vehicle destination is set to {destination}."
|