A PDF query system that allows users to upload PDF files and ask questions about their content using Ollama.
macOS (with Homebrew):
brew install ollamaOther platforms: Download from https://ollama.ai
ollama pull llama2Open a terminal and run:
ollama serveKeep this terminal open. Ollama will run on http://127.0.0.1:11434.
Open a new terminal and run:
cd /path/to/pdf_query
source venv/bin/activate
python3 -m uvicorn main:app --reload --host 127.0.0.1 --port 8000(Replace /path/to/pdf_query with your actual project directory path)
Navigate to: http://127.0.0.1:8000
Upload a PDF and ask questions!
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txtnpm install
npm run buildmain.py- FastAPI application entry pointllm_client.py- Ollama LLM client wrapperpdf_utils.py- PDF text extraction utilitiessrc/- React frontend source codedist/- Built React app (generated afternpm run build)requirements.txt- Python dependenciespackage.json- Node.js dependencies
POST /query-pdf
Accepts:
file: PDF file (multipart/form-data)question: User's question (form field)
Returns:
{
"answer": "Answer from Ollama",
"context_truncated": false,
"context_length": 1234
}