Deployment Guide for Streamlit PDF Chatbot with FAISS and Groq
This guide walks you through:
- Preparing your project locally.
- Pushing your code to GitHub.
- Deploying your app on Streamlit Cloud.
- Setting up your GROQ API key securely.
Prerequisites
- Git installed locally.
- GitHub account created.
- Streamlit Cloud account (sign in with GitHub).
- Python 3.9+ installed.
- GROQ API Key generated.
Project Structure
Your project should look like this:
project/
│── docs/ # Folder containing your PDF files
│── .env # Your environment variables
│── .gitignore
│── backend.py
│── chunks.pkl # Pickled chunks
│── faiss_index.bin # FAISS index (generated after indexing)
│── frontend.py
│── pyproject.toml
│── uv.lock
Step 1: Build the FAISS Index Locally
Before deploying, preprocess PDFs and build the docucment backend:
python -m backend
This generates:
-
faiss_index.bin
→ FAISS vector index -
chunks.pkl
→ Pickled text chunks
These files must be committed to GitHub for the app to work.
Step 2: Push Code to GitHub
Initialize Git:
git init
Add a .gitignore to your root directory and these in there:
__pycache__
app.egg-info
*.pyc
.mypy_cache
.coverage
htmlcov
.cache
.venv
.env
Permissions.txt
commands.txt
docs/personal
.vscode
Add files:
git add .
Commit:
git commit -m "Initial commit - PDF Chatbot with FAISS"
Create a new repository on GitHub.
Link remote:
git remote add origin https://github.com/<your-username>/<repo-name>.git
Push:
git branch -M main
git push -u origin main
Step 3: Deploy on Streamlit Cloud
- Go to Streamlit Cloud.
- Log in with your GitHub account.
- Click New app.
- Choose your repository and branch (
master
). - Set the entrypoint to
frontend.py
. - Go to ⋮ > Settings > Secrets
- Add:
GROQ_API_KEY = "your_api_key_here"
Updating PDFs
When you add new PDFs:
- Place them inside
docs/
. - Run:
python -m backend
- Commit and push updates:
git add .
git commit -m "Updated index with new PDFs"
git push
- Streamlit Cloud will automatically redeploy with the new index.
Troubleshooting
FAISS index not found → Run
python -m backend
before deploying.Wrong answers → Make sure your
docs/
folder had the right PDFs before indexing.Key errors → Double-check you added
GROQ_API_KEY
in Streamlit secrets.
🎉 Done! Your Streamlit PDF Chatbot with FAISS is now live, secure, and powered by GROQ.
Top comments (0)