Runs tflspec's own checks on a read answer (tfl_ai_parse()), with the
study's context (tfl_ai_context()), and adds their problems to the
answer's. Errors block applying the answer; warnings do not.
Arguments
- answer
A
tfl_ai_answer(tfl_ai_parse()).- context
The
tfl_ai_context()the prompt was made with;NULLfor none (only what needs no context is checked).- adam
figure: the study's data (tfl_read_adam()), for the checks that look into it;NULLfor none.
Value
A data frame of the problems: where (toc row 2 field type,
layers[3] point field size ...), problem, severity (error or
warning); no rows when there are none.
Details
toc: the rows are written to a temporary.csvand read back withtfl_read_toc()(its errors – a row with no output id but other cells filled, an id twice – become problems on their rows); a kind it had to guess, and a row with no id it passes over as a heading, are warnings; a column outside the context'stoc_fieldsis an error.table: each report against the schema – a key a report file does not have, a content function that is not a table's, an argument the function does not have (tfl_schema_check(), an error here: the AI's invention), a value of the wrong type, a required argument missing; itsard:fields and method; the analysis sets ofspec/data.yml(withstudy_dir); with the context'sdatasets(the ADaM summary), every dataset and variable an analysis names (made byderiveoraddaside); a report asked for and missing. Then the answer is put in a copy of the study folder and its ARD program (tfl_ard_code()) and each table's code (tfl_content_code()) are written: what fails there is a problem too. Nothing is run.figure:tfl_check_fig_design()on the design (withadam, the data-aware checks too: the variables and PARAMCDs it names); anoutput_idother than the context's is an error; a template not known, or not among the context'stemplates, and a dataset not in the context'sdatasetsare warnings.
See also
tfl_ai_repair_prompt() to send them back.
Examples
answer <- c(
"```yaml",
"tflspec_ai: {task: toc, version: 1}",
"toc:",
"- {output_id: T-14-1-1, type: table, title: Demographics}",
"- {output_id: T-14-1-1, type: tbl, title: Disposition}",
"- {output_id: L-16-2-1, type: list, title: Deaths}",
"assumptions: []",
"```")
tfl_ai_check(tfl_ai_parse(answer, "toc"), tfl_ai_context("toc"))
#> where problem severity
#> 1 toc row 1 field output_id 'T-14-1-1' is given twice error
#> 2 toc row 2 field output_id 'T-14-1-1' is given twice error