The CHatGPT Assisted Debugging (CHAD) package is an attempt to make debugging in R more user-friendly. It works by submitting error and stack trace messages to OpenAI to provide human-readable error interpretation, context, and debugging advice. It depends on the cli
, rlang
, jsonlite
and OpenAI
packages as well as an active OpenAI API key.
To install the package run:
library(devtools)
install_github("n8layman/chad")
To use:
- Add your OpenAI API key to the global environment using
Sys.setenv(OPENAI_API_KEY = "sk-xxxx")
where "sk-xxx" is your OpenAI API key. - Run
rlang::global_entrace()
before running the code that you suspect will generate an error. - After encountering an error run
explain_last_error()
. The ChatGPT enhanced error will be displayed as a message and returned invisibly for manual printing.