An intelligent conversational AI agent built with state-of-the-art LLMs and RAG architecture
Built as part of NVIDIA's "Building RAG Agents with LLMs" Course
Features • Demo • Installation • Usage • Architecture • Technologies
SkyFlow Airlines Chatbot is an advanced AI-powered customer service agent that demonstrates the implementation of Retrieval-Augmented Generation (RAG) using LangChain and NVIDIA's AI endpoints. The chatbot intelligently manages conversation state, extracts user information, and retrieves flight data to provide personalized customer support.
This project showcases modern AI engineering practices including:
- 🧠 Stateful conversation management with dynamic knowledge base updates
- 🔍 Information extraction using structured output parsing with Pydantic
- 🔗 Chain-based architecture leveraging LangChain's composable components
- 🚀 Production-grade LLMs (Llama 3.3 70B & Mixtral 8x22B via NVIDIA AI Endpoints)
- 🤖 Intelligent Conversation Flow: Maintains context across multiple turns using a running knowledge base
- 👤 Automatic Information Extraction: Extracts and tracks user details (name, confirmation number) without explicit prompting
- 📊 Dynamic Database Queries: Simulates real-time flight information retrieval based on conversation state
- 💬 Natural Language Interface: Seamless chat experience with streaming responses
- 🎨 Dual Interface Modes:
- Web-based UI using Gradio
- Terminal-based interface for CLI enthusiasts
- Slot-Filling Extraction: Uses Pydantic models for structured data validation
- Chain Composition: Modular architecture with
RunnableAssignandRunnableLambda - Multi-Model Strategy:
- Llama 3.3 70B for conversational responses
- Mixtral 8x22B for information extraction tasks
- Streaming Support: Real-time token-by-token response generation
- State Persistence: Global state management for conversation continuity
User: Hi, can you help me with my flight?
Bot: Hello! I'm your SkyFlow agent! How can I help you?
User: I need to know my departure time
Bot: I'd be happy to help! Could you please provide your first name,
last name, and confirmation number?
User: I'm Jane Doe, confirmation 12345
Bot: Thank you! Jane Doe's flight from San Jose to New Orleans departs
at 12:30 PM tomorrow and lands at 9:30 PM. Is there anything else
you'd like to know?
- Python 3.10 or higher
- NVIDIA API Key (Get one here)
-
Clone the repository
git clone https://github.com/yourusername/skyflow-airline-chatbot.git cd skyflow-airline-chatbot -
Create a virtual environment
python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate
-
Install dependencies
pip install langchain-nvidia-ai-endpoints langchain-core langchain \ pydantic gradio python-dotenv rich -
Configure your API key
cp .env.example .env # Edit .env and add your NVIDIA API key echo "NVIDIA_API_KEY=your-api-key-here" > .env
-
Run the chatbot
python airline_chatbot.py
Simply run the script and it will launch a Gradio interface:
python airline_chatbot.pyAccess the chat at http://localhost:7860 or at the public URL provided by Gradio.
Edit the script to enable CLI mode:
use_gradio = False # Change to False for terminal modeTry these sample users to test the flight lookup functionality:
| Name | Confirmation | Route | Departure Time |
|---|---|---|---|
| Jane Doe | 12345 | San Jose → New Orleans | Tomorrow, 12:30 PM |
| John Smith | 54321 | New York → Los Angeles | Sunday, 8:00 AM |
| Alice Johnson | 98765 | Chicago → Miami | Next week, 7:00 PM |
| Bob Brown | 56789 | Dallas → Seattle | Yesterday, 1:00 PM |
┌─────────────────────────────────────────────────────────────┐
│ User Input │
└──────────────────────────────┬──────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ Internal Chain │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ Knowledge Base Getter (Mixtral 8x22B) │ │
│ │ • Extracts user info from conversation │ │
│ │ • Updates running state with Pydantic validation │ │
│ └───────────────────────────┬──────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ Database Getter │ │
│ │ • Constructs query key from knowledge base │ │
│ │ • Retrieves flight info from simulated DB │ │
│ └───────────────────────────┬──────────────────────────────│
└──────────────────────────────┼──────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ External Chain │
│ • Generates natural language response (Llama 3.3 70B) │
│ • Streams tokens to user interface │
└─────────────────────────────────────────────────────────────┘
-
Knowledge Base (Pydantic Model)
- Tracks:
first_name,last_name,confirmation,discussion_summary,open_problems,current_goals - Validates and structures conversation state
- Tracks:
-
RExtract Utility
- Custom runnable for slot-filling extraction
- Parses LLM output into structured Pydantic objects
-
Chain Architecture
- Internal Chain: Updates state and retrieves context
- External Chain: Generates user-facing responses
-
Database Simulation
- In-memory flight database with query function
- Demonstrates RAG retrieval pattern
- LangChain - Framework for building LLM applications
- NVIDIA AI Endpoints - Cloud-hosted LLM inference
- Meta Llama 3.3 70B Instruct
- Mistral Mixtral 8x22B Instruct
- Pydantic - Data validation and settings management
- Gradio - ML web interface framework
- Rich - Beautiful terminal formatting
- Python-dotenv - Environment variable management
This project was developed as part of NVIDIA's "Building RAG Agents with LLMs" course, where I gained hands-on experience with:
- ✅ Designing and implementing RAG (Retrieval-Augmented Generation) systems
- ✅ Managing stateful conversations with LLMs
- ✅ Composing complex LangChain pipelines with runnables
- ✅ Implementing structured output parsing for information extraction
- ✅ Working with multiple LLMs for specialized tasks
- ✅ Building production-ready AI applications with proper error handling
- ✅ Securing API keys and managing environment configurations
- Integration with real airline databases
- Multi-language support
- Voice interface with speech-to-text
- Advanced analytics dashboard
- User authentication and session management
- Deployment to cloud platforms (AWS, Azure, GCP)
- A/B testing framework for prompt optimization
Contributions, issues, and feature requests are welcome!
Your Name
- GitHub: @notoctavio
- LinkedIn: Vizaru Octavio-Daniel
- Instagram: @octavio.1312
- NVIDIA for providing the "Building RAG Agents with LLMs" course and AI endpoints
- LangChain community for excellent documentation and examples
- Meta and Mistral AI for their powerful open-source LLMs
Made with ❤️ and 🤖 by [Octavio Daniel Vizaru]
