You could make use of the UnstructuredPDFLoader and the load_qa_chain as follows:
fromlangchain.document_loadersimportUnstructuredPDFLoaderfromlangchain.llmsimportOpenAIfromlangchain.chains.question_answeringimportload_qa_chainAPI_KEY='api-key'loader=UnstructuredPDFLoader("your_document.pdf")data=loader.load()chain=load_qa_chain(OpenAI(temperature=0.9,openai_api_key=API_KEY),chain_type="stuff")# model response
response=chain.run(input_documents=data,question="<Input your query here>")
You could make use of the
UnstructuredPDFLoaderand theload_qa_chainas follows:You can get more information here