tidyverse / elmer

Call LLM APIs from R
http://elmer.tidyverse.org/
Other
208 stars 30 forks source link

chat_github to retrieve api key using Sys.getenv("GITHUB_API_KEY") instead of using gitcreds function, since gitcreds funtions do not work in Shiny deployment #173

Open feitonyliu opened 6 days ago

feitonyliu commented 6 days ago

Currently, chat_github() expects a github credential already setup in the current directory and use gitcreds::gitcreds_get()$password to retrieve the token. I tried to deploy a shiny app using chat_github() with default settings. It works on my computer and not working after being deployed to shinyapps.io, causing a credential not found error.

The suggested change is to retrieve github key using Sys.getenv("GITHUB_API_KEY") and have the token placed in the .Renviron file as GITHUB_API_KEY={github_pat_token}.

There are two benefits making this change:

  1. standardize the API management, github API will be placed in the same way as other api keys, e.g., openai api key, inside the .Renviron file.
  2. it reduces the complication in shiny deployment, where the deployment environment will likely only have access to .Renviron, not github credentials.

Thanks

Tony

hadley commented 4 days ago

We could certainly provide it as a backup, but making it only use an env var would be a large downgrade in user experience for most people.

feitonyliu commented 4 days ago

May be add a note saying that the Github setting does not apply when the applications are deployed to hosting facilities such as shinyapps.io.