This project integrates Retrieval-Augmented Generation (RAG) with Text-to-SQL capabilities into a single query interface using Streamlit, LlamaIndex, SQL database, and LLM(ChatGPT). It enables users to upload documents, index them, and perform queries to retrieve structured and unstructured information.
Ensure you have the following installed before running the code:
- Python 3.8+
- pip
You can install the dependencies by running:
pip install -r requirements.txtThe requirements.txt should include:
streamlit
python-dotenv
llama-index
llama-index-core
llama-index-llms-openai
sqlalchemy
httpx
pandasCreate a .env file in the project root and add the following API keys:
OPENAI_API_KEY=your_openai_api_key
LLAMA_INDEX_API_KEY=your_llama_index_api_keyTo run the app, use the following command:
streamlit run app.py- Upload Documents: Navigate to the upload section and add your PDF files.
- File Tracking: The system detects and prevents duplicate file uploads.
- Query Execution: Use the text box to input natural language questions.
- Results Display: Queries will be processed and displayed using SQL database and LlamaCloud.
- If a file fails to upload, check API keys and try again.
- If a query times out, increase the timeout setting in
request_timeout.