Provide Gemini with the list of IDs in correction request

This commit is contained in:
sebastien committed 2026-10-10 17:19:06 +02:00
1 parent f978310c4c
commit 2d0f7a219f
9 files changed
+242 -9

No files matched your search

+17 -1
View File
@@ -532,6 +532,19 @@ def process_single_task(task_tuple, precomputed_response=None):
json_data = parse_correction_response(full_response_text)
# Validate the whole group before moving PDFs or applying corrections.
returned_ids = [entry["id"] for entry in json_data]
unexpected = sorted(set(returned_ids) - set(d_data))
missing = sorted(set(d_data) - set(returned_ids))
duplicates = sorted({pid for pid in returned_ids if returned_ids.count(pid) > 1})
if unexpected or missing or duplicates:
raise ValueError(
f"Correction ID mismatch: expected {list(d_data)}, "
f"received {returned_ids}; unexpected IDs: {unexpected}; "
f"missing IDs: {missing}; duplicate IDs: {duplicates}. "
"No corrections from this response were applied."
)
# Ensure consistency of answer placements
for p in json_data:
pid = p["id"]
@@ -899,7 +912,10 @@ def run_configured(args: argparse.Namespace) -> ExitCode:
"data": b64_img,
}
},
{"text": prompting.make_prompt(INPUT_DIR, label)},
{"text": prompting.make_prompt(
INPUT_DIR, label,
expected_ids=[row[0] for row in group_data],
)},
],
}
],