Function bodies 3 total
format_results function · python · L16-L20 (5 LOC)server.py
def format_results(result) -> dict:
return {
"current_price": result.current_price,
"flights": [asdict(f) for f in result.flights],
}search_flights function · python · L27-L54 (28 LOC)server.py
def search_flights(
origin: str,
destination: str,
date: str,
return_date: str | None = None,
seat: SeatType = "economy",
adults: int = 1,
children: int = 0,
infants: int = 0,
max_stops: int | None = None,
) -> dict:
"""Search for flights between two airports. Dates should be YYYY-MM-DD format. Airport codes are 3-letter IATA codes (e.g. SFO, NRT, LHR). Returns flight options with airline name, departure/arrival times, duration, stops, and price."""
flight_data = [FlightData(date=date, from_airport=origin, to_airport=destination)]
trip = "one-way"
if return_date:
flight_data.append(FlightData(date=return_date, from_airport=destination, to_airport=origin))
trip = "round-trip"
result = get_flights(
flight_data=flight_data,
trip=trip,
passengers=Passengers(adults=adults, children=children, infants_in_seat=infants),
seat=seat,
fetch_mode="local",
max_stops=max_stops,
search_multi_city function · python · L58-L75 (18 LOC)server.py
def search_multi_city(
flights: list[dict],
seat: SeatType = "economy",
adults: int = 1,
) -> dict:
"""Search for multi-city flight itineraries. Each entry in flights should have origin, destination, and date keys. Example: [{"origin": "SFO", "destination": "NRT", "date": "2026-07-15"}, {"origin": "NRT", "destination": "LHR", "date": "2026-07-22"}]."""
flight_data = [
FlightData(date=f["date"], from_airport=f["origin"], to_airport=f["destination"])
for f in flights
]
result = get_flights(
flight_data=flight_data,
trip="multi-city",
passengers=Passengers(adults=adults),
seat=seat,
fetch_mode="local",
)
return format_results(result)