The steps before the first request, one after the other:
tfl_ai_study_init() (only when the study has no study.yml yet – one
that is there is kept, so the call can be run again),
tfl_ai_adam_summary() (to ai/adam_summary.md),
tfl_ai_read_shell() (to ai/toc_shell.md; its summary is printed,
with what to pass when no TOC or a report's shell was found) and
tfl_ai_write_requests(). Nothing is sent anywhere.
Arguments
- dir
The study folder.
- toc
The TOC / SHELL workbook (
.xlsxor.xlsm).- adam
The ADaM folder, from
dir(relative) or absolute.- study_id, title
The study's id and title, for a new study folder.
- toc_sheet, sheets
As
tfl_ai_read_shell(): the TOC sheet when the guess is wrong, the sheets to keep.- size, language, workbook, instructions, max_chars
As
tfl_ai_write_requests(): the reports a request holds, the language of the assumptions, how the workbook reaches the chat ("text","attach","both"), the instructions in each request or once, a request's length at most.- overwrite
TRUEto start the study folder again (tfl_ai_study_init()over itsstudy.ymlandspec/). The requests are written again on every call (the answers are kept).
Value
The requests, as tfl_ai_write_requests() gives them.
Examples
ex <- system.file("ai", "example", package = "tflspec")
d <- file.path(tempdir(), "prepare-study")
dir.create(file.path(d, "adam"), recursive = TRUE, showWarnings = FALSE)
if (requireNamespace("haven", quietly = TRUE)) {
for (x in c("adsl", "adae", "adrs", "adlb")) {
df <- getExportedValue("tflspec", x)
for (v in names(df)) if (is.factor(df[[v]])) df[[v]] <- as.character(df[[v]])
haven::write_xpt(df, file.path(d, "adam", paste0(x, ".xpt")))
}
r <- tfl_ai_prepare(d, file.path(ex, "onco_toc_shell.xlsx"),
study_id = "XYZ-ONC-01", overwrite = TRUE)
r[c("request", "outputs", "chars")]
}
#> <tfl_ai_shell: onco_toc_shell.xlsx>
#> 4 sheet(s): TOC (toc), T14.1.1 (shell), T14.2.1 (shell), Safety (shell)
#> 4 report(s) in the TOC, 4 with a shell found
#> text: 3932 characters; format(x) gives it
#> 4 requests (4 reports) in ai/requests; the longest 33295 characters.
#> Next: paste ai/requests/demographics-1.md into a new chat; save the whole answer as ai/answers/demographics-1.md, then run tfl_ai_collect_answers().
#> request outputs chars
#> 1 demographics-1 T-14-1-1 33295
#> 2 ae-1 T-14-3-1 33176
#> 3 labs-1 T-14-3-5 32997
#> 4 efficacy-1 T-14-2-1 33168