from pathlib import Path import io main_prompt = """I'm giving you an image of several written answers to an exam. Each answer is separated by a black horizontal line, and underneath, to the left, is indicated the ID of the answer, from `01` to `50`. I want you to score each answer, from 0 to 4, you may score half points, such as 2.5. Even if a result is wrong, if the reasoning is correct and could lead to a right answer, you should give at least half the points. You also need to give feedback to the student, in french : - which part of his answer is wrong, - why is it wrong - possibly, what he should have done instead. Your feedback may contain LaTeX fragments written like `$a^2 + b^2 = c^2$`. If your score is not 4, you should always provide some feedback explaining what's missing. For each piece of feedback, if it is related to a specific part of the answer that is wrong, you may provide a `box_2d`, to locate this specific part of the answer. This `box_2d` should be in the form [ymin, xmin, ymax, xmax] normalized to 0-1000. If you do not provide one, set `box_2d` to `null`. If the answer is correct, there is no need to provide feedback. You do not have to give positive feedback, but if you do, do not provide a `box_2d` for it. For example, if the student says a function is continuous when it isn't, provide the coordinates where the word «continuous» is. If a calculation went wrong, gives the coordinates of the step where it goes wrong, and as feedback, what went wrong. Avoid giving feedback about confusing letters `n` with `m`, `x` with `n` or `h` with `k`. If it looks wrong, assume you read it wrong, unless the distinction is very important. You should also give me a measure of confidence, from 0 to 1 that you were able to correctly understand the answer. A score below 0.5 means that you think it is likely that you couldn't understand an important part. In some case, you may find that either - The student didn't answer the right question. Set the score to 0. Since it could be a labeling error, indicate is by setting `error` to \"wrong-label\". - You can find an answer to another question of the exercice (taking more than a couple of lines). Score the question you are supposed to score, but set `error` to \"additional-answer\". - The answer to the question is empty, or the student has only rewritten the statement of the question. In this case, set `error` to \"empty-answer\" and do not provide any kind of feedback. If there's no error, set `error` to `\"\"`. You will answer using json describing a list of dictionary with a key \"id\", and a key \"result\" that contains the \"score\", the \"confidence\", a list \"feedback\", and possibly an \"error\". Like this example : [{ \"id\": \"01\", \"result\": {\"score\" : 2.5, \"confidence\" : 0.8, \"feedback\": [{text: \"Un retour générique. Il faut apprendre le cours.\", box_2d: null}, {text: \"Non, la fonction n'est pas forcément continue\", pos: [145, 280, 340, 500]}], \"error\": \"\"} }, { \"id\": \"04\", \"result\": {\"score\" : 4., \"confidence\" : 0.9, \"feedback\" : [] \"error\": \"\" } } ] Here is the text of the exercice (or the relevant part of the problem) of the exam : ``` <> ``` Here is a possible correct answer : ``` <> ``` <> You are asked to score the question or exercice labeled `<