def generate_list_flights()

in src/frontend_service/orchestrator/langchain_tools/tools.py [0:0]


def generate_list_flights(client: aiohttp.ClientSession):
    async def list_flights(
        departure_airport: str,
        arrival_airport: str,
        date: str,
    ):
        params = {
            "departure_airport": departure_airport,
            "arrival_airport": arrival_airport,
            "date": date,
        }
        response = await client.get(
            url=f"{BASE_URL}/flights/search",
            params=filter_none_values(params),
            headers=get_headers(client),
        )

        response_json = await response.json()
        response_results = response_json.get("results")
        if len(response_results) < 1:
            return "There are no flights matching that query. Let the user know there are no results."
        else:
            return response_results

    return list_flights