This project is a Retrieval-Augmented Generation (RAG) chatbot that allows you to upload your own documents and ask questions about their content. It uses a FastAPI backend for the RAG pipeline and a Streamlit frontend for the user interface.
The application consists of two main components:
- Backend: A FastAPI server that exposes an API for processing and querying documents. It can handle PDF and TXT files, extract the text, create a vector store, and generate answers to questions using a language model.
- Frontend: A Streamlit application that provides a user-friendly interface to interact with the backend. You can upload documents and ask questions through a chat interface.
- Document Upload: Supports uploading PDF and TXT files.
- Question Answering: Ask questions about the content of the uploaded documents.
- Source Display: Shows the sources from the document that were used to generate the answer.
- Decoupled Frontend and Backend: The frontend and backend are separate applications that communicate via an API, allowing for independent development and scaling.
To run this project, you need to have Python 3.8+ installed.
First, clone the repository and create a virtual environment:
git clone <repository-url>
cd <repository-directory>
python -m venv venv
source venv/bin/activate # On Windows, use `venv\Scripts\activate`Next, install the required dependencies:
pip install -r requirements.txtNavigate to the backend directory and run the FastAPI server using Uvicorn:
cd backend
uvicorn main:app --reloadThe backend server will be running at http://127.0.0.1:8000.
In a new terminal, navigate to the frontend directory and run the Streamlit application:
cd frontend
streamlit run app.pyThe frontend application will open in your browser at http://localhost:8501.
- Open the Streamlit application in your browser.
- Use the sidebar to upload a PDF or TXT file.
- Once the file is loaded, you can ask a question in the chat input box.
- The answer and the sources used to generate it will be displayed.
.
├── backend
│ ├── main.py # FastAPI application
│ └── rag_pipeline.py # RAG pipeline logic
├── frontend
│ └── app.py # Streamlit application
├── .gitignore
└── requirements.txt # Python dependencies