Skip to content

Instantly share code, notes, and snippets.

@pjastam
Created June 30, 2024 13:52
Show Gist options
  • Save pjastam/ec0e664fb2d620107873aba6e0f3d621 to your computer and use it in GitHub Desktop.
Save pjastam/ec0e664fb2d620107873aba6e0f3d621 to your computer and use it in GitHub Desktop.
Setup file for using ChatGPT in RStudio
#####################################################################
# Source: https://mlverse.github.io/chattr/articles/openai-gpt.html
#####################################################################
# Insert your personal OpenAI secret key to autheticate the chattr app
Sys.setenv("OPENAI_API_KEY" = "####################")
#####################################################################
# Source: https://mlverse.github.io/chattr/
#####################################################################
# Install the remotes package if not already installed
if (!require(remotes)) {
install.packages("remotes")
}
# Install the chattr package (from GitHub) if not already installed
if (!require(chattr)) {
remotes::install_github("mlverse/chattr")
}
# Select the model back-end you with to use (copilot/gpt35/gpt4/llamagpt)
chattr::chattr_use("gpt4")
# Run the chattr app in the RStudio Viewer pane by default
chattr::chattr_app()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment