if (FALSE) {
## ------------------------------------------------------------------
## 1) Builder pattern – create a reusable coder agent
## ------------------------------------------------------------------
coder <- build_code_agent(
llm = my_llm_wrapper, # your own wrapper around the LLM API
max_tries = 3,
backoff = 2,
verbose = FALSE
)
# Use the agent multiple times
res1 <- coder("Write an R function that z-score–standardises all numeric columns.")
res2 <- coder("Explain what `%>%` does in tidyverse pipelines.")
## ------------------------------------------------------------------
## 2) One-shot pattern – run a single request immediately
## ------------------------------------------------------------------
one_shot <- build_code_agent(
llm = my_llm_wrapper,
user_input = "Create a ggplot2 bar chart of mpg by cyl in mtcars.",
max_tries = 3,
backoff = 2,
verbose = FALSE
)
}
Run the code above in your browser using DataLab