This program implements a chatbot system that combines Retrieval-Augmented Generation (RAG) and API-based flight search to answer user queries related to airline policies and flight availability. It processes user input to classify and respond appropriately, leveraging LLMs, vector databases, and external APIs.
-
Query Classification:
- Classifies user queries into three categories:
- RAG-Related: Queries about travel policies (e.g., luggage rules, traveling with pets, etc.).
- API-Related: Questions requiring live flight information (e.g., cheapest flights, flight performance).
- General: Queries outside the chatbot's scope.
- Classifies user queries into three categories:
-
Policy Retrieval:
- Uses LLamaIndex with ChromaDB as the vector store for retrieving policy documents.
- Handles both specific airline queries and general ones using metadata filtering.
-
Flight Search:
- Supports various flight queries via APIs, including:
- Flight availability between two cities.
- Cheapest flight offers.
- Performance of specific airports.
- Supports various flight queries via APIs, including:
-
Adaptive Query Engine:
- Dynamically configures the query engine based on the classification of the input (e.g., specific airline queries use metadata filtering).
-
Multimodal Input Handling:
- Accepts free text from the user and extracts structured information (e.g., origin, destination, and date) using LLMs.
- Main
- Create RAG Index
- Define the index, vector store, and retriever while providing metadata.
- Current metadata includes:
- Bag, pets, and sports equipment policies of 3 airlines:
- American Airlines
- Delta Airlines
- United Airlines
- Bag, pets, and sports equipment policies of 3 airlines:
- Prompt Handling
- Continuously asks for user input until the user says
exit,quit, orbye(currently hard-coded, can be enhanced with LLM).
- Continuously asks for user input until the user says
- Query Classification
- RAG Query:
- Call
create_prompt. - Execute
classify_rag_queryto determine the relevant metadata. - Build the query using the RAG output.
- Return the result.
- Call
- API-Related Query:
- Classify the type of API call required:
- Call
FlightAvailBtwCitiesfor flights between two cities on a specific date. - Call
FlightInspirationSearchfor the cheapest flights from a location. - Call
FlightOffersSearchfor the cheapest flights between two cities.
- Call
- Classify the type of API call required:
- Other Queries:
- Return a response indicating the chatbot cannot answer the question.
- RAG Query:
- Flights between two cities on a specific day.
- Number of seats available on a flight between two cities.
- Filtering based on:
- Fastest flights.
- Flights below a specific duration.
- Non-stop flights.
- Time of day (may be ambiguous).
- Avoiding particular layovers (e.g., country-based).
- Avoiding or preferring specific carriers.
number_of_stopsalways returns 0. Needs adjustment to reflect duration.- Multiple flights are represented as a second instance of a segment.
- Cheapest flights from a specific location within a date range.
- Flights based on a budget (e.g., "My budget is $10,000. What are the cheapest flights?").
- Calls
AirlineCodeLookupfor comprehensive answers.
ViewBy = Datefetches more options when explicitly mentioned, even though it's a default parameter.
- "What are the rates?"
- Location filtering is not available in the input.
- Does not answer "Cheapest flight between two locations" (use
FlightOffersSearchfor this).
- Cheapest flights between two cities (sorted by price).
- Filters for:
- Airlines (include or exclude).
- Class (ECONOMY, PREMIUM_ECONOMY, BUSINESS, FIRST).
- Non-stop flights (not working currently).
- Maximum price per traveler.
- Only single-date queries are allowed; multi-query is required for multiple dates.
- Provide just the cheapest option or ask follow-up questions for clarity if input is minimal.
- Departure and arrival times.
number_of_stopsinFlightAvailBtwCitiesis returning 0 universally.- Non-stop filter in
FlightOffersSearchis currently non-functional. - Location filtering in
FlightInspirationSearchis absent. - Multi-date queries require multiple function calls.