Typed LLM chain with FastAPI, Pandas, and SmolLM.
| Requirement | Status |
|---|---|
GET /health |
Done |
POST /data/upload (CSV, metadata) |
Done |
GET /data/stats (describe(), 404 if missing) |
Done |
POST /ai/ask (Runnable chain) |
Done |
Runnable chain PromptBuilder | LLMRunner | ResponseParser |
Done |
| Pydantic types in each step | Done |
SmolLM via transformers.pipeline |
Done |
.env not in git |
Done |
| Error handling + meaningful status codes | Done |
| pytest (chain, endpoints, mocked model) | Done |
reflektion.md |
Done |
uv syncCopy optional env file:
copy .env.example .envuv run uvicorn app.main:app --reloadSwagger: http://127.0.0.1:8000/docs
- Upload CSV:
curl -X POST "http://127.0.0.1:8000/data/upload" -F "file=@app/data/climate.csv"- Stats:
curl "http://127.0.0.1:8000/data/stats"- Ask:
curl -X POST "http://127.0.0.1:8000/ai/ask" \
-H "Content-Type: application/json" \
-d "{\"question\":\"Vilken stad har hogst medeltemperatur?\"}"Without upload:
/data/stats->404/ai/ask->400
app/
main.py
config.py
schemas.py
data.py
llm/
runnable.py
steps.py
pipeline.py
tests/
data/
climate.csv
reflektion.md
uv run pytest app/tests/ -v- Dataset stored in memory (single process).
- CSV must be UTF-8.
- First
/ai/askcall may be slow while model downloads (~300 MB).