Skip to content

jamilEmon/RAG-Chatbot-with-FastAPI-and-Streamlit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RAG Chatbot with FastAPI and Streamlit

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.

Project Summary

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.

Features

  • 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.

How to Run the Project

To run this project, you need to have Python 3.8+ installed.

1. Set Up the Environment

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.txt

2. Run the Backend

Navigate to the backend directory and run the FastAPI server using Uvicorn:

cd backend
uvicorn main:app --reload

The backend server will be running at http://127.0.0.1:8000.

3. Run the Frontend

In a new terminal, navigate to the frontend directory and run the Streamlit application:

cd frontend
streamlit run app.py

The frontend application will open in your browser at http://localhost:8501.

4. Use the Application

  1. Open the Streamlit application in your browser.
  2. Use the sidebar to upload a PDF or TXT file.
  3. Once the file is loaded, you can ask a question in the chat input box.
  4. The answer and the sources used to generate it will be displayed.

Project Structure

.
├── backend
│   ├── main.py          # FastAPI application
│   └── rag_pipeline.py  # RAG pipeline logic
├── frontend
│   └── app.py           # Streamlit application
├── .gitignore
└── requirements.txt     # Python dependencies

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages