Openai and pdf with python

I’m making a chatbot using Openai with the data source coming from PDF. The programming language used is Python. What I want to ask is, for example, if the information is in a PDF, the application will look for an answer based on the PDF information, but if the PDF doesn’t contain the information in question, it will look for an answer from ChatGPT. can anyone help?

1 Like

The way I would go about this is first convert the pdf into text. There are some python libraries like PyMuPDF or PyPDF2 that can help you out with that (even some web APIs like Document AI). After that its pretty much done you just have to send the text to the gpt end point and with a clever prompt get it to not hallucinate and extract the text you want it to extract if it exists.

1 Like