DEV Community

JeffMint
JeffMint

Posted on

Chatbot with Python(Deployment Phase)

Deployment Guide for Streamlit PDF Chatbot with FAISS and Groq

This guide walks you through:

  1. Preparing your project locally.
  2. Pushing your code to GitHub.
  3. Deploying your app on Streamlit Cloud.
  4. Setting up your GROQ API key securely.

Prerequisites


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

Enter fullscreen mode Exit fullscreen mode

Step 1: Build the FAISS Index Locally

Before deploying, preprocess PDFs and build the docucment backend:

python -m backend
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Add files:

git add .
Enter fullscreen mode Exit fullscreen mode

Commit:

git commit -m "Initial commit - PDF Chatbot with FAISS"
Enter fullscreen mode Exit fullscreen mode

Create a new repository on GitHub.

Link remote:

git remote add origin https://github.com/<your-username>/<repo-name>.git
Enter fullscreen mode Exit fullscreen mode

Push:

git branch -M main
git push -u origin main
Enter fullscreen mode Exit fullscreen mode

Step 3: Deploy on Streamlit Cloud

  1. Go to Streamlit Cloud.
  2. Log in with your GitHub account.
  3. Click New app.
  4. Choose your repository and branch (master).
  5. Set the entrypoint to frontend.py.
  6. Go to ⋮ > Settings > Secrets
  7. Add:
GROQ_API_KEY = "your_api_key_here"
Enter fullscreen mode Exit fullscreen mode

Updating PDFs

When you add new PDFs:

  1. Place them inside docs/.
  2. Run:
python -m backend
Enter fullscreen mode Exit fullscreen mode
  1. Commit and push updates:
git add .
git commit -m "Updated index with new PDFs"
git push
Enter fullscreen mode Exit fullscreen mode
  1. 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)