How shabab-personal/nsw-heights-safety-rag works
This is a local NSW working-at-heights safety assistant. Users ask questions in the Angular chat; the FastAPI endpoint retrieves relevant document chunks and generates a context-grounded answer with a local LLM, returning the answer and chunk previews. Separately, PDF ingestion extracts pages, chunks text, embeds it, and stores vectors for later retrieval. The README documents dynamic document support, but sampled ingestion only shows rebuilding the collection; UI component and dynamic document-management wiring were not sampled.
Main entry points: main.py Ask API · chat.component.ts Chat interface · rag.service.ts RAG service · ingest.py PDF ingestion
Components 11
Document ingestion
- Safety PDFs
data/pdfs - PDF ingestion
rag_basic/ingest.py
RAG pipeline
- Embedding model
- ChromaDB collection
- Chunk retrieval
rag_basic/query.py - Answer generation
rag_basic/query.py - Ollama LLM
API backend
- Ask API
api/main.py
Angular frontend
- Chat interface
safety-rag-ui/src/app/components/chat/chat.component.ts - RAG service
safety-rag-ui/src/app/services/rag.service.ts
Other components
- Safety worker
Connections 14
- Safety PDFs → PDF ingestion: reads PDFs
- PDF ingestion → Embedding model: encodes chunks
- PDF ingestion → ChromaDB collection: writes vectors
- Safety worker → Chat interface: asks question
- Chat interface → RAG service: submits question
- RAG service → Ask API: POST /ask
- Ask API → Chunk retrieval: retrieves chunks
- Chunk retrieval → Embedding model: encodes question
- Chunk retrieval → ChromaDB collection: queries vectors
- Ask API → Answer generation: generates answer
- Answer generation → Ollama LLM: calls model
- Ask API → RAG service: returns answer and chunks
- RAG service → Chat interface: emits response
- Chat interface → Safety worker: shows answer