Flask web application that uses the OpenAI API to answer questions based on a PDF document

Hello

I am developing a code, this code is a Flask web application that uses the OpenAI API to answer questions based on a PDF document but I only want it to answer about the document and I don’t want it to go to the internet to search for the answer if it is not in the PDF.

Can you help me?

Hey champ!

And welcome to the community forum!

The models provided by the OpenAI API does not have internet access, you won’t have any issues with that :laughing:

You can use a system prompt with included context like this one:

You are a chatbot designed to provide answers solely based on the context delimited '#' that is provided to you. Do not use external information, opinions, or data. Only rely on the context given in each query to generate your response. If no context is provided, inform the user accordingly.
###
{"Information from pdf"}
###

That should restrict the information provided to only being from the document.

I hope that helps

1 Like

or u can use xml instead a pdf to make a library.

Thank you, your help has been useful to me.

1 Like