Skip to content

notoctavio/AI-Customer-Service-Chatbot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

✈️ SkyFlow Airlines AI Customer Service Chatbot

Python LangChain NVIDIA License Status

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

FeaturesDemoInstallationUsageArchitectureTechnologies


📋 Overview

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)

✨ Features

Core Capabilities

  • 🤖 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

Technical Features

  • Slot-Filling Extraction: Uses Pydantic models for structured data validation
  • Chain Composition: Modular architecture with RunnableAssign and RunnableLambda
  • 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

🎥 Demo

Chat Flow Example

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?

Screenshots

Gradio Web Interface
Clean, modern web UI with chat history
Gradio Interface

🚀 Installation

Prerequisites

Quick Start

  1. Clone the repository

    git clone https://github.com/yourusername/skyflow-airline-chatbot.git
    cd skyflow-airline-chatbot
  2. Create a virtual environment

    python -m venv .venv
    source .venv/bin/activate  # On Windows: .venv\Scripts\activate
  3. Install dependencies

    pip install langchain-nvidia-ai-endpoints langchain-core langchain \
                pydantic gradio python-dotenv rich
  4. 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
  5. Run the chatbot

    python airline_chatbot.py

💻 Usage

Web Interface (Default)

Simply run the script and it will launch a Gradio interface:

  python airline_chatbot.py

Access the chat at http://localhost:7860 or at the public URL provided by Gradio.

Terminal Mode

Edit the script to enable CLI mode:

use_gradio = False  # Change to False for terminal mode

Test Users

Try 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

🏗️ Architecture

System Design

┌─────────────────────────────────────────────────────────────┐
│                          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                         │
└─────────────────────────────────────────────────────────────┘

Key Components

  1. Knowledge Base (Pydantic Model)

    • Tracks: first_name, last_name, confirmation, discussion_summary, open_problems, current_goals
    • Validates and structures conversation state
  2. RExtract Utility

    • Custom runnable for slot-filling extraction
    • Parses LLM output into structured Pydantic objects
  3. Chain Architecture

    • Internal Chain: Updates state and retrieves context
    • External Chain: Generates user-facing responses
  4. Database Simulation

    • In-memory flight database with query function
    • Demonstrates RAG retrieval pattern

🛠️ Technologies

AI & ML Stack

  • 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

Interface & Development

  • Gradio - ML web interface framework
  • Rich - Beautiful terminal formatting
  • Python-dotenv - Environment variable management

📚 What I Learned

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

🚦 Future Enhancements

  • 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

🤝 Contributing

Contributions, issues, and feature requests are welcome!


👤 Author

Your Name


🙏 Acknowledgments

  • 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]

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages