Skip to content

Load a PDF file from a remote URL and use the OpenAI API to chat with it

License

Notifications You must be signed in to change notification settings

jsonsmth/GPT-chatwithpdf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

GPT-chatwithpdf

This interactive script uses OpenAI's GPT-3 API to answer questions about a PDF document. It breaks the PDF document into chunks of text and uses GPT-3 to generate answers to user questions.

Requirements

  • Python 3
  • OpenAI API key (sign up at openai.com)
  • PyPDF2
  • requests
  • transformers
  • python-dotenv

Installation

  1. Clone the repository or download the ZIP file and extract its contents to a directory of your choice.

  2. Install the required dependencies by running pip3 install -r requirements.txt in the project directory.

  3. Sign up for an OpenAI API key at openai.com and create a new file named .env in the project directory.

  4. Add your OpenAI API key to the .env file as shown below:

    API_KEY=your_api_key_here
    

Usage

Running the script

Run the script by using the command python3 chat.py <URL> in the project directory. Replace <URL> with the URL of the PDF document you want to analyze.

Asking questions

Once the script is running, you can ask questions about the PDF document. Type a question and press Enter. The script will use GPT-3 to generate an answer to your question based on the PDF document.

Providing feedback

After the script generates an answer, you can provide feedback by using one of the following options:

  • Press the Spacebar to bypass the feedback prompt.
  • Press the Up arrow key (^) to indicate that the answer was correct.
  • Press the Down arrow key (v) to indicate that the answer was incorrect.

If you indicate that the answer was incorrect, the script will prompt you to provide the correct information.

Quitting the script

To quit the script, type quit and press Enter.

Supported Platforms

This script should run on any platform that supports Python 3 and the required dependencies, including Windows, Mac, and Linux.

Note: This script was written with the assistance of ChatGPT, a language model trained by OpenAI.

About

Load a PDF file from a remote URL and use the OpenAI API to chat with it

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages