The RAG-based Flight Query Bot is a Streamlit-powered web application that allows users to query flight information using natural language (e.g., "Show me flights from New York to London"). It uses Retrieval-Augmented Generation (RAG) with an Ollama language model to extract entities from queries and retrieve flight data from a mock database. The project is deployed on a local Kubernetes cluster using Minikube and includes a CI/CD pipeline with GitHub Actions for automated testing.
RAG-based-Flight-Query-Bot/
├── .github/
│ └── workflows/
│ └── test.yml
├── tests/
│ └── test_mock_database.py
├── mock_database.py
├── query_handler.py
├── ollama_api.py
├── app.py (optional)
├── requirements.txt
└── README.md
- Frontend: Streamlit UI (
app.py) for user interaction. - Backend:
query_handler.py: Processes queries and extracts entities using Ollama.ollama_api.py: Integrates with the Ollama LLM for natural language responses.mock_database.py: Provides mock flight data and search functionality.
- Deployment: Kubernetes on Minikube with two services:
flight-assistant-service(Streamlit) andollama-service(Ollama server). - CI/CD: GitHub Actions runs unit tests on every push or pull request.
- Windows, macOS, or Linux
- Python 3.10 or 3.11
- Docker Desktop (for building images and running Minikube)
- Minikube (for local Kubernetes)
- kubectl (Kubernetes CLI)
- Git (for cloning the repository)
Clone this project to your local machine:
git clone https://github.com/RobuRishabh/RAG-based-Flight-Query-Bot.git
cd RAG-based-Flight-Query-BotCreate a virtual environment and install required Python packages:
# Create a virtual environment (optional but recommended)
python -m venv flightquerybot
# Activate it (Windows)
flightquerybot\Scripts\activate
# Activate it (macOS/Linux)
source flightquerybot/bin/activate
# Install dependencies
pip install -r requirements.txtThe project uses a local Ollama server for language processing.
- Download and install Ollama from ollama.com.
- Follow the installation instructions for your OS.
ollama pull qwen2.5-coder:3bThis downloads the qwen2.5-coder:3b model (default for this project).
ollama serveKeep this terminal open. The server runs at http://localhost:11434.
Minikube creates a local Kubernetes cluster.
Follow the official Minikube installation guide for your OS. Example for Windows (using PowerShell as admin):
minikube startminikube statusEnsure host, kubelet, and apiserver are Running.
Build the flight-assistant Docker image using Minikube’s Docker daemon:
# Set Minikube's Docker environment
eval $(minikube docker-env)
# Build the image
docker build -t flight-assistant:latest .Deploy the application and Ollama server to Minikube:
# Deploy Ollama server
kubectl apply -f ollama-deployment.yaml
kubectl apply -f ollama-service.yaml
# Deploy Flight Assistant app
kubectl apply -f deployment.yaml
kubectl apply -f service.yamlminikube tunnelKeep this running to assign an external IP.
minikube service flight-assistant-service --urlExample output: http://192.168.49.2:8501.
Open the URL in your browser to interact with the chatbot.
- Open the Streamlit app in your browser.
- Enter a query in the text box and press Enter.
- The bot processes your query and displays flight details or a "no flights found" message.
"Show me flight NY100"→ Shows details for flightNY100."What are the flights from New York to London?"→ Lists matching flights."Flights from Chicago"→ Shows flights departing from Chicago."Flight XYZ999"→ Returns "No flights found" (invalid flight).
This project uses GitHub Actions for Continuous Integration (CI) to ensure code quality. The workflow is defined in .github/workflows/test.yml.
- Trigger: Runs on every
pushorpull_requestto themainbranch. - Environment: Uses an
ubuntu-latestrunner with Python 3.10. - Steps:
- Checkout code:
- uses: actions/checkout@v4
- Set up Python:
- uses: actions/setup-python@v5 with: python-version: '3.10'
- Install dependencies:
- run: | python -m pip install --upgrade pip pip install -r requirements.txt
- Run tests:
- run: | python -m unittest discover -s tests -p "test_*.py"
- Checkout code:
To test before pushing:
# Activate virtual environment
flightquerybot\Scripts\activate # Windows
source flightquerybot/bin/activate # macOS/Linux
# Run all tests
python -m unittest discover -s tests -p "test_*.py"Expected output: Ran X tests in Y.YYYs OK.
minikube stopminikube deleteIf the UI doesn’t load, check pod logs:
kubectl logs -l app=flight-assistant
kubectl logs -l app=ollamaEnsure minikube tunnel is running for external access.