#How do I add a PDF attachments to chat gpt 4 while in plugin mode?
1 messages · Page 1 of 1 (latest)
Hi @bright nexus. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
Based on the information provided in the extracts, it appears that there is no direct feature to upload PDF attachments in ChatGPT 4 while in plugin mode. However, there is a workaround mentioned in a forum post (https://community.openai.com/t/565556) where you can use a combination of OpenAI and Langchain to read and ask questions from a PDF file. Here is the code snippet provided:
from langchain.document_loaders import PyPDFLoader
from langchain.llms import OpenAI
from langchain.chains.question_answering import load_qa_chain
# Locate your PDF here.
pdf="<YOUR_PDF_GOES_HERE>"
# Load the PDF
loader = PyPDFLoader(pdf)
documents = loader.load()
api_key = "sk-?????"
llm = OpenAI(openai_api_key=api_key)
chain = load_qa_chain(llm,verbose=True)
question = input("Enter your question here : ")
response = chain.run(input_documents=documents, question=question)
print(response)
Please replace <YOUR_PDF_GOES_HERE> with the path to your PDF file and sk-????? with your OpenAI API key. This code will load the PDF, and then you can ask questions about the content of the PDF.