Skip to content

Commit

Permalink
changed repo to CorradoLanera/gpteasyr
Browse files Browse the repository at this point in the history
  • Loading branch information
CorradoLanera committed May 21, 2024
1 parent f1387e3 commit e125da7
Show file tree
Hide file tree
Showing 20 changed files with 115 additions and 106 deletions.
2 changes: 1 addition & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
^renv$
^renv\.lock$
^ubep\.gpt\.Rproj$
^gpteasyr\.Rproj$
^\.Rproj\.user$
^README\.Rmd$
^LICENSE\.md$
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ jobs:
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: UBESP-DCTV/ubep.gpt
slug: CorradoLanera/gpteasyr
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ representative at an online or offline event.
## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at Corrado.Lanera@ubep.unipd.it.
reported to the community leaders responsible for enforcement at Corrado.Lanera@gmail.com.
All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
Expand Down
14 changes: 7 additions & 7 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
Package: ubep.gpt
Package: gpteasyr
Title: A basic and simple interface to OpenAI’s GPT API
Version: 0.2.9
Version: 0.3.0
Authors@R:
person("Corrado", "Lanera", , "corrado.lanera@ubep.unipd.it", role = c("aut", "cre"),
person("Corrado", "Lanera", , "corrado.lanera@gmail.com", role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-0520-7428"))
Description: The goal of 'ubep.gpt' is to provide a basic and simple interface to OpenAI's GPT API (and other compatible APIs). The package is also designed to work with (i.e., to query on) dataframes/tibbles, and to simplify the process of querying the API.
Description: The goal of 'gpteasyr' is to provide a basic and simple interface to OpenAI's GPT API (and other compatible APIs). The package is also designed to work with (i.e., to query on) dataframes/tibbles, and to simplify the process of querying the API.
License: MIT + file LICENSE
URL: https://github.com/UBESP-DCTV/ubep.gpt,
https://ubesp-dctv.github.io/ubep.gpt/
BugReports: https://github.com/UBESP-DCTV/ubep.gpt/issues
URL: https://github.com/CorradoLanera/gpteasyr,
https://CorradoLanera.github.io/gpteasyr/
BugReports: https://github.com/CorradoLanera/gpteasyr/issues
Imports:
httr,
jsonlite,
Expand Down
26 changes: 15 additions & 11 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
# ubep.gpt 0.2.9
# gpteasyr 0.3.0

* Changed name and repo to 'CorradoLanera/gpteasyr'.

# gpteasyr 0.2.9

* Added `setup_py` function to setup python backend.
* update `README`

# ubep.gpt 0.2.8
# gpteasyr 0.2.8

* Added `use_py` argument to `gpt_query`, `gpt_query_on_column`, and `get_completion_from_messages`

# ubep.gpt 0.2.7
# gpteasyr 0.2.7

* Added `closing` argument to `compose_usr_prompt`, `compose_prompt`, and `create_usr_data_prompter` functions, to allow add text at the very end of the prompt, i.e., after the embedded text.

# ubep.gpt 0.2.5
# gpteasyr 0.2.5

* Added seed argument to `gpt_query`, `gpt_query_on_column`, and `get_completion_from_messages` functions.

# ubep.gpt 0.2.4
# gpteasyr 0.2.4

* Now `create_usr_data_prompter` can accept a custom delimiter.
* Default delimiter changed from four quotes (`""""`) to three quotes (`"""`).

# ubep.gpt 0.2.3
# gpteasyr 0.2.3

* `stream = FALSE` hard coded (for the moment) on `get_completion_from_messages`.
* column name for results in `gpt_query_on_columns` is now customizable.
Expand All @@ -29,27 +33,27 @@
with a single column only (when `add = FALSE`).
* Add progress bar to `gpt_query_on_column` functions.

# ubep.gpt 0.2.2
# gpteasyr 0.2.2

* hot-fix old calls to `match.arg(model)` in `gpt_query` and `gpt_query_on_column` functions.

# ubep.gpt 0.2.1
# gpteasyr 0.2.1

* Add option to return NA when the API returns an error; this apply on `gpt_query` and `gpt_query_on_column` functions only (i.e., not to the base `get_completion_from_messages` function).

# ubep.gpt 0.2.0
# gpteasyr 0.2.0

* Removed dependency from `{openai}` in favor of `{httr}` and `{jsonlite}` directly
* Now queries can be made to personalized endpoints.
* create_usr_data_prompter now works with empty characters (treated as NULL).
* Now compose_prompt_api correctly manage empty prompts.

# ubep.gpt 0.1.1
# gpteasyr 0.1.1

* 100% coverage passed
* Activated all tests on CI

# ubep.gpt 0.1.0
# gpteasyr 0.1.0

* All functions tested.
* Prompt compositors (i.e., `compose_prompt`, `compose_usr_prompt`, `compose_sys_prompt`, and `create_usr_data_prompter`) now always return a character vector (possibly of length 0).
Expand Down
1 change: 1 addition & 0 deletions R/get_completion_from_messages.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#' tokens used for the request (`prompt_tokens`), answer
#' (`completion_tokens`), and overall (`total_tokens`, the sum of the
#' other two)
#'
#' @export
#'
#' @examples
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion R/query_gpt_on_column.R
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ query_gpt_on_column <- function(
usr_data_prompter <- create_usr_data_prompter(
usr_prompt = usr_prompt,
closing = closing
)
)

gpt_answers <- db[[text_column]] |>
purrr::map(\(txt) {
Expand Down
8 changes: 4 additions & 4 deletions R/setup_py.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#'
#' @examples
#' if (FALSE) {
#' library(ubep.gpt)
#' library(gpteasyr)
#' setup_py()
#'
#' prompt <- compose_prompt_api(
Expand All @@ -35,9 +35,9 @@
setup_py <- function(venv_name = "r-gpt-venv", ask = interactive()) {
if (
(!ask) ||
usethis::ui_yeah(
"Do you want to setup a ({venv_name}) python environment?"
)
usethis::ui_yeah(
"Do you want to setup a ({venv_name}) python environment?"
)
) {
reticulate::virtualenv_create(venv_name, packages = "openai")
reticulate::use_virtualenv(venv_name, required = TRUE)
Expand Down
30 changes: 16 additions & 14 deletions R/zzz.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
.onAttach <- function(...) {
packageStartupMessage("Wellcome to ubep.gpt!")
packageStartupMessage("Wellcome to `{gpteasyr}`!")

if (Sys.getenv("OPENAI_API_KEY") == "") {
packageStartupMessage(
"OPENAI_API_KEY environment variable is not set.\n"
)
packageStartupMessage(
"it is required to use OpenAI APIs with `ubep.gpt`.\n"
"it is required to use OpenAI APIs with `{gpteasyr}`.\n"
)
packageStartupMessage(
"To set the OPENAI_API_KEY environment variable,
Expand All @@ -18,11 +18,11 @@
Never share your API key with others.
Keep it safe and secure.
If you need an API key, you can generate it in the OpenAI-API website
(https://platform.openai.com/api-keys).
Remind to assign it to the correct project
(i.e., NOT to the 'default' one).
(https://platform.openai.com/api-keys), or contact your 'GPT's admin'.
Remind to generate it within the correct (your) project!
(I.e., usually, NOT to the 'default' one.)
If you need to be added to the organization and/or to a project,
please, contact your project's referent.\n\n"
please, contact your GPT's admin.\n\n"
)

packageStartupMessage(
Expand All @@ -34,7 +34,7 @@
"The OPENAI_API_KEY environment variable is set\n"
)
packageStartupMessage(
"You are ready to use the package `ubep.gpt`.\n"
"You are ready to use the package `{gpteasyr}`.\n"
)
packageStartupMessage(
"Just, double check if the key is the correct one.\n\n"
Expand All @@ -44,16 +44,18 @@
Keep it safe and secure.
If you think that your API key was compromised,
you can regenerate it in the OpenAI-API website
(https://platform.openai.com/api-keys).\n\n"
(https://platform.openai.com/api-keys), or contacting your GPT's admin.
\n"
)
packageStartupMessage("Enjoy the package!\n")
packageStartupMessage("Enjoy GPT with `{gpteasyr}`!\n")
}
packageStartupMessage(
"If you like to use the python backend (working only for GPT's OpenAI requests!),\n",
"setup the environmen first by executing:\n",
usethis::ui_code("setup_py()"), "(default virtual environment name is 'r-gpt-venv').\n",
"If you need to change the default name, run:\n",
"If you like to use the Python backend
(working for GPT's OpenAI requests only!),\n",
"setup its environment first by executing:\n",
usethis::ui_code("setup_py()"), "
(default virtual environment name is 'r-gpt-venv').\n",
"If you prefer to use a name different from the default one, run:\n",
usethis::ui_code("setup_py(\"<your_custom_environment_name>\")")
)

}
16 changes: 8 additions & 8 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@ knitr::opts_chunk$set(
)
```

# ubep.gpt
# gpteasyr

<!-- badges: start -->
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[![Codecov test coverage](https://codecov.io/gh/UBESP-DCTV/ubep.gpt/branch/main/graph/badge.svg)](https://app.codecov.io/gh/UBESP-DCTV/ubep.gpt?branch=main)
[![R-CMD-check](https://github.com/UBESP-DCTV/ubep.gpt/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/UBESP-DCTV/ubep.gpt/actions/workflows/R-CMD-check.yaml)
[![Codecov test coverage](https://codecov.io/gh/CorradoLanera/gpteasyr/branch/main/graph/badge.svg)](https://app.codecov.io/gh/CorradoLanera/gpteasyr?branch=main)
[![R-CMD-check](https://github.com/CorradoLanera/gpteasyr/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/CorradoLanera/gpteasyr/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->

The goal of `{ubep.gpt}` is to provide a basic/simple interface to OpenAI's GPT API. The package is designed to work with dataframes/tibbles and to simplify the process of querying the API.
The goal of `{gpteasyr}` is to provide a basic/simple interface to OpenAI's GPT API. The package is designed to work with dataframes/tibbles and to simplify the process of querying the API.

## Installation

You can install the development version of `{ubep.gpt}` like so:
You can install the development version of `{gpteasyr}` like so:

``` r
remotes::install_github("UBESP-DCTV/ubep.gpt")
remotes::install_github("CorradoLanera/gpteasyr")
```

## Basic example
Expand All @@ -42,7 +42,7 @@ To use the function you need to compose a prompt. You can use (but it is not nec
Once you have queried the API, you can extract the content of the response using the `get_content` function. You can also extract the tokens of the prompt and the response using the `get_tokens` function.

```{r}
library(ubep.gpt)
library(gpteasyr)
prompt <- compose_prompt_api(
sys_prompt = "You are the assistant of a university professor.",
usr_prompt = "Tell me about the last course you provided."
Expand Down Expand Up @@ -295,5 +295,5 @@ cat(res)

## Code of Conduct

Please note that the ubep.gpt project is released with a [Contributor Code of Conduct](https://contributor-covenant.org/version/2/1/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.
Please note that the gpteasyr project is released with a [Contributor Code of Conduct](https://contributor-covenant.org/version/2/1/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.

Loading

0 comments on commit e125da7

Please sign in to comment.