ai_config() sets them for the session (a function's own settings still
win); with_ai_config() and local_ai_config() for a block of code, as
withr does.
Usage
ai_config(...)
with_ai_config(code, ...)
local_ai_config(..., .local_envir = parent.frame())Arguments
- ...
Settings:
lm(the model:"gpt-4.1-mini","claude-haiku-4-5","gemini:gemini-2.5-flash", ...),temperature,max_tokens,adapter("xml","chat","json"),module("cot": reasoning first),retries,api_retries,concurrency(calls in flight at once, default 8),on_error("warn", the default: a failed row isNA; or"stop"),log_calls(a folder, orTRUE),log_content(TRUE,FALSE,c(transcript = FALSE), or the names of the fields to keep),caller,router(anlm15::new_router());cache_replies(TRUE: in memory;"disk", a folder or a.sqlitefile: kept across runs, shared by every language) andreplicate(the n-th independent answer to the same request);progress(a progress line over a column);observers(functions given every event),journal(ai_journal()) andprogram_observers;plugins(ai_plugin()) andprogram_plugins;approve(a function,"changes","all", or tool names: seeai_conversation());escalate_to(a model or an AI function that answers when the first model is less sure thanescalate_below, default 0.9).- code
Code to run with these settings.
- .local_envir
The environment whose end ends these settings.
Details
What the call log keeps (log_content) is not overridden by a
closer setting: every layer (a function's own, each block, ai_config(),
and the environment variable FUNCTAI_LOG_CONTENT) can only remove. A
value is written only when no layer drops it, so a host holds every
function it runs to "never write the transcript":
with_ai_config(code, log_content = c(transcript = FALSE)), or, surest
against a misspelt name, the list of what may be kept,
log_content = c("question") (the same as list("*" = FALSE, question = TRUE)). Mind the difference: c(question = TRUE) names one field and
says nothing of the others, so it keeps everything; c("question") keeps
only the question. A name is always the field of that name (a field
FunctAI adds included); a one-output function's answer may also be called
by its formula's name when no field has that name.
FUNCTAI_LOG_CONTENT=0 drops every value, whatever the
settings say. A field FunctAI adds (the reasoning, the tool calls) is
written only when no field of the call is dropped. A record that does not
keep every value keeps no request or reply either, and no error message.