What This Agent Does
build_code_agent() helps you generate or debug R code
from natural-language instructions.
Generate Mermaid PNGs
library(LLMAgentR)
my_llm_wrapper <- function(prompt, verbose = FALSE) "LLM response placeholder"
workflow <- build_code_agent(
llm = my_llm_wrapper,
output = "both",
direction = "LR"
)
save_mermaid_png(
x = workflow,
file = "pkgdown/assets/code-agent-workflow.png"
)Step 1: Create an LLM Wrapper
my_llm_wrapper <- function(prompt, verbose = FALSE) {
# Replace with your provider call (OpenAI, Groq, Anthropic, etc.)
"LLM response placeholder"
}Step 2: Build a Reusable Agent
library(LLMAgentR)
coder <- build_code_agent(
llm = my_llm_wrapper,
max_tries = 3,
backoff = 2,
verbose = FALSE
)Step 3: Run a Task
result <- coder(
"Write an R function that standardizes all numeric columns in a data frame."
)
str(result)