An AI that reads our pregnancy textbooks.
Megan can ask the app any pregnancy question, in plain English, and it will answer her from the six textbooks I loaded into it — with citations to the actual page. Not a search result. Not a chatbot. A small honest librarian that lives in the app.
Is leg cramping at 22 weeks normal, and is there anything I should do about it?
Yes — leg cramps are very common in the second and third trimesters, especially at night. They're typically benign, and most providers suggest gentle stretching of the calf before bed, staying hydrated, and making sure your magnesium and calcium intake is adequate. If a cramp lasts more than a few minutes, comes with significant swelling (especially in one leg), or doesn't ease with stretching, contact your provider — those can be signs of something that needs evaluation.
Sources
- Williams Obstetrics, 26th ed. — Chapter 12, p. 304
- Mayes' Midwifery — Section on minor disorders of pregnancy, p. 412
- Heidi Murkoff, What to Expect When You're Expecting — Week 22 entry
What it is, in plain English
I picked six pregnancy and obstetrics textbooks that OBs, midwives, and L&D nurses actually recommend — a mix of clinical references and trusted lay-audience books. I broke each of them into thousands of small overlapping chunks, ran each chunk through an embedding model, and stored the results in a vector index. When Megan asks a question, the app finds the chunks that are closest in meaning to what she asked and hands them to a language model, which writes an answer in plain language and cites the specific book and page each piece came from.
It is not making things up. It is reading the books, finding the right paragraph, and translating it into something Megan can read in twenty seconds. When the question is outside the books, it says so. When the question is medical and specific to her, it says to call the OB. That part is non-negotiable.
What it is not
It is not a doctor. It is not a triage tool. It is not a substitute for any conversation with a provider. It is not connected to any of Megan's health data — what she asks here does not pull in her journal entries, her symptoms, her week, or anything else from the app. It is just six books and a question, every time.
The saved answers library
Every answer can be saved. The saved library is a small bookshelf inside the app — useful the second time the same question comes up at 11 PM, and useful as the start of a question list to take to the next appointment.
Under the hood
The stack
Model: Vertex AI's Gemini 2.5 Flash. Fast, cheap, very good at following the citation format I asked for in the system prompt.
Vector store: Pinecone, with a dedicated index named
pregnancy-books. 3,815 chunks across the six books. Each chunk is roughly
500 tokens with 80 tokens of overlap, embedded with Google's
text-embedding-004.
Backend: a Firebase Cloud Function. The function takes a question, embeds it, queries Pinecone for the top-k most similar chunks, builds a prompt with the chunks and a strict citation instruction, calls Gemini, and returns the answer plus the sources. It runs in about 1.5 to 3 seconds end to end.
The chunking pipeline
Each EPUB and PDF was parsed into plain text with chapter and page boundaries preserved. I wrote a small Python script that walks each book, splits into chunks at natural break points (paragraph boundaries within chapter sections, never across chapter breaks), tags each chunk with the book title, chapter, and page number, embeds it, and upserts it into Pinecone. Re-running the script is idempotent — chunk IDs are stable.
The prompt
The system prompt has three jobs: tell the model to only use the provided chunks, tell the model to cite every claim with the book title and page, and tell the model what to do when the chunks don't answer the question (say so, and recommend calling the provider for anything urgent).
What I tuned
Chunk size and overlap, top-k, temperature, the instruction wording for citations. The biggest improvement by far came from forcing the model to cite at the end of each sentence rather than at the end of each paragraph. With per-sentence citations, the answer reads like a small textbook excerpt and Megan can verify any specific claim by opening the book to the listed page.
Cost
Negligible. The two of us using it heavily in a week barely registers. The single largest cost is the Pinecone index, and that's a flat monthly figure that I'd pay even if we were the only users (which, for now, we are).
A note from a nurse
I would not have shipped this if it weren't grounded in actual books. Generative AI without retrieval is not safe for medical questions. Generative AI grounded in retrieval, with citations to the source, and with a hard guardrail telling the user to call the provider for anything that needs evaluation — that is a small careful tool. That's what this is.