Construct a Jupyter notebook that uses Langchain to load a PDF file and then allows the user to ask questions about the content of that file. To do this you will need to use the PyPDFLoader class to load the PDF file. You can then pass the text contents of that PDF file to a prompt that asks the LLM to answer the question using the provided text.
For this exercise you should find a moderately large PDF file to work with. A good source of PDFs to use for this purpose is instruction manuals that you can download from the web, such as the user guide for a car.
You will have to experiment to make sure that the text in the PDF is not too long. Remember that you are limited to a context window of no more than eight thousand tokens.
By default, the PyPDFLoader class loads PDFs one page at a time. This would give you multiple documents from a single PDF file. To force the PyPDFLoader to load the entire PDF into a single Document object, do this:
pdf_loader = PyPDFLoader("Manual.pdf",mode="single")
pdf_docs = pdf_loader.load()
pdf_docs will still be a list, but now the first element in that list should be the Document object containing the entire contents of your PDF.
When you are finished, simply upload your Jupyter notebook to the course's canvas page. To test your code I will be using my own PDF file named "Manual.pdf".