Files
patchy631--ai-engineering-hub/flight-booking-crew/kayak.py
T
2026-07-13 12:37:47 +08:00

25 lines
994 B
Python

from crewai.tools import tool
from typing import Optional
@tool("Kayak tool")
def kayak_search(
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
# Export the decorated function
kayak = kayak_search