How ayshasharaf/rag-knowledge-base works
This is a PDF-based RAG knowledge-base API. A user uploads a PDF; the API saves it and invokes indexing, which loads and splits the document, embeds its chunks, and writes them to Pinecone. For questions, the API invokes retrieval and then answer generation with the retrieved context, returning the answer and source chunks. The README documents these capabilities; the sampled source confirms the main call and data flows shown here.
Main entry points: main.py FastAPI routes · ingestor.py Document ingestor · retriever.py Chunk retriever · generator.py Answer generator
Components 11
API
- FastAPI routes
app/main.py
Document indexing
- Uploaded PDFs
app/main.py - Document ingestor
app/ingestor.py - PDF loader
app/ingestor.py - Text splitter
app/ingestor.py - Embedding encoder
app/ingestor.py - Pinecone index
app/ingestor.py
Question answering
- Chunk retriever
app/retriever.py - Answer generator
app/generator.py - Hugging Face chat API
Other components
- User
Connections 18
- User → FastAPI routes: uploads PDF
- User → FastAPI routes: asks question
- FastAPI routes → Uploaded PDFs: writes file
- FastAPI routes → Document ingestor: indexes file
- Document ingestor → PDF loader: loads PDF
- PDF loader → Text splitter: supplies pages
- Document ingestor → Text splitter: splits documents
- Document ingestor → Embedding encoder: embeds chunks
- Document ingestor → Pinecone index: upserts vectors
- FastAPI routes → Chunk retriever: retrieves context
- Chunk retriever → Embedding encoder: embeds question
- Chunk retriever → Pinecone index: queries vectors
- Pinecone index → Chunk retriever: returns matches
- FastAPI routes → Answer generator: generates answer
- Answer generator → Hugging Face chat API: requests completion
- Hugging Face chat API → Answer generator: returns completion
- Answer generator → FastAPI routes: returns answer
- FastAPI routes → User: returns result