R/generate_decision_qmd.R
generate_decision_qmd.RdThis function generates a Quarto (.qmd) report based on the provided decision context and summary of APSIMX outputs. It uses an AI language model to interpret the decision information and produce a structured report that includes narrative explanations and R code for visualisation, following a predefined template.
generate_decision_qmd(
apsimx_file,
decisions,
qmd_file,
decision_type = c("cultivar", "sowing", "nitrogen"),
use_ai = TRUE,
use_cache = TRUE
)Character scalar path to the APSIMX file used in the analysis. This will be referenced in the QMD report.
List of resolved decision objects containing the decision context, including crop, location metadata, soil conditions, and other relevant information that should be included in the report.
Character scalar path where the generated QMD file will be saved. The function will write the generated content to this file.
Character scalar indicating the type of decision to generate the report for. Options are "cultivar", "sowing", or "nitrogen". This will guide the content and structure of the generated report.
Logical scalar indicating whether to use AI for generating the QMD content
(typically TRUE). If FALSE, the function will not generate content and will currently throw an error, as non-AI generation is not implemented yet.
Logical scalar indicating whether to use cached AI responses if available. This can speed up generation if the same prompt has been used before.
Character scalar path to the written output QMD file.
The generated QMD report will be saved to the specified file path. The function ensures that the AI-generated content adheres to strict constraints, relying solely on the provided decision context and summary data without introducing new assumptions or calculations.