This is a Python script that uses the OpenAI GPT-4 API to generate question-answer pairs for academic papers. The answers are based on the content of the papers and the predefined set of questions.
- Processes all PDF files in a given directory and its subdirectories.
- Converts PDF files to plain text using
pdfminer.six. - Uses the OpenAI GPT-3.5-turbo API to generate answers to a predefined set of questions based on the content of each paper.
- Saves the questions and answers for each paper in a JSON file.
- Generates a summary HTML file displaying all the questions and answers.
-
Install the required Python packages with pip:
pip install openai pdfminer.six glob2 -
Replace
'Put-Your-OpenAI-API-Key-Here'with your actual OpenAI API key. -
Modify the
questionslist to include the questions you want to ask about each paper. -
Specify the input directory and output directory:
input_dir = "Put-Your-Input-Path-Here" output_dir = "Put-Your-Output-Path-Here"
-
Run the script:
python paper_reader_automation.py
- The OpenAI API is a paid service. Ensure you understand the cost before running the script on a large number of papers.
- The script does not perform error checking on the input files. Ensure that the input directory contains valid PDF files.
- The script assumes that the PDF files are text-based, not image-based. It may not be able to extract text from scanned documents or documents with other forms of images.