I want the code to only show the pdf response, model = gpt-4

I have a code that answers questions from a pdf, this code uses gpt-4, but I want it to only answer questions from the pdf, if I ask questions about other topics I want it not to answer and for the chat to show a message indicating that it does not have the information

I think you have to use the pre-prompt and post-prompt to limit your answer