Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RAG PDF Assistant

A small Python project for asking questions from PDF or text documents using a simple RAG pipeline.

The project loads a document, splits it into chunks, retrieves the most relevant chunks, and then uses an LLM to answer the user's question. If no API key is available, it still returns the best matching context so the retrieval part can be tested locally.

Why I Built This

I wanted to practice the main parts of an LLM application:

  • document loading
  • text chunking
  • retrieval
  • prompt building
  • FastAPI endpoints
  • clean Python project structure

This project is intentionally kept simple so the core idea is easy to understand.

Tech Stack

  • Python
  • FastAPI
  • scikit-learn
  • pypdf
  • OpenAI API optional

Project Structure

rag-pdf-assistant/
  app.py
  requirements.txt
  .env.example
  data/
    sample_notes.txt
  src/
    chunking.py
    document_loader.py
    llm_client.py
    rag_pipeline.py
    vector_store.py

Setup

python -m venv venv
venv\Scripts\activate
pip install -r requirements.txt

Create a .env file if you want LLM answers:

OPENAI_API_KEY=your_api_key_here

The app still works without an API key, but it will return retrieved context instead of a generated answer.

Run API

uvicorn app:app --reload

Then open:

http://127.0.0.1:8000/docs

Example Request

Use /ask with:

{
  "file_path": "data/sample_notes.txt",
  "question": "What is retrieval augmented generation?"
}

Notes

This is a learning-focused RAG project. For a production system, I would add:

  • persistent vector database
  • file upload support
  • user authentication
  • better evaluation
  • background processing for large PDFs

About

Python RAG assistant for asking questions from PDF and text documents

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages