This FastAPI-based service allows users to upload documents (PDF, JSON, or text) and ask questions based on the content of these documents using an OpenAI-powered chatbot.
- Document Upload: Upload and store documents in a FAISS-based index for quick retrieval.
- Question Answering: Ask questions about the content of the uploaded documents and get responses powered by OpenAI's GPT model.
Before you begin, ensure you have the following installed:
- Docker
- Docker Compose (optional, if you want to run with Docker Compose)
- OpenAI API Key
Create a .env
file in the root directory of your project with the following content:
OPENAI_API_KEY=your_openai_api_key_here
Replace your_openai_api_key_here
with your actual OpenAI API key.
git clone https://github.com/patriksabol/rag-based-chatbot.git
cd document-search-api
You can build the Docker image using the provided Dockerfile
. Run the following command:
docker build -t document-search-api .
Once the Docker image is built, you can run the service using Docker:
docker run -d -p 8080:80 --env-file .env document-search-api
This command runs the service in detached mode and maps port 80
on your local machine to port 80
in the container.
You can now access the service in your web browser by navigating to:
http://localhost:8080
- On the homepage, click "Choose File" and select a PDF document.
- Click "Upload" to store the document in the FAISS index.
- Enter your question in the text area under "Ask a Question".
- Click "Ask" to submit your query. The service will retrieve the most relevant document and generate a response using OpenAI's API.