A sophisticated multimodal AI airline assistant that combines LLM intelligence with real-time flight booking capabilities
Features • Demo • Installation • Usage • Architecture • API Reference
- Overview
- Features
- Demo
- Architecture
- Installation
- Configuration
- Usage
- Project Structure
- API Reference
- Technical Deep Dive
- Limitations & Future Work
- Contributing
- License
AirMate is an advanced demonstration of a multimodal airline assistant prototype that showcases the power of Large Language Models (LLMs) combined with deterministic business logic. Built as a comprehensive Jupyter Notebook, it integrates multiple AI APIs, programmatic tools, persistent storage, and a modern web interface to deliver a seamless flight booking experience.
- 🤖 Multi-LLM Integration: Leverages OpenAI GPT-4, Anthropic Claude, and Google Gemini APIs
- 🛠️ Tool-Calling Architecture: Implements function calling for dynamic, context-aware responses
- 🎨 Multimodal Capabilities: Generates travel images and converts text responses to speech
- 💾 Persistent Bookings: SQLite database for storing confirmed flight reservations
- 🌐 Translation Engine: Built-in multilingual support for global accessibility
- 🎭 Interactive UI: Beautiful Gradio interface for intuitive user interactions
| Feature | Description |
|---|---|
| 💰 Real-time Pricing | Fetch ticket prices for multiple destinations with dynamic discount calculations |
| Browse 100+ synthetic flights per city with real-time availability status | |
| 📝 Booking Management | Complete booking workflow with PNR generation and SQLite persistence |
| 🎨 AI-Generated Travel Art | DALL-E 3 powered destination artwork in pop-art style |
| 🔊 Text-to-Speech | Natural voice responses using OpenAI's TTS-1 model |
| 🌍 Multi-Language Support | Translate conversations to 100+ languages with validation |
| 🧠 Context-Aware Assistance | Maintains conversation history for coherent multi-turn dialogues |
- Tool Orchestration: LLM dynamically selects and chains function calls based on user intent
- Booking State Management: Tracks booking requests across conversation turns
- Data Validation: Integrated
pycountryfor language validation - Concise Responses: System-level prompt engineering for brief, accurate answers
- Error Handling: Robust error management across API calls and tool executions
User: "How much is a ticket to Moscow?"
├─> LLM analyzes query
├─> Calls get_ticket_prices("Moscow")
├─> Returns: "$363"
└─> Assistant: "A ticket to Moscow costs $363."
User: "What about with discounts?"
├─> LLM calls get_discounted_ticket_prices("Moscow")
├─> Calculates: $363 - 12% = $319
└─> Assistant: "Discounted price for Moscow is $319."
User: "Show me available flights"
├─> LLM calls get_flight_tickets("Moscow")
├─> Returns: 100 synthetic flights with details
├─> Generates travel artwork for Moscow
└─> Assistant: [Displays flights + travel image]
User: "Book flight AA1234 for John Doe"
├─> LLM calls confirm_and_save_booking(...)
├─> Saves to SQLite with PNR generation
└─> Assistant: "Booking confirmed! Your PNR is: X7K9M2L4"
(Add screenshots of your Gradio interface here)
┌─────────────────────────────────────────────────────────────┐
│ Gradio Web Interface │
│ ┌──────────┐ ┌──────────┐ ┌──────────────┐ │
│ │ Chat UI │ │ Image │ │ Translation │ │
│ └──────────┘ └──────────┘ └──────────────┘ │
└───────────────────────┬─────────────────────────────────────┘
│
┌──────────────▼──────────────┐
│ Chat Controller (chat()) │
│ - Message routing │
│ - History management │
│ - Tool orchestration │
└──────────────┬──────────────┘
│
┌──────────────▼──────────────┐
│ LLM Inference Layer │
│ ┌────────────────────────┐ │
│ │ OpenAI GPT-4-mini │ │
│ │ + Tool Calling Support │ │
│ └────────────────────────┘ │
└──────────────┬──────────────┘
│
┌──────────────▼──────────────┐
│ Tool Execution Engine │
│ (handle_all_tools()) │
└──┬─────────┬─────────┬──────┘
│ │ │
┌───────▼──┐ ┌──▼─────┐ ┌▼────────────┐
│ Pricing │ │ Flight │ │ Booking │
│ Tools │ │ Search │ │ Tools │
└──────────┘ └────────┘ └──┬──────────┘
│
┌───────▼────────┐
│ SQLite Database │
│ (bookings) │
└────────────────┘
┌────────────────────────────────────┐
│ Multimodal Enhancement Layer │
│ ┌──────────┐ ┌──────────────┐ │
│ │ DALL-E 3 │ │ TTS-1 │ │
│ │ (Images) │ │ (Voice) │ │
│ └──────────┘ └──────────────┘ │
└────────────────────────────────────┘
- User Input → Gradio Interface
- Message Routing → Chat controller with conversation history
- LLM Processing → GPT-4-mini with tool definitions
- Tool Invocation → Function execution based on LLM decision
- Response Generation → LLM synthesizes final answer
- Multimodal Enhancement → TTS + Image generation
- UI Update → Display text, audio, and visuals
- Python: 3.8 or higher
- FFmpeg: Required for audio processing (TTS playback)
- API Keys: OpenAI, Anthropic, and Google AI
git clone https://github.com/AsutoshaNanda/AirMate.git
cd AirMate# Using venv
python -m venv venv
# Activate on Windows
venv\Scripts\activate
# Activate on macOS/Linux
source venv/bin/activatepip install -r requirements.txtRequired packages:
gradio
requests
beautifulsoup4
python-dotenv
anthropic
openai
google-generativeai
pillow
pydub
pycountry
Windows (using Chocolatey):
choco install ffmpegmacOS (using Homebrew):
brew install ffmpegLinux (Ubuntu/Debian):
sudo apt-get install ffmpegCreate a .env file in the project root:
# .env
OPENAI_API_KEY=sk-proj-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
ANTHROPIC_API_KEY=sk-ant-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
GOOGLE_API_KEY=AIzaxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-
Add
.envto your.gitignore:.env *.env -
Use environment-specific configuration:
# For production import os OPENAI_API_KEY = os.environ.get('OPENAI_API_KEY')
-
Consider using secret management tools:
- AWS Secrets Manager
- Azure Key Vault
- HashiCorp Vault
# Install Jupyter if not already installed
pip install jupyter
# Launch notebook
jupyter notebook "Ultimate Flight AI Assistant.ipynb"Execution Steps:
- Run cells sequentially from top to bottom
- Ensure all API keys are loaded successfully
- Execute until the Gradio interface launches
- Interface will open at
http://127.0.0.1:7869
# Convert notebook to script
jupyter nbconvert --to script "Ultimate Flight AI Assistant.ipynb"
# Run the script
python "Ultimate Flight AI Assistant.py"Modify the last cell in the notebook:
ui.launch(share=True) # Creates a public URL for 72 hoursAirMate/
│
├── 📓 Ultimate Flight AI Assistant.ipynb # Main implementation
├── 📄 README.md # Project documentation
├── 📜 LICENSE # MIT License
├── 🔐 .env # Environment variables (not in repo)
├── 📋 requirements.txt # Python dependencies
├── 💾 flight_bookings.db # SQLite database (auto-generated)
│
└── 📚 Notebook Sections:
├── Section 1: Environment & API Setup
├── Section 2: Data & Tool Definitions
├── Section 3: Multimodal Capabilities
├── Section 4: Booking Persistence
├── Section 5: Chat Controller & Tool Orchestration
├── Section 6: Translation Engine
└── Section 7: Gradio UI Implementation
Main conversation handler
Parameters:
message(str): User's input messagehistory(list): List of (user_msg, assistant_msg) tuples
Returns:
tuple: (assistant_response, generated_image)
Example:
response, image = chat("Find flights to Tokyo", [])Fetches base ticket price for a destination
Parameters:
destination_city(str): City name (case-insensitive)
Returns:
str: Price string (e.g., "$363") or "Unknown"
Supported Cities:
Moscow, Paris, Tokyo, Berlin, London, Sydney, Rome, Dubai, Singapore, Mumbai
Calculates and returns discounted price
Parameters:
destination_city(str): City name
Returns:
str: Formatted message with discounted price
Example Response:
"Discounted price for Tokyo is $337"
Retrieves available flights for a destination
Parameters:
destination_city(str): Target city
Returns:
list: List of flight dictionaries
Flight Object Structure:
{
'flight_number': 'AA1234',
'departure_time': '08:30 AM',
'gate': 'A12',
'availability': 'Available' # or 'Not Available'
}Persists booking to database and generates PNR
Parameters:
destination_city(str): Destinationflight_number(str): Selected flightpassenger_names(list): List of passenger namesseat_type(str): Economy/Business/Firstpassenger_type(str): Adult/Child/Seniorfare_type(str): Regular/Flexibledate_of_travel(str): YYYY-MM-DD formatnum_passengers(int): Number of passengers
Returns:
{
'status': 'success',
'pnr': 'X7K9M2L4',
'booking_summary': {...}
}Generates travel-themed artwork
Parameters:
cities(list): List of city names
Returns:
PIL.Image: Generated artwork
Model: DALL-E 3
Style: Pop art travel poster
Converts text to speech and plays audio
Parameters:
message(str): Text to vocalize
Model: OpenAI TTS-1
Voice: Alloy
Output: Plays audio directly (local only)
Translates conversation to target language
Parameters:
message(str): Current messagehistory(list): Conversation historytarget_language(str): Target language (validated via pycountry)
Returns:
str: Translated text
Supported Languages: 100+ via pycountry validation
AirMate implements OpenAI's function calling specification:
tools = [
{
"type": "function",
"function": {
"name": "get_ticket_prices",
"description": "Fetch ticket price for a destination",
"parameters": {
"type": "object",
"properties": {
"destination_city": {
"type": "string",
"description": "The destination city"
}
},
"required": ["destination_city"]
}
}
}
# ... more tools
]Execution Flow:
- LLM receives user query + tool definitions
- If tool needed, LLM returns
tool_callsinstead of text handle_all_tools()executes Python functions- Tool results appended to message history
- LLM generates final natural language response
Table: bookings
| Column | Type | Description |
|---|---|---|
booking_id |
INTEGER PRIMARY KEY | Auto-increment ID |
pnr |
TEXT | 8-character alphanumeric PNR |
passenger_name |
TEXT | Full name |
destination_city |
TEXT | Destination |
flight_number |
TEXT | Flight identifier |
ticket_price |
TEXT | Price with currency |
seat_type |
TEXT | Economy/Business/First |
passenger_type |
TEXT | Adult/Child/Senior |
fare_type |
TEXT | Regular/Flexible |
date_of_travel |
TEXT | ISO 8601 date |
num_passengers |
INTEGER | Total passengers |
PNR Generation:
import random, string
pnr = ''.join(random.choices(string.ascii_uppercase + string.digits, k=8))
# Example: "X7K9M2L4"system_message = """
You are a helpful AI assistant for an airline.
Provide short, courteous answers, no more than 1 sentence.
Always be accurate. If you don't know the answer, say so.
"""Design Rationale:
- Brevity: Reduces token usage and response time
- Accuracy: Prevents hallucinations
- Honesty: Admits uncertainty rather than fabricating answers
Customization: Remove the "1 sentence" constraint for more detailed responses:
system_message = """
You are a professional airline customer service assistant.
Provide comprehensive, accurate information about flights, bookings, and travel.
Use a friendly, helpful tone and structure complex responses clearly.
"""def artist(cities: list) -> PIL.Image:
city = cities[0] if cities else "generic destination"
response = openai.images.generate(
model="dall-e-3",
prompt=f"A vibrant pop art travel poster for {city}...",
size="1024x1024",
response_format="b64_json"
)
image_data = base64.b64decode(response.data[0].b64_json)
return Image.open(io.BytesIO(image_data))def talker(message: str) -> None:
response = openai.audio.speech.create(
model="tts-1",
voice="alloy",
input=message
)
audio_data = io.BytesIO(response.content)
audio = AudioSegment.from_file(audio_data, format="mp3")
play(audio) # Requires ffmpeg| Issue | Impact | Priority |
|---|---|---|
| Synthetic Flight Data | No real-time inventory | 🔴 High |
| Local SQLite Storage | No multi-user support | 🟡 Medium |
| No Authentication | Security risk for production | 🔴 High |
| TTS Local Playback | Doesn't work in server deployments | 🟡 Medium |
| No Payment Gateway | Can't process real transactions | 🔴 High |
| Limited Error Handling | API failures may crash the app | 🟠 Medium-High |
| No Rate Limiting | Vulnerable to API quota exhaustion | 🟡 Medium |
- Real Flight API Integration: Amadeus/Skyscanner API
- PostgreSQL Migration: Replace SQLite with production DB
- User Authentication: JWT-based auth system
- Payment Integration: Stripe/PayPal gateway
- Comprehensive Logging: ELK stack integration
- Booking Modifications: Cancel/reschedule functionality
- PNR Retrieval System: Lookup existing bookings
- Email Notifications: Booking confirmations via SendGrid
- Mobile App: React Native companion app
- Admin Dashboard: Analytics and booking management
- Async API Calls: FastAPI backend with asyncio
- Caching Layer: Redis for flight data caching
- Load Balancing: Docker + Kubernetes deployment
- CDN Integration: Cloudflare for static assets
- Monitoring: Prometheus + Grafana dashboards
- Multi-Agent System: Specialized agents for search/booking/support
- RAG Integration: Vector DB for policy/FAQ retrieval
- Sentiment Analysis: Detect frustrated users and escalate
- Voice Interface: Real-time voice booking via Whisper API
- Predictive Pricing: ML models for price forecasting
We welcome contributions! Here's how you can help:
# Fork and clone
git clone https://github.com/YOUR_USERNAME/AirMate.git
cd AirMate
# Create feature branch
git checkout -b feature/amazing-feature
# Make changes and test
python -m pytest tests/
# Commit with conventional commits
git commit -m "feat: add multi-city search"
# Push and create PR
git push origin feature/amazing-feature- Follow PEP 8 style guide
- Add unit tests for new features
- Update documentation for API changes
- Keep commits atomic and well-described
- Test on Python 3.8, 3.9, 3.10, 3.11
- 🐛 Bug fixes and error handling
- 📚 Documentation improvements
- 🧪 Unit test coverage
- 🎨 UI/UX enhancements
- 🌐 Internationalization (i18n)
This project is licensed under the MIT License - see the LICENSE file for details.
MIT License
Copyright (c) 2025 Asutosha Nanda
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Author: Asutosha Nanda
GitHub: @AsutoshaNanda
Repository: AirMate
- 🐛 Bug Reports: GitHub Issues
- 💬 Discussions: GitHub Discussions
- 📧 Email: Open an issue for contact information
- OpenAI - GPT-4 and DALL-E 3 APIs
- Anthropic - Claude API integration
- Google - Gemini API support
- Gradio Team - Exceptional UI framework
- Open Source Community - All the amazing libraries used