Session 2 homework: RAG on your Session 1 endpoint
Extend your Session 1 POST /ask on Render into a basic document-grounded RAG API. Same service, two processes: POST /ingest when data changes, POST /ask when users ask — plus a Streamlit UI for ingest + ask. Pinecone is the recommended beginner vector store. A notebook-only demo does not count. Done means both endpoints work on your live URL, with citations, refusal, and a Streamlit demo.
Ready when
Basic submission first
Enough to pass: text ingest with `document_id`, retrieval tested before generation, one cited answer, one refusal, and a Streamlit UI for ingest + ask. Golden-set evals, chunk experiments, and hybrid search are add-ons.
Tip
Start from your Session 1 deploy
Do not rebuild from scratch. Your Session 1 FastAPI service on Render is the base. Add vector store + ingest + retrieval in front of the existing /ask handler.
Architecture
POST /ingest
NewAccept plain text + `document_id` → chunk with overlap → embed → upsert to vector store with metadata.
POST /ask
Session 1 to 2Embed question → retrieve top-k → grounding prompt (cite + refuse) → generate. Test retrieval alone before wiring the LLM.
Vector store
RecommendedUse Pinecone for the basic path. Lock the embedding model early so ingest and query use the same vector dimensions.
Path A: Basic submission
- 1
Choose corpus + vector store
Start with the Northwind sample docs and Pinecone. Your own capstone corpus can come later.
- 2
Build POST /ingest
Accept JSON with plain text + `document_id`. Chunk, embed, and upsert with document metadata.
- 3
Test retrieval FIRST
Debug route or script: question in → top-k chunks + scores out. No LLM yet.
- 4
Upgrade POST /ask
Retrieve → ground (context-only, cite chunk IDs, refuse when missing) → generate. Keep cost/tokens fields where possible.
- 5
Deploy + prove live
Same Render service as Session 1. curl ingest + curl ask against public URL.
- 6
Prove one answer + one refusal
Show one doc-grounded answer with cited document_id or chunk IDs, and one question that refuses because the docs do not contain the answer.
- 7
Streamlit UI (required)
Minimal UI for ingest + ask that calls your live API. Keep FastAPI as the source of truth — screenshot the UI for Maven.
# Ingest
curl -s -X POST https://YOUR-SERVICE.onrender.com/ingest \
-H "Content-Type: application/json" \
-d '{"text": "...", "document_id": "handbook"}'
# Ask (RAG)
curl -s -X POST https://YOUR-SERVICE.onrender.com/ask \
-H "Content-Type: application/json" \
-d '{"question": "What is the remote work policy?"}'Path B: Add-ons (choose one or two if you have energy)
Golden-set eval
RecommendedCreate 5 known-answer questions and track retrieval hit, faithfulness, and correctness.
Chunk size comparison
Try two chunk sizes and report which one retrieves better.
Hybrid search
Combine BM25 or keyword search with embeddings.
Metadata filtering
Filter by `document_id`, source, or tag.
Batch ingest
Add a folder ingest script or multi-file endpoint.
Reranking
Retrieve top-k, then reorder with a rerank model or API.
What to submit
Maven submission proof: live URL, ingest curl, ask curl, Streamlit screenshot, one cited answer, and one refusal response. If you did add-ons, include eval scores or screenshots too.
Critical
Do NOT share your live URL on LinkedIn
Maven submission channel: live URL, ingest + ask curls, Streamlit screenshot, one doc-grounded answer with cited chunk IDs, and one refusal. LinkedIn: screenshots or screen recording only.
Watch out
Common mistakes
- Rebuilding /ask from scratch instead of extending Session 1.
- No ingest endpoint - hard-coding docs at deploy is not a pipeline.
- Skipping retrieval-only testing.
- No refusal-path question.
- No Streamlit UI - curl-only is not enough for this assignment.
- Posting live URL publicly.
Done when
- Session 1 POST /ask still works (extended, not replaced blindly)
- Vector store chosen and configured (Pinecone recommended for the basic path)
- POST /ingest accepts text + `document_id`, chunks, embeds, and upserts documents
- Retrieval tested alone before generation - you can show top-k chunks for a known question
- POST /ask retrieves, grounds (cites + refuses), and answers only from ingested docs
- Both endpoints work on your live Render URL (curl ingest + curl ask)
- You can show one successful cited answer and one refusal when the answer is not in the docs
- Streamlit UI for ingest + ask calls the live API (screenshot for Maven)
Submit in Maven: Maven submission only: live URL, ingest + ask curls, Streamlit screenshot, one cited answer, and one refusal. LinkedIn: screenshots only - never post the live service URL publicly.