khagu/ios-website-bot
0
Locus RAG Bot
A RAG-based question-answering bot designed to provide information about LOCUS 2026 and past events. It uses web-crawled data, Medium articles, and local embeddings to answer user queries accurately.
Features
- Data Ingestion: Crawls
locus.com.npand related Medium articles. - Data Cleaning: Removes boilerplate (navbars, footers) for better RAG performance.
- Local Embeddings: Uses
Sentence Transformers(all-MiniLM-L6-v2) for free, local embedding generation. - Mistral AI: Uses Mistral AI's large model for high-quality answer generation.
- Vector Store: Powered by Pinecone for fast and scalable retrieval.
- FastAPI: Clean and efficient API for querying the bot.
Project Structure
locus-rag-bot/
├── app/ # FastAPI backend + RAG logic
│ ├── engine.py # Core RAG engine (LangChain + Pinecone + Mistral)
│ └── main.py # FastAPI application
├── data/ # Raw & cleaned markdown data
├── scripts/ # Utility scripts
│ ├── ingest.py # Crawls website content
│ ├── clean_data.py # Cleans markdown boilerplate
│ └── index_data.py # Indexes data to Pinecone
├── .env.example # Template for environment variables
├── Dockerfile # For containerized deployment
└── requirements.txt # Project dependenciesSetup
1. Local Environment
# Create and activate virtual environment
python3 -m venv venv
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt2. Configuration
Copy .env.example to .env and fill in your keys:
cp .env.example .envRequired keys:
MISTRAL_API_KEY: Get from Mistral AI Console.PINECONE_API_KEY: Get from Pinecone Dashboard.PINECONE_INDEX_NAME: Your Pinecone index name (dimension: 384).
Data Pipeline
1. Ingest Data
Crawls the website and saves content to data/.
python3 scripts/ingest.py2. Clean Data
Removes boilerplate from the crawled markdown.
python3 scripts/clean_data.py3. Index Data
Generates embeddings and uploads them to Pinecone.
python3 scripts/index_data.pyRunning the API
Locally
uvicorn app.main:app --host 0.0.0.0 --port 7860 --reloadThe API docs will be available at http://localhost:7860/docs.
Using Docker
# Build the image
docker build -t locus-rag-bot .
# Run the container
docker run -p 7860:7860 --env-file .env locus-rag-botAPI Usage
Health Check
GET /health
Query the Bot
POST /query
curl -X POST "http://localhost:7860/query" \
-H "Content-Type: application/json" \
-d '{"question": "What is LOCUS?"}'Response:
{
"answer": "LOCUS is an annual national technological festival organized by students of Pulchowk Campus...",
"context": ["..."]
}