Answer questions about predmicror models using a deterministic local registry and, when available, an optional local Ollama model for prose. Model-fitting code is generated from package metadata and statically checked before being returned.
Usage
predmicror_assistant(
query,
model = "llama3-groq-tool-use:8b",
root = NULL,
data = NULL,
file = NULL,
sheet = NULL,
sep = NULL,
dec = ".",
na.strings = c("", "NA"),
task = NULL,
time = NULL,
response = NULL,
temperature = NULL,
ph = NULL,
aw = NULL,
inhibitor = NULL,
return_context = FALSE,
conversation = NULL,
backend = c("auto", "ollama", "deterministic"),
prefer_wrappers = TRUE,
verify_code = TRUE,
return_trace = FALSE
)Arguments
- query
Character question to ask.
- model
Ollama model name used when
backendis"auto"or"ollama".- root
Path to the package root for context collection. Defaults to the installed package path when available, otherwise the current working directory.
- data
Optional data frame to profile and use for data-aware code generation.
- file
Optional path to a .csv, .txt, .tsv, .xls, or .xlsx file to read, profile, and use for data-aware code generation.
- sheet
Optional Excel sheet name or index when
fileis .xls or .xlsx.- sep
Optional field separator for delimited text files. If NULL, a simple separator detector is used.
- dec
Decimal mark for delimited text files.
- na.strings
Character vector of strings to treat as missing values when reading delimited text files.
- task
Optional data task override. Use one of
"growth","inactivation", or"cardinal";NULLkeeps automatic detection.- time, response, temperature, ph, aw, inhibitor
Optional column-name overrides used when
dataorfileis supplied.- return_context
Logical; if TRUE, returns a list with answer and context.
- conversation
Optional list or character vector with prior questions and answers to include as conversational context.
- backend
Character string. One of
"auto","ollama", or"deterministic"."auto"uses Ollama when the CLI is available and otherwise falls back to deterministic registry-based output.- prefer_wrappers
Logical; if TRUE, generated fitting examples prefer
fit_growth(),fit_inactivation(), andfit_cardinal()over directgslnls::gsl_nls()calls.- verify_code
Logical; if TRUE, statically checks generated R code with
parse()and simple model-scale/signature rules.- return_trace
Logical; if TRUE, returns prompt, backend, candidates, generated code, and validation metadata for debugging.
Value
Character response by default; list with answer and context when
return_context = TRUE or list with trace when return_trace = TRUE.
Examples
predmicror_assistant("How do I fit a Huang model?", backend = "deterministic")
#> [1] "\nSuggested model: `HuangFM` - full Huang primary growth model.\nExpected response scale: `lnN`; example response column: `lnN`.\nI used `fit_growth()` as the main path; direct `gsl_nls()` calls are better left for advanced use.\nGrowth responses should be on the natural logarithm scale (lnN).\n\n```r\ndata(growthfull)\nfit <- fit_growth(\n data = growthfull,\n model = \"HuangFM\",\n time = \"Time\",\n response = \"lnN\",\n start = list(Y0 = 0, Ymax = 22, MUmax = 1.7, lag = 5)\n)\nsummary(fit)\nfit_metrics(fit)\naug <- predmicror_augment(fit)\nnew_times <- data.frame(Time = seq(min(growthfull$Time), max(growthfull$Time), length.out = 200))\npred <- predict(fit, newdata = new_times)\nplot(lnN ~ Time, data = growthfull, xlab = \"Time\", ylab = \"ln N\")\nlines(new_times$Time, pred, col = \"blue\", lwd = 2)\npoints(growthfull$Time, aug$.fitted, pch = 16, col = \"grey40\")\n```\nVerification: the code passed static parse() and simple scale/signature checks."
