| auto_fix | R Documentation |
Self-healing runtime for R code execution. Implements a "Hypothesis-Fix-Verify" loop that feeds error messages, stack traces, and context back to an LLM for automatic error correction.
Execute R code with automatic error recovery using LLM assistance. When code fails, the error is analyzed and a fix is attempted automatically.
auto_fix(
expr,
model = NULL,
max_attempts = 3,
context = NULL,
verbose = TRUE,
memory = NULL
)
expr |
The R expression to execute. |
model |
The LLM model to use for error analysis (default: from options). |
max_attempts |
Maximum number of fix attempts (default: 3). |
context |
Optional additional context about the code's purpose. |
verbose |
Print progress messages (default: TRUE). |
memory |
Optional ProjectMemory object for learning from past fixes. |
The result of successful execution, or an error if all attempts fail.
## Not run:
# Simple usage - auto-fix a data transformation
result <- auto_fix({
df <- read.csv("data.csv")
df %>%
filter(value > 100) %>%
summarize(mean = mean(value))
})
# With context for better error understanding
result <- auto_fix(
expr = {
model <- lm(y ~ x, data = df)
},
context = "Fitting a linear regression model to predict sales"
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.