Posts

Showing posts with the label Small AI Apps

Small AI App #1: Build a PDF Q&A App with FastAPI + Gemini (Upload a PDF, Ask It Questions)

Image
Versions used in this post — read this first: Python 3.12.3 · FastAPI 0.161.1 · uvicorn 0.54.0 · pypdf 6.21.2 · google-genai 2.33.0 · python-multipart 0.0.32 · Model: gemini-3.8-flash . Everything runs from one file, app.py , and the code below is the exact code that was run and tested for this post. The direct answer Yes — one small FastAPI file is enough. Upload a PDF and the server extracts its text with pypdf, splits it into overlapping chunks, and stores them in memory. Ask a question and it picks the chunks sharing the most words with it, sends only those to Gemini with a strict instruction to answer from them alone, and returns the answer with the token counts the API reported and what they cost. No vector database, nothing on top of FastAPI — and if no chunk matches, the app does not call the model at all. This is the first episode of Small AI Apps : complete, runnable applications built with FastAPI and Gemini, each small enough to finish in under an hour and honest ab...