-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkayak.py
23 lines (20 loc) · 935 Bytes
/
kayak.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from crewai_tools import tool
from typing import Optional
@tool("Kayak tool")
def kayak(
departure: str, destination: str, date: str, return_date: Optional[str] = None
) -> str:
"""
Generates a Kayak URL for flights between departure and destination on the specified date.
:param departure: The IATA code for the departure airport (e.g., 'SOF' for Sofia)
:param destination: The IATA code for the destination airport (e.g., 'BER' for Berlin)
:param date: The date of the flight in the format 'YYYY-MM-DD'
:return_date: Only for two-way tickets. The date of return flight in the format 'YYYY-MM-DD'
:return: The Kayak URL for the flight search
"""
print(f"Generating Kayak URL for {departure} to {destination} on {date}")
URL = f"https://www.kayak.com/flights/{departure}-{destination}/{date}"
if return_date:
URL += f"/{return_date}"
URL += "?currency=USD"
return URL