Read the answers of a study's requests, check them, write the report files
Source:R/ai_requests.R
tfl_ai_collect_answers.RdReads each <request>.md in answers (the AI's whole answer to the
request of the same name, tfl_ai_write_requests()), checks it against
its request (tfl_ai_parse(), tfl_ai_check()) and, when it has no
error, writes its report files (tfl_ai_unpack()). An answer with
errors writes no file: its repair prompt (tfl_ai_repair_prompt()) goes
to repairs, to paste into the same chat; save the new answer over the
old and collect again.
Value
A data frame, one row a report: request, output_id,
status (ok, warning, error, no answer), problems (how
many), first (the first problem). Its print is a summary: each
request's status, its reports and the next step.
Details
An answer is read as UTF-8, with or without the byte-order mark Windows
Notepad writes, and with any line ends; an answer saved in another
encoding (Shift-JIS / CP932, "ANSI") is an error that says how to save
it again. An answer saved as <request>.md.txt or <request>.txt (Notepad
adds .txt) is read too.