View source: R/build_interpreter_agent.R
build_interpreter_agent | R Documentation |
Constructs an LLM-powered agent that explains plots, tables, text, or other outputs for both technical and non-technical audiences.
llm |
Function that takes |
interpreter_prompt |
Optional template for the prompt (default supplied). |
code_output |
The output to interpret (plot caption, table text,
model summary, etc.). **Default |
max_tries |
Max LLM retry attempts (default |
backoff |
Seconds between retries (default |
verbose |
Logical; print progress (default |
**Two calling patterns**
**Builder pattern** – omit code_output
; a reusable
interpreter-agent closure is returned.
**One-shot pattern** – provide code_output
; the function runs
immediately and returns the interpretation.
If code_output
is NULL
: a function (closure).
Otherwise: a list with
The full prompt sent to the LLM.
The LLM’s explanation (or error).
Logical; did it succeed?
Number of attempts made.
## Not run:
## 1) Builder pattern --------------------------------------------
interp <- build_interpreter_agent(llm = my_llm_wrapper, verbose = FALSE)
table_txt <- "
| Region | Sales | Profit |
| North | 2000 | 300 |
| South | 1500 | 250 |"
res1 <- interp(table_txt)
res2 <- interp("R² = 0.87 for the fitted model …")
## 2) One-shot pattern -------------------------------------------
build_interpreter_agent(
llm = my_llm_wrapper,
code_output = table_txt,
verbose = FALSE
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.