This Python script enables users to interactively ask questions from multiple uploaded PDF documents using the OpenAI GPT-3 language model. The application is built using Streamlit, a popular Python library for creating web applications.
The application is deployed on Streamlit Cloud. You can access it here.
OpenAI GPT-3 Integration: Utilizes OpenAI's GPT-3 model for answering user queries related to the content of uploaded PDF documents.
PDF Text Extraction: Extracts text content from uploaded PDF files using PyPDF2
.
Chunking and Vectorization: Splits the extracted text into chunks and creates a vector store using langchain
and FAISS
for efficient search and retrieval.
Conversational Interface: Employs a conversational chain for maintaining context between user queries across multiple PDF documents. Streamlit UI: Provides a user-friendly interface powered by Streamlit, allowing users to input their OpenAI API key, upload PDFs, and ask questions.
Python 3.7 or higher
Libraries:'streamlit',, PyPDF2
, langchain
, FAISS
-
Set up Environment
pip install -r requirements.txt
-
Run the application.
streamlit main.py
-
Obtaining OpenAI API Key
To use this application, you'll need an OpenAI API key. Here's how you can obtain it:
-
Visit the OpenAI website.
-
Sign in or create an account if you're a new user.
-
Once logged in, navigate to your account settings or API dashboard.
-
Find or generate your API key. It will usually be a long string of characters.
-
Copy the API key and paste it into the 'Enter your OpenAI API key' field in the application.
-
Interacting with the Application
Input your OpenAI API key in the provided field. Upload multiple PDF documents. Ask questions related to the uploaded PDFs in the text input field provided. Click "Process" to handle the user query based on the uploaded documents.
Ensure a stable internet connection to interact with the OpenAI GPT-3.5 API. The OpenAI API key is sensitive. Keep it confidential, and avoid sharing it publicly.
Contributions are welcome! Feel free to fork the repository, make enhancements, and create pull requests to improve the functionality or user experience of the application.