Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Jatin-Mehra119/PDF-Insight-Beta/llms.txt

Use this file to discover all available pages before exploring further.

This guide walks you from zero to a running PDF Insight Pro instance with a successful PDF upload and an LLM-powered answer — all in under five minutes. You will interact with the server through its REST API, but a built-in web UI is also available once the server is running.
GROQ_API_KEY is required. The server will reject every /chat and /upload-pdf request with an error if this variable is missing or empty. Obtain a free key at console.groq.com before proceeding.
1

Prerequisites

Before you begin, make sure you have the following:
  • Python 3.12 or later — check with python --version
  • A Groq API key — sign up at console.groq.com and generate a key from the dashboard
  • A Tavily API key (optional) — required only if you want to enable live web-search augmentation; sign up at app.tavily.com
2

Clone & Install

Clone the repository, create an isolated virtual environment, and install all Python dependencies.
git clone https://github.com/Jatin-Mehra119/PDF-Insight-Beta.git
cd PDF-Insight-Beta

# Create and activate a virtual environment
python -m venv venv
source venv/bin/activate        # Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt
The requirements.txt includes FastAPI, LangChain, FAISS, PyMuPDF, Sentence Transformers, and all other runtime dependencies.
3

Configure API Keys

Create a .env file in the project root. The application loads it automatically on startup via python-dotenv.
# .env
GROQ_API_KEY=your_groq_api_key_here
TAVILY_API_KEY=your_tavily_api_key_here   # omit this line to disable web search
Never commit this file to source control — it is already listed in .gitignore.
4

Start the Server

Launch the FastAPI application with Uvicorn. The --reload flag enables hot-reloading during development.
uvicorn app:app --host 0.0.0.0 --port 8000 --reload
You should see output similar to:
INFO:     Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
INFO:     Started reloader process
INFO:     Started server process
INFO:     Waiting for application startup.
INFO:     Application startup complete.
Visit http://localhost:8000 in your browser to access the built-in responsive web UI — no curl required. It supports drag-and-drop PDF uploads, a real-time chat interface, model selection, and a web-search toggle.
5

Upload a PDF

Send a PDF file to the /upload-pdf endpoint. The server extracts, chunks, embeds, and indexes the document, then returns a session_id you will use for all subsequent chat requests.
curl -X POST http://localhost:8000/upload-pdf \
  -F "file=@/path/to/your/document.pdf" \
  -F "model_name=llama-3.1-8b-instant"
Response (UploadResponse):
{
  "status": "success",
  "session_id": "a3f2c1d4-7e8b-4a2f-9c0d-1e2f3a4b5c6d",
  "message": "Processed document.pdf"
}
Copy the session_id value — you will need it in the next step.
6

Ask a Question

Post a question about your uploaded document to the /chat endpoint. Include the session_id returned by the upload step.
curl -X POST http://localhost:8000/chat \
  -H "Content-Type: application/json" \
  -d '{
    "session_id": "a3f2c1d4-7e8b-4a2f-9c0d-1e2f3a4b5c6d",
    "query": "What are the main findings of this document?",
    "use_search": false,
    "model_name": "llama-3.1-8b-instant"
  }'
Response (ChatResponse):
{
  "status": "success",
  "answer": "The document's main findings include ...",
  "context_used": [
    {
      "text": "Relevant passage extracted from the PDF...",
      "score": 0.312,
      "metadata": { "source": "document.pdf", "page": 3 }
    }
  ]
}
The context_used array lists every chunk the agent retrieved and its similarity score, giving you full transparency into what the LLM actually read.
7

Enable Web Search

Set "use_search": true to instruct the LangChain agent to augment its answer with live Tavily web results. All other fields remain the same.
curl -X POST http://localhost:8000/chat \
  -H "Content-Type: application/json" \
  -d '{
    "session_id": "a3f2c1d4-7e8b-4a2f-9c0d-1e2f3a4b5c6d",
    "query": "Are there any recent developments related to this topic?",
    "use_search": true,
    "model_name": "llama-3.1-8b-instant"
  }'
When use_search is true, the agent will call the Tavily Search API during its reasoning loop and incorporate web results alongside the document context before generating a final answer.
Web search requires a valid TAVILY_API_KEY in your .env file. If the key is absent, the server will return an error indicating that TAVILY_API_KEY is not set. Web search will not function.

Build docs developers (and LLMs) love