Constructs an agent that uses LLM to interpret various outputs (plots, tables, text results) and provides structured explanations suitable for both technical and non-technical audiences.
Arguments
- llm
A function that accepts a character prompt and returns an LLM response.
- interpreter_prompt
Optional custom prompt template (default provides structured interpretation framework).
- code_output
The output to interpret (chart summary, table, text results etc.).
- max_tries
Maximum number of attempts for LLM calls (default: 3).
- backoff
Seconds to wait between retries (default: 2).
- verbose
Logical controlling progress messages (default: TRUE).
Value
A list containing:
prompt - The full prompt sent to LLM
interpretation - The generated interpretation
success - Logical indicating if interpretation succeeded
attempts - Number of tries made
Examples
if (FALSE) { # \dontrun{
# Example table or code output
output_text <- "
| Region | Sales | Profit |
|---------|-------|--------|
| North | 2000 | 300 |
| South | 1500 | 250 |
| East | 1800 | 400 |
| West | 2200 | 100 |
"
# Build interpreter agent
interpreter_agent <- build_interpreter_agent(
llm = my_llm_wrapper,
code_output = output_text,
max_tries = 3,
backoff = 2,
verbose = FALSE
)
} # }