diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml new file mode 100644 index 0000000..9c8c78d --- /dev/null +++ b/.github/workflows/R-CMD-check.yaml @@ -0,0 +1,40 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + push: + branches: [main, master] + pull_request: + branches: [main, master, dev] + release: + types: [published] + schedule: + - cron: '00 09 * * 0' + workflow_dispatch: + +name: R-CMD-check + +jobs: + R-CMD-check: + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + R_KEEP_PKG_SOURCE: yes + # Dummy API keys for testing (these are not real keys) + OPENAI_API_KEY: sk-test-dummy-key-for-ci-testing-only + ENDPOINTR_API_KEY: test-dummy-key-for-ci-testing-only + ANTHROPIC_API_KEY: sk-ant-test-dummy-key-for-ci-testing-only + HF_API_KEY: hf_test_dummy_key_for_ci_testing_only + HF_TEST_API_KEY: hf_test_dummy_key_for_ci_testing_only + FAKE_API_KEY: fake-test-dummy-key-for-ci-testing-only + steps: + - uses: actions/checkout@v3 + + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::rcmdcheck + + - uses: r-lib/actions/check-r-package@v2 diff --git a/R/data.R b/R/data.R index 42b3869..14c731e 100644 --- a/R/data.R +++ b/R/data.R @@ -28,7 +28,7 @@ #' \item{text}{Character; the original text that was embedded} #' \item{category}{Character; category classification of the text} #' \item{.error}{Logical; whether the embedding process failed} -#' \item{.error_msg}{Character; error message if embedding failed (NA if successful)} +#' \item{.error_message}{Character; error message if embedding failed (NA if successful)} #' \item{V1}{Numeric; embedding vector dimensions} #' \item{V2}{Numeric; embedding vector dimensions} #' \item{V3}{Numeric; embedding vector dimensions} @@ -815,7 +815,7 @@ #' \item{NEGATIVE}{Numeric; probability score for negative sentiment (0-1)} #' \item{POSITIVE}{Numeric; probability score for positive sentiment (0-1)} #' \item{.error}{Logical; whether the classification process failed} -#' \item{.error_msg}{Character; error message if classification failed (NA if successful)} +#' \item{.error_message}{Character; error message if classification failed (NA if successful)} #' } #' @source Generated using Hugging Face sentiment classification model via EndpointR functions "df_sentiment_classification_example" diff --git a/R/utils.R b/R/utils.R index bb4ef98..9c3f5c9 100644 --- a/R/utils.R +++ b/R/utils.R @@ -21,18 +21,24 @@ get_api_key <- function(key_name) { stopifnot("`key_name` should be a string" = is.character(key_name)) # add && API_KEY check here? - renviron_path <- path.expand("~/.Renviron") - if(!file.exists(renviron_path)){ - cli::cli_abort("{.file {renviron_path}} not found, please create one.") - } - if(!endsWith(key_name, "API_KEY")){ cli::cli_abort("{.val {key_name}} is an invalid name. API keys must end with 'API_KEY'") } + # Check if the environment variable is already set (e.g., in CI or via withr::with_envvar) api_key <- Sys.getenv(key_name) if(identical(api_key, "")) { + # Only check for .Renviron if the environment variable is not set + renviron_path <- path.expand("~/.Renviron") + if(!file.exists(renviron_path)){ + cli::cli_abort(c( + "{.val {key_name}} was not found in environment variables", + "i" = "{.file {renviron_path}} not found either", + "i" = "Please set with {.code set_api_key({key_name})}, and restart your R session for changes to take effect." + )) + } + cli::cli_abort("{.val {key_name}} was not found, please set with {.code set_api_key({key_name})}, and restart your R session for changes to take effect.") } diff --git a/README.Rmd b/README.Rmd index 70bc15b..d946ed1 100644 --- a/README.Rmd +++ b/README.Rmd @@ -11,13 +11,9 @@ knitr::opts_chunk$set( ) ``` -SAMY Data Science - # EndpointR - - - +[![R-CMD-check](https://github.com/jpcompartir/EndpointR/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/jpcompartir/EndpointR/actions/workflows/R-CMD-check.yaml) [![pkgdown](https://github.com/jpcompartir/EndpointR/actions/workflows/pkgdown.yaml/badge.svg)](https://github.com/jpcompartir/EndpointR/actions/workflows/pkgdown.yaml) EndpointR is a 'batteries included', open-source R package for connecting to various Application Programming Interfaces ([APIs](https://en.wikipedia.org/wiki/API){target="_blank"}) for Machine Learning model predictions. @@ -283,3 +279,7 @@ Read the [LLM Providers Vignette](articles/llm_providers.html), and the [Structu - Read the [httr2 vignette](https://httr2.r-lib.org/articles/wrapping-apis.html#basics){target="_blank"} on managing your API keys securely and encrypting them. - Read the [EndpointR API Keys](articles/api_keys.html) vignette for information on which API keys you need for wach endpoint we support, and how to securely import those API keys into your .Renvironfile. + +--- + +SAMY Data Science diff --git a/README.md b/README.md index e21f3fa..c61f480 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,10 @@ -SAMY Data Science - # EndpointR - - - +[![R-CMD-check](https://github.com/jpcompartir/EndpointR/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/jpcompartir/EndpointR/actions/workflows/R-CMD-check.yaml) +[![pkgdown](https://github.com/jpcompartir/EndpointR/actions/workflows/pkgdown.yaml/badge.svg)](https://github.com/jpcompartir/EndpointR/actions/workflows/pkgdown.yaml) EndpointR is a ‘batteries included’, open-source R package for connecting to various Application Programming Interfaces @@ -297,5 +294,9 @@ information on common workflows with the OpenAI Chat Completions API information on which API keys you need for wach endpoint we support, and how to securely import those API keys into your .Renvironfile. +------------------------------------------------------------------------ + +SAMY Data Science + [^1]: Content pending implementation for Anthroic Messages API, Gemini API, and OpenAI Responses API diff --git a/inst/images/samy_banner.png b/inst/images/samy_banner.png new file mode 100644 index 0000000..9418f7c Binary files /dev/null and b/inst/images/samy_banner.png differ diff --git a/inst/images/samy_logo_small.png b/inst/images/samy_logo_small.png new file mode 100644 index 0000000..4f8a3ba Binary files /dev/null and b/inst/images/samy_logo_small.png differ diff --git a/man/df_embeddings_hf.Rd b/man/df_embeddings_hf.Rd index e0bd787..ae7753b 100644 --- a/man/df_embeddings_hf.Rd +++ b/man/df_embeddings_hf.Rd @@ -11,7 +11,7 @@ A data frame with 3 rows and 773 variables: \item{text}{Character; the original text that was embedded} \item{category}{Character; category classification of the text} \item{.error}{Logical; whether the embedding process failed} -\item{.error_msg}{Character; error message if embedding failed (NA if successful)} +\item{.error_message}{Character; error message if embedding failed (NA if successful)} \item{V1}{Numeric; embedding vector dimensions} \item{V2}{Numeric; embedding vector dimensions} \item{V3}{Numeric; embedding vector dimensions} diff --git a/man/df_sentiment_classification_example.Rd b/man/df_sentiment_classification_example.Rd index c4efb77..662137d 100644 --- a/man/df_sentiment_classification_example.Rd +++ b/man/df_sentiment_classification_example.Rd @@ -13,7 +13,7 @@ A data frame with 3 rows and 7 variables: \item{NEGATIVE}{Numeric; probability score for negative sentiment (0-1)} \item{POSITIVE}{Numeric; probability score for positive sentiment (0-1)} \item{.error}{Logical; whether the classification process failed} -\item{.error_msg}{Character; error message if classification failed (NA if successful)} +\item{.error_message}{Character; error message if classification failed (NA if successful)} } } \source{