Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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"
Expand Down
16 changes: 11 additions & 5 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
}

Expand Down
10 changes: 5 additions & 5 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,9 @@ knitr::opts_chunk$set(
)
```

<img src="man/figures/samy_banner.png" alt="SAMY Data Science" width="100%"/>

# EndpointR

<!-- badges: start -->

<!-- badges: end -->
[![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.

Expand Down Expand Up @@ -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.

---

<img src="man/figures/samy_banner.png" alt="SAMY Data Science" width="100%"/>
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@

<!-- README.md is generated from README.Rmd. Please edit that file -->

<img src="man/figures/samy_banner.png" alt="SAMY Data Science" width="100%"/>

# EndpointR

<!-- badges: start -->

<!-- badges: end -->
[![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
Expand Down Expand Up @@ -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.

------------------------------------------------------------------------

<img src="man/figures/samy_banner.png" alt="SAMY Data Science" width="100%"/>

[^1]: Content pending implementation for Anthroic Messages API, Gemini
API, and OpenAI Responses API
Binary file added inst/images/samy_banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added inst/images/samy_logo_small.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion man/df_embeddings_hf.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/df_sentiment_classification_example.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.