Retrieval-augmented QA app that lets you upload a document (PDF/TXT), indexes it with LlamaIndex + OpenAI embeddings, and answers questions via an OpenAI LLM. Frontend is Streamlit.
# 1) Create and activate venv (example)
python3 -m venv venv
source venv/bin/activate
# 2) Install deps
pip install -r requirements.txt
# 3) Set your OpenAI key
export OPENAI_API_KEY="sk-..."
# or create a .env file with OPENAI_API_KEY=...
# 4) Run the app
streamlit run StreamlitApp.py- Upload a document in the UI; it is saved into
Data/. load_datareads the file(s) and produces documents.create_or_load_indexbuilds (or reloads) a vector index using OpenAI embeddings and persists it tostorage/.- Queries are sent to the index; responses come from the OpenAI LLM.
StreamlitApp.py– Streamlit UI and request flowQAWithPDF/data_ingestion.py– loads uploaded files into LlamaIndex documentsQAWithPDF/embedding.py– builds/loads the vector index and sets embedding/LLM settingsQAWithPDF/model_api.py– loads the OpenAI LLMQAWithPDF/logger.py– basic logging configurationrequirements.txt– full dependency liststorage/– persisted index artifacts (created at runtime)Data/– uploaded documents are written here
OPENAI_API_KEYmust be set in your environment or.env.- Adjust embedding/LLM models or chunking in
QAWithPDF/embedding.pyif needed.
- If imports fail, ensure you run from the project root so
QAWithPDFis onPYTHONPATH. - Delete
storage/to rebuild the index from fresh documents if you change embeddings or data.