Queries a language model API with structured neuroscience prompts (e.g., IDP-domain consistency, region-network assignment) and parses the output into a clean data frame.
assess_prompt(
df,
text_cols,
context_col = NULL,
prompt = "You are a neuroscientist. Return JSON.",
backend = c("groq", "openrouter"),
api_key_env = NULL,
model = NULL,
required_fields = c("short_form", "long_form"),
user_input_prompt = "Return structured JSON output.",
collapse_fn = function(x) paste(na.omit(x), collapse = ", "),
max_retries = 5,
retry_delay_base = 2,
jitter = TRUE,
temperature = 0.1,
parallel = FALSE,
.options_furrr = furrr::furrr_options(),
cache_dir = NULL,
verbose = TRUE,
skip_api_key_check = FALSE
)
A data frame containing input data (domains, IDPs, regions, etc.).
Character vector, column names to collapse into the user query (e.g. IDPs, regions).
Character, optional column name providing task context (e.g., domain). Default: NULL.
Character, system prompt to set context. Default: "You are a neuroscientist. Return JSON."
Character, API backend ("groq", "openrouter"). Default: "groq".
Character, environment variable storing the API key. Default: NULL.
Character, model name. Default: NULL (uses backend default).
Character vector, keys required in parsed API response. Default: c("short_form", "long_form").
Character, additional user prompt text. Default: "Return structured JSON output."
Function, how to collapse multiple text columns. Default: function(x) paste(na.omit(x), collapse = ", ")
.
Integer, maximum API retry attempts. Default: 5.
Numeric, base delay (seconds) for exponential backoff. Default: 2.
Logical, add jitter to retry delays. Default: TRUE.
Numeric, sampling temperature (0–1). Default: 0.1.
Logical, use parallel processing with furrr::future_map
. Default: FALSE.
List, options for furrr::future_map
. Default: furrr::furrr_options()
.
Character, directory for caching API responses. Default: NULL.
Logical, print debug information. Default: TRUE.
Logical, if TRUE, skip API key validation (useful for testing). Default: FALSE.
A tibble combining original data with parsed model outputs.