Chat Completion with excel data

I have created an html home page, which let’s user upload an excel data file and I read it using pandas and store it in a variable, I want to generate response using chat completion api based on the uploaded file. I am struggling to figure out how do I pass my data to chat completion, as I have tried using content: data in user role.

First, the AI can’t understand data files. You’ll need to convert specific files into text the AI can understand just as you’d understand and be able to read it.

Spreadsheet files can be simple data, or can be multiple pages of formulas, merged columns, pivot tables, that would make programmatic extraction to text and comprehension difficult.

When you’ve obtained text, which can be by programming libraries or even a renderer and OCR, then the best way to augment the AI’s knowledge is to place the additional text into an assistant role message before the users.

Appending a line before the document contents should give the purpose, so the AI knows what to do, a prefix such as “The user has uploaded this file data from a spreadsheet, and might ask about it”, to “you are a domain-specific AI and will only answer about contents of this document, not answering from any pre-trained knowledge”.