Ship: a lab as a service¶
rag 04 served with FastAPI: streamed answers, a log line per answer, health checks, a feedback endpoint and a Dockerfile. Read SHIP.md first: what changes from lab to service, streaming vs buffered, Docker, and the feedback-to-golden-set loop. Before you start: rag (Core labs). After it, you can: put any lab behind an API and learn from its users.
Setup¶
Same venv as every topic (see Start here); Ollama running with qwen3:8b and nomic-embed-text.
uvicorn app:app --port 8000 # from this folder
docker build -f ship/Dockerfile -t ask-docs . # from the ai-learning folder
Files¶
| File | What it is | Read? |
|---|---|---|
app.py |
The service: /ask (streamed or buffered), /feedback, /health, /ready |
Read |
Dockerfile |
The image: packages from the lock, non-root user, health check, Ollama on the host | Read |
test_app.py |
Model-free tests: search and model faked | Skim |
data/ |
answers.jsonl and feedback.jsonl, created on the first request (not in git) |
— |
Rules of thumb¶
- Stream answers people read; buffer and check first when the answer drives money, stock or a promise.
- Log the question, sources and model with every answer: feedback without them can't become a test case.
- A person decides which thumbs down become golden cases. Never auto-add them.
- Secrets go in at run time (
--env-file), never into the image.
Tests¶
pytest -q # no model needed