You can log into OpenAI’s API running the dedicated
login()
function or just ask something with
askgpt()
:
library(askgpt)
login()
#> ℹ It looks like you have not provided an API key yet. Let me guide you through the process:
#> 1. Go to <https://platform.openai.com/account/api-keys>
#> 2. (Log into your account if you haven't done so yet)
#> 3. On the site, click the button + Create new secret key
#> to create an API key
#> 4. Copy this key into R/RStudio
You will not need to do this again after the first time. (Technical
detail: This will store an encrypted version of your key in the
directory returned by rappdirs::user_cache_dir("askgpt")
.)
If your old API key does not work any more, you can store a new one
with: login(force_refresh = TRUE)
.
To enable error logging (which you need if you want askgpt to explain errors to you) first run:
After this, the key phrase “What is wrong with my last
command?” (or just “help!”) will make askgpt
look
up your last command and error message and return some help for you. The
other important key phrase is “Can you elaborate on
that?” (or just “What?”), which will elaborate on the previous
answer. You can ask basically any question you want though: