Skip to content

Commit

Permalink
Updated default model to gpt-4o-mini
Browse files Browse the repository at this point in the history
  • Loading branch information
jcrodriguez1989 committed Aug 8, 2024
1 parent 10192e3 commit 335d505
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 3 deletions.
4 changes: 4 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,19 @@ export(create_variable_name)
export(document_code)
export(explain_code)
export(find_issues_in_code)
export(list_models)
export(optimize_code)
export(refactor_code)
export(reset_chat_session)
importFrom(clipr,read_clip)
importFrom(httr,GET)
importFrom(httr,POST)
importFrom(httr,add_headers)
importFrom(httr,content)
importFrom(httr,content_type_json)
importFrom(httr,stop_for_status)
importFrom(httr,use_proxy)
importFrom(jsonlite,fromJSON)
importFrom(jsonlite,toJSON)
importFrom(miniUI,gadgetTitleBar)
importFrom(miniUI,miniPage)
Expand Down
2 changes: 1 addition & 1 deletion R/gpt_get_completions.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ gpt_get_completions <- function(prompt, openai_api_key = Sys.getenv("OPENAI_API_
}
# See https://platform.openai.com/docs/api-reference/chat .
params <- list(
model = Sys.getenv("OPENAI_MODEL", "gpt-3.5-turbo"),
model = Sys.getenv("OPENAI_MODEL", "gpt-4o-mini"),
max_tokens = as.numeric(Sys.getenv("OPENAI_MAX_TOKENS", 256)),
temperature = as.numeric(Sys.getenv("OPENAI_TEMPERATURE", 1)),
top_p = as.numeric(Sys.getenv("OPENAI_TOP_P", 1)),
Expand Down
24 changes: 24 additions & 0 deletions R/list_models.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#' ChatGPT: List Models
#'
#' @param openai_api_key OpenAI's API key.
#'
#' @examples
#' \dontrun{
#' list_models()
#' }
#'
#' @importFrom httr add_headers content GET stop_for_status
#' @importFrom jsonlite fromJSON
#'
#' @return A data.frame with the available models to be used by OpenAI's API.
#'
#' @export
#'
list_models <- function(openai_api_key = Sys.getenv("OPENAI_API_KEY")) {
get_res <- GET(
paste0(api_url, "/models"),
add_headers("Authorization" = paste("Bearer", openai_api_key))
)
stop_for_status(get_res)
fromJSON(content(get_res, as = "text", encoding = "UTF-8"))$data
}
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ ChatGPT model parameters can be tweaked by using environment variables.

The following environment variables can be set to tweak the behavior, as documented in https://beta.openai.com/docs/api-reference/completions/create .

* `OPENAI_MODEL`; defaults to `"gpt-3.5-turbo"`
* `OPENAI_MODEL`; defaults to `"gpt-4o-mini"`
* `OPENAI_MAX_TOKENS`; defaults to `256`
* `OPENAI_TEMPERATURE`; defaults to `1`
* `OPENAI_TOP_P`; defaults to `1`
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ The following environment variables can be set to tweak the behavior, as
documented in
<https://beta.openai.com/docs/api-reference/completions/create> .

- `OPENAI_MODEL`; defaults to `"gpt-3.5-turbo"`
- `OPENAI_MODEL`; defaults to `"gpt-4o-mini"`
- `OPENAI_MAX_TOKENS`; defaults to `256`
- `OPENAI_TEMPERATURE`; defaults to `1`
- `OPENAI_TOP_P`; defaults to `1`
Expand Down
23 changes: 23 additions & 0 deletions man/list_models.Rd

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

0 comments on commit 335d505

Please sign in to comment.