Skip to content
All projects
AIJun 2026

PDF RAG Chatbot: Answers Only From Your Documents

Answers Only From Your Documents

A retrieval-augmented chatbot that answers questions only from your own PDF files. It reads a local folder, builds a local FAISS index, retrieves the most relevant chunks for each question, and asks your company's LLM to answer from that context alone. When the answer isn't there, it replies "I could not find this."

PDF RAG Chatbot
Year
Jun 2026
Scope
solo build
Type
AI
Status
Completed
01

Overview

Teams sit on folders of PDFs (policies, manuals, contracts) and need answers from them without a general-purpose model inventing what the documents don't say. This is a simple RAG chatbot: point it at a documents/ folder and it answers strictly from those files, with a fixed fallback message when the answer isn't in them.

02

The hard parts

  1. 01

    Keeping the model from answering beyond the documents with a plausible answer that isn't in them.

  2. 02

    Running entirely against an internal, OpenAI-compatible company gateway behind a firewall.

  3. 03

    Keeping embedding and chat model names in sync so the index and queries never mismatch.

  4. 04

    Staying simple enough to set up with no database or hosted vector service.

03

The approach

ingest.py loads every PDF, splits the text into overlapping chunks of about 1,000 characters, embeds each through the company's embedding API, and saves a FAISS index locally. app.py loads that index and, for each question, retrieves the top-k relevant chunks and passes them to the LLM with strict instructions to answer only from that context, returning "I could not find this information in the provided documents" otherwise. Both scripts read the embedding model from a shared .env so they can't drift, and the OpenAI-compatible client works with any internal gateway, or with OpenAI, Azure or Gemini after a one-line change.

04

Outcome

A minimal Streamlit chat window with no login, database or external vector service: drop PDFs in a folder, run ingest, and ask questions. Nothing is downloaded from HuggingFace, and both embeddings and answers come from the configured gateway, so it runs behind a corporate firewall. Settings sit near the top of each script.

05

What I'd do differently

People trust a RAG system that says "I don't know" cleanly, so the grounding prompt and the fallback message mattered more than any retrieval trick. Keeping the model and endpoint in config, with no code changes to switch providers, made it portable across company gateways.

06

Stack

rag
LangChainFAISS (local vector store)
ingest
PyPDFchunking (1000 / 150 overlap)
models
Any OpenAI-compatible endpoint (embeddings + chat)
ui
Streamlit

Like what you see?

Let's build the next one.

Hiring, or have a problem that needs this kind of engineering? I read every message myself.