I want to upload pdf file in chatgpt and ask for a summary of it in one go?

i need to upload a PDF file and ask a question about this file in one go but all I find are separate APIs
one for uploading the file and another to relate this file ID with the store
and others to relate this to assistance
is this too much? is there a more simple approach?
also is there any available c# code for this?

The only built-in method is to create a vector store from an uploaded file, which gives a file search method to the AI to return relevant chunks of the document. This is only made available in “Assistants” needing even more API calls in multiple steps.

If you want full understanding of the PDF text all at once, and a simple call, you would need to use your own document extraction in code, and use chat completions to send a message and get an immediate answer when the text is included in a message to be answered about.

The text would have to fit in the model’s input context window, or you would also have to implement your own chunking and embeddings-based searching to reduce the size sent to the AI.

2 Likes

Regular gave some great advice. For your usecase, I would drop the pdf text into one context window and see if that works. It’s easy and you don’t have to worry about chunking and a bunch of other things.

In c# → Extract text from pdf → build your prompt.

Good luck!

The new OpenAI official .NET library is in beta and explains how to do just this. You do have to create an assistant, but the steps outlined are simple.