Spaces:
Sleeping
title: BGP Troubleshooting RAG Chatbot
emoji: π
colorFrom: blue
colorTo: green
sdk: docker
app_file: app.py
pinned: false
BGP Troubleshooting RAG Chatbot β Cloud Deployment
Domain-specific RAG chatbot for Cisco BGP troubleshooting, deployed on HuggingFace Spaces with Groq cloud LLM inference. No local setup required β visit the URL and start asking questions.
π Live Demo: huggingface.co/spaces/VP21/bgp-rag-groq
π Local Version (nettune): github.com/vanip3/bgp-rag-chatbot
Architecture
User (Browser)
β
βΌ
HuggingFace Spaces
(Streamlit App β app.py)
β
ββββΊ FAISS Vector Store βββ HuggingFace Embeddings
β (Pre-built index, (all-MiniLM-L6-v2)
β committed to repo)
β
ββββΊ Top-4 Relevant Chunks
β
βΌ
Groq Cloud API
(llama-3.1-8b-instant)
β
βΌ
Answer + Source Documents
The user's question is embedded locally using all-MiniLM-L6-v2, compared against the pre-built FAISS index to retrieve the 4 most relevant document chunks, then passed to Llama 3.1 8B via the Groq API for answer generation. Source attribution shows which documents informed each answer.
Local vs Cloud Version Comparison
| Local (Project 2) | Cloud (This Project) | |
|---|---|---|
| LLM | nettune (fine-tuned, Ollama) | Llama 3.1 8B (Groq API) |
| Embeddings | all-MiniLM-L6-v2 | all-MiniLM-L6-v2 |
| Vector Store | FAISS (built at runtime) | FAISS (pre-built index) |
| Access | Local only | Public URL |
| Cost | Free (local GPU/CPU) | Free (Groq free tier) |
| Setup needed | Ollama + model download | None β visit URL |
Key Concepts Demonstrated
RAG pipeline cloud deployment β the same retrieval-augmented generation pattern from the local version runs on a public URL with zero infrastructure management. HuggingFace Spaces handles the server, networking, and TLS.
Secure API key management β GROQ_API_KEY is stored in HF Spaces Secrets (encrypted at rest, injected as an environment variable at runtime). It never appears in code or git history. This is the same pattern used in AWS Secrets Manager, GCP Secret Manager, and Azure Key Vault.
Pre-built vector index strategy β the FAISS index is built once locally (python ingest.py) and committed to the repo as binary files (faiss_index/index.faiss, faiss_index/index.pkl). The Space loads these files in ~3 seconds instead of spending 3-5 minutes building the index on every cold start β a critical optimization for serverless deployments with CPU limits.
Cloud LLM inference via Groq API β Groq's LPU (Language Processing Unit) hardware delivers ~500 tokens/second on Llama 3.1 8B, free tier, no credit card required. The API is OpenAI-compatible, making it a drop-in for any LangChain LLM component.
Production Streamlit deployment β explicit API key validation at startup, graceful error messaging for operators who fork without setting secrets, persistent chat history via st.session_state, and source document attribution on every response.
Knowledge Base
Six documents indexed from Cisco BGP documentation and production telemetry:
| File | Content |
|---|---|
bgp_states_guide.txt |
BGP FSM states (IDLE β ESTABLISHED), causes, and verification commands |
bgp_troubleshooting_guide.txt |
Systematic methodology for session failures, flapping, route issues |
bgp_show_commands.txt |
Complete show command reference with output interpretation |
bgp_error_messages.txt |
Syslog message reference with NOTIFICATION error codes and remediation |
bgp_configuration_guide.txt |
iBGP, Route Reflectors, authentication, filtering, timers |
bgp_telemetry_logs.txt |
30-day production syslog data with incident analysis |
How to Deploy Your Own Copy
- Fork this repo (or create a new HuggingFace Space and push directly)
- Create a new HuggingFace Space β select Streamlit as the SDK
- Push this repo to the Space:
git remote add space https://huggingface.co/spaces/YOUR-USERNAME/YOUR-SPACE-NAME git push space main - In Space Settings β Variables and Secrets, add:
- Name:
GROQ_API_KEY - Value: your key from console.groq.com
- Name:
- The Space auto-builds and deploys β your public URL is live in ~2 minutes
Local Development
# 1. Clone
git clone https://github.com/vanip3/bgp-rag-groq
cd bgp-rag-groq
# 2. Install dependencies
pip install -r requirements.txt
# 3. Build FAISS index (one-time)
python ingest.py
# 4. Set API key
export GROQ_API_KEY=gsk_... # Linux/macOS
# or: set GROQ_API_KEY=gsk_... # Windows CMD
# 5. Run the app
streamlit run app.py
To verify the RAG chain works before launching the UI:
python rag_chain.py
File Structure
bgp-rag-groq/
βββ app.py # Streamlit UI (HF Spaces entry point)
βββ rag_chain.py # RAG chain: Groq LLM + FAISS retrieval
βββ ingest.py # Build FAISS index (run once locally)
βββ requirements.txt # Auto-installed by HF Spaces
βββ data/
β βββ docs/
β β βββ bgp_states_guide.txt
β β βββ bgp_troubleshooting_guide.txt
β β βββ bgp_show_commands.txt
β β βββ bgp_error_messages.txt
β β βββ bgp_configuration_guide.txt
β βββ telemetry/
β βββ bgp_telemetry_logs.txt
βββ faiss_index/ # Pre-built index β committed to repo
βββ index.faiss
βββ index.pkl
Tech Stack
- LangChain β RAG chain orchestration (
RetrievalQA,PromptTemplate) - Groq API β Cloud LLM inference (
llama-3.1-8b-instant, free tier) - HuggingFace Embeddings β
sentence-transformers/all-MiniLM-L6-v2(local, CPU) - FAISS β Vector similarity search (Facebook AI Research)
- Streamlit β Web UI (auto-detected by HF Spaces)
- HuggingFace Spaces β Free cloud deployment platform