Assistant API and Instruction

I have multiple sections in a pdf like above image. I am trying to extract these individual sections data and output in Json using assistant API.

I am giving the following instruction

There are LOGISTIC ORDER, HANDOVER DATE, COLOUR, SIZE, COST PRICE data in multiple sections under PARTIAL DELIVERIES. Extract each of them based on individual section data. Colour and Size data is given in tabular format in Indvidual sections.

                  COLOUR | SIZE 1 | SIZE 2 | Total
                  123 - DARK | 10 | 20 | 30

                  123 - WHITE | 30 | 40 | 70

                  Total | 40 | 60 | 100

                For the above table output json will be {"Sizes":[{"Color":"123 - DARK","Size": "Size 1","Quantity":10}, {"Color":"123 - DARK","Size": "Size 2","Quantity":20}, {"Color":"123 - WHITE","Size": "Size 1","Quantity":30}, {"Color":"123 - WHITE","Size": "Size 2","Quantity":40}]}. Don't process Total column and Total row of each table. COLOUR and SIZE data can be in multiple tables in multiple sections. Process all sections table data. Don't merge them in final output. Don't write any explanation. Don't modify output json and don't add anything before and after of the output json. Output exactly as {"Deliveries": [{"LogisticOrder":"","HandoverDate":"","Cost":0.0,"Sizes":[{"Color":"","Size": "<Size>","Quantity":0}]}]}

But gpt is not responding as expected. Suppose there are 3 sections like above image. Sometimes it processes 2 table sometime 3. Also if there are mutiple rows in a single table. It can not process all rows as expected.

Can someone help me how to give better instruction to process all tables and rows as expected?

Why wouldn’t you just use something like pdftotext to extract the tables? It’s actually quite good at it and deterministic.