Title: | R Wrapper for OpenAI API |
---|---|
Description: | An R wrapper of OpenAI API endpoints (see <https://platform.openai.com/docs/introduction> for details). This package covers Models, Completions, Chat, Edits, Images, Embeddings, Audio, Files, Fine-tunes, Moderations, and legacy Engines endpoints. |
Authors: | Iegor Rudnytskyi [aut, cre] |
Maintainer: | Iegor Rudnytskyi <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.4.1 |
Built: | 2024-11-13 13:08:57 UTC |
Source: | https://github.com/irudnyts/openai |
Cancel a running fine-tune job. See this page for details.
cancel_fine_tune( fine_tune_id, openai_api_key = Sys.getenv("OPENAI_API_KEY"), openai_organization = NULL )
cancel_fine_tune( fine_tune_id, openai_api_key = Sys.getenv("OPENAI_API_KEY"), openai_organization = NULL )
fine_tune_id |
required; a length one character vector. |
openai_api_key |
required; defaults to |
openai_organization |
optional; defaults to |
For arguments description please refer to the official documentation.
Returns a list, elements of which contains information about the cancelled fine-tune.
Other fine-tune functions:
create_fine_tune()
,
delete_fine_tune_model()
,
list_fine_tune_events()
,
list_fine_tunes()
,
retrieve_fine_tune()
## Not run: training_file <- system.file( "extdata", "sport_prepared_train.jsonl", package = "openai" ) validation_file <- system.file( "extdata", "sport_prepared_train.jsonl", package = "openai" ) training_info <- upload_file(training_file, "fine-tune") validation_info <- upload_file(validation_file, "fine-tune") info <- create_fine_tune( training_file = training_info$id, validation_file = validation_info$id, model = "ada", compute_classification_metrics = TRUE, classification_positive_class = " baseball" # Mind space in front ) id <- ifelse( length(info$data$id) > 1, info$data$id[length(info$data$id)], info$data$id ) cancel_fine_tune(fine_tune_id = id) ## End(Not run)
## Not run: training_file <- system.file( "extdata", "sport_prepared_train.jsonl", package = "openai" ) validation_file <- system.file( "extdata", "sport_prepared_train.jsonl", package = "openai" ) training_info <- upload_file(training_file, "fine-tune") validation_info <- upload_file(validation_file, "fine-tune") info <- create_fine_tune( training_file = training_info$id, validation_file = validation_info$id, model = "ada", compute_classification_metrics = TRUE, classification_positive_class = " baseball" # Mind space in front ) id <- ifelse( length(info$data$id) > 1, info$data$id[length(info$data$id)], info$data$id ) cancel_fine_tune(fine_tune_id = id) ## End(Not run)
Creates a completion for the chat message. See this page for details.
create_chat_completion( model, messages = NULL, temperature = 1, top_p = 1, n = 1, stream = FALSE, stop = NULL, max_tokens = NULL, presence_penalty = 0, frequency_penalty = 0, logit_bias = NULL, user = NULL, openai_api_key = Sys.getenv("OPENAI_API_KEY"), openai_organization = NULL )
create_chat_completion( model, messages = NULL, temperature = 1, top_p = 1, n = 1, stream = FALSE, stop = NULL, max_tokens = NULL, presence_penalty = 0, frequency_penalty = 0, logit_bias = NULL, user = NULL, openai_api_key = Sys.getenv("OPENAI_API_KEY"), openai_organization = NULL )
model |
required; a length one character vector. |
messages |
required; defaults to |
temperature |
required; defaults to |
top_p |
required; defaults to |
n |
required; defaults to |
stream |
required; defaults to |
stop |
optional; defaults to |
max_tokens |
required; defaults to |
presence_penalty |
required; defaults to |
frequency_penalty |
required; defaults to |
logit_bias |
optional; defaults to |
user |
optional; defaults to |
openai_api_key |
required; defaults to |
openai_organization |
optional; defaults to |
For arguments description please refer to the official documentation.
Returns a list, elements of which contain chat completion(s) and supplementary information.
## Not run: create_chat_completion( model = "gpt-3.5-turbo", messages = list( list( "role" = "system", "content" = "You are a helpful assistant." ), list( "role" = "user", "content" = "Who won the world series in 2020?" ), list( "role" = "assistant", "content" = "The Los Angeles Dodgers won the World Series in 2020." ), list( "role" = "user", "content" = "Where was it played?" ) ) ) ## End(Not run)
## Not run: create_chat_completion( model = "gpt-3.5-turbo", messages = list( list( "role" = "system", "content" = "You are a helpful assistant." ), list( "role" = "user", "content" = "Who won the world series in 2020?" ), list( "role" = "assistant", "content" = "The Los Angeles Dodgers won the World Series in 2020." ), list( "role" = "user", "content" = "Where was it played?" ) ) ) ## End(Not run)
Creates a completion based on the provided prompt and parameters. See this page for details.
create_completion( engine_id = deprecated(), model, prompt = "<|endoftext|>", suffix = NULL, max_tokens = 16, temperature = 1, top_p = 1, n = 1, stream = FALSE, logprobs = NULL, echo = FALSE, stop = NULL, presence_penalty = 0, frequency_penalty = 0, best_of = 1, logit_bias = NULL, user = NULL, openai_api_key = Sys.getenv("OPENAI_API_KEY"), openai_organization = NULL )
create_completion( engine_id = deprecated(), model, prompt = "<|endoftext|>", suffix = NULL, max_tokens = 16, temperature = 1, top_p = 1, n = 1, stream = FALSE, logprobs = NULL, echo = FALSE, stop = NULL, presence_penalty = 0, frequency_penalty = 0, best_of = 1, logit_bias = NULL, user = NULL, openai_api_key = Sys.getenv("OPENAI_API_KEY"), openai_organization = NULL )
engine_id |
|
model |
required; a length one character vector. |
prompt |
required; defaults to |
suffix |
optional; defaults to |
max_tokens |
required; defaults to |
temperature |
required; defaults to |
top_p |
required; defaults to |
n |
required; defaults to |
stream |
required; defaults to |
logprobs |
optional; defaults to |
echo |
required; defaults to |
stop |
optional; defaults to |
presence_penalty |
required; defaults to |
frequency_penalty |
required; defaults to |
best_of |
required; defaults to |
logit_bias |
optional; defaults to |
user |
optional; defaults to |
openai_api_key |
required; defaults to |
openai_organization |
optional; defaults to |
For arguments description please refer to the official documentation.
Returns a list, elements of which contain completion(s) and supplementary information.
## Not run: create_completion( model = "text-davinci-002", prompt = "Say this is a test", max_tokens = 5 ) logit_bias <- list( "11" = -100, "13" = -100 ) create_completion( model = "ada", prompt = "Generate a question and an answer", n = 4, best_of = 4, logit_bias = logit_bias ) ## End(Not run)
## Not run: create_completion( model = "text-davinci-002", prompt = "Say this is a test", max_tokens = 5 ) logit_bias <- list( "11" = -100, "13" = -100 ) create_completion( model = "ada", prompt = "Generate a question and an answer", n = 4, best_of = 4, logit_bias = logit_bias ) ## End(Not run)
Creates an edit based on the provided input, instruction, and parameters. See this page for details.
create_edit( engine_id = deprecated(), model, input = "\"", instruction, temperature = 1, top_p = 1, openai_api_key = Sys.getenv("OPENAI_API_KEY"), openai_organization = NULL )
create_edit( engine_id = deprecated(), model, input = "\"", instruction, temperature = 1, top_p = 1, openai_api_key = Sys.getenv("OPENAI_API_KEY"), openai_organization = NULL )
engine_id |
|
model |
required; a length one character vector. |
input |
required; defaults to |
instruction |
required; a length one character vector. |
temperature |
required; defaults to |
top_p |
required; defaults to |
openai_api_key |
required; defaults to |
openai_organization |
optional; defaults to |
For arguments description please refer to the official documentation.
Returns a list, elements of which contain edited version of prompt and supplementary information.
## Not run: create_edit( model = "text-davinci-edit-001", input = "What day of the wek is it?", instruction = "Fix the spelling mistakes" ) ## End(Not run)
## Not run: create_edit( model = "text-davinci-edit-001", input = "What day of the wek is it?", instruction = "Fix the spelling mistakes" ) ## End(Not run)
Creates an embedding vector that represents the provided input. See this page for details.
create_embedding( engine_id = deprecated(), model, input, user = NULL, openai_api_key = Sys.getenv("OPENAI_API_KEY"), openai_organization = NULL )
create_embedding( engine_id = deprecated(), model, input, user = NULL, openai_api_key = Sys.getenv("OPENAI_API_KEY"), openai_organization = NULL )
engine_id |
|
model |
required; a length one character vector. |
input |
required; an arbitrary length character vector. |
user |
optional; defaults to |
openai_api_key |
required; defaults to |
openai_organization |
optional; defaults to |
For arguments description please refer to the official documentation.
Returns a list, an element of which contains embedding vector(s) for a given input.
## Not run: create_embedding( model = "text-embedding-ada-002", input = c( "Ah, it is so boring to write documentation", "But examples are really crucial" ) ) ## End(Not run)
## Not run: create_embedding( model = "text-embedding-ada-002", input = c( "Ah, it is so boring to write documentation", "But examples are really crucial" ) ) ## End(Not run)
Creates a job that fine-tunes a specified model based on a given dataset. See this page for details.
create_fine_tune( training_file, validation_file = NULL, model, n_epochs = 4, batch_size = NULL, learning_rate_multiplier = NULL, prompt_loss_weight = 0.1, compute_classification_metrics = FALSE, classification_n_classes = NULL, classification_positive_class = NULL, classification_betas = NULL, suffix = NULL, openai_api_key = Sys.getenv("OPENAI_API_KEY"), openai_organization = NULL )
create_fine_tune( training_file, validation_file = NULL, model, n_epochs = 4, batch_size = NULL, learning_rate_multiplier = NULL, prompt_loss_weight = 0.1, compute_classification_metrics = FALSE, classification_n_classes = NULL, classification_positive_class = NULL, classification_betas = NULL, suffix = NULL, openai_api_key = Sys.getenv("OPENAI_API_KEY"), openai_organization = NULL )
training_file |
required; a length one character vector. |
validation_file |
optional; defaults to |
model |
required; a length one character vector. |
n_epochs |
required; defaults to |
batch_size |
optional; defaults to |
learning_rate_multiplier |
optional; defaults to |
prompt_loss_weight |
required; defaults to |
compute_classification_metrics |
required; defaults to |
classification_n_classes |
optional; defaults to |
classification_positive_class |
optional; defaults to |
classification_betas |
optional; defaults to |
suffix |
optional; defaults to |
openai_api_key |
required; defaults to |
openai_organization |
optional; defaults to |
For arguments description please refer to the official documentation.
Returns a list, elements of which contain information about the fine-tune.
Other fine-tune functions:
cancel_fine_tune()
,
delete_fine_tune_model()
,
list_fine_tune_events()
,
list_fine_tunes()
,
retrieve_fine_tune()
## Not run: training_file <- system.file( "extdata", "sport_prepared_train.jsonl", package = "openai" ) validation_file <- system.file( "extdata", "sport_prepared_train.jsonl", package = "openai" ) training_info <- upload_file(training_file, "fine-tune") validation_info <- upload_file(validation_file, "fine-tune") info <- create_fine_tune( training_file = training_info$id, validation_file = validation_info$id, model = "ada", compute_classification_metrics = TRUE, classification_positive_class = " baseball" # Mind space in front ) ## End(Not run)
## Not run: training_file <- system.file( "extdata", "sport_prepared_train.jsonl", package = "openai" ) validation_file <- system.file( "extdata", "sport_prepared_train.jsonl", package = "openai" ) training_info <- upload_file(training_file, "fine-tune") validation_info <- upload_file(validation_file, "fine-tune") info <- create_fine_tune( training_file = training_info$id, validation_file = validation_info$id, model = "ada", compute_classification_metrics = TRUE, classification_positive_class = " baseball" # Mind space in front ) ## End(Not run)
Creates an image given a prompt. See this page for details.
create_image( prompt, n = 1, size = c("1024x1024", "256x256", "512x512"), response_format = c("url", "b64_json"), user = NULL, openai_api_key = Sys.getenv("OPENAI_API_KEY"), openai_organization = NULL )
create_image( prompt, n = 1, size = c("1024x1024", "256x256", "512x512"), response_format = c("url", "b64_json"), user = NULL, openai_api_key = Sys.getenv("OPENAI_API_KEY"), openai_organization = NULL )
prompt |
required; a length one character vector. |
n |
required; defaults to |
size |
required; defaults to |
response_format |
required; defaults to |
user |
optional; defaults to |
openai_api_key |
required; defaults to |
openai_organization |
optional; defaults to |
For arguments description please refer to the official documentation.
Returns a list, an element of which contain either a link to the generated image or the generated image decoded in Base64.
Other image functions:
create_image_edit()
,
create_image_variation()
## Not run: create_image("An astronaut riding a horse in a photorealistic style") ## End(Not run)
## Not run: create_image("An astronaut riding a horse in a photorealistic style") ## End(Not run)
Creates an edited or extended image given an original image and a prompt. See this page for details.
create_image_edit( image, mask, prompt, n = 1, size = c("1024x1024", "256x256", "512x512"), response_format = c("url", "b64_json"), user = NULL, openai_api_key = Sys.getenv("OPENAI_API_KEY"), openai_organization = NULL )
create_image_edit( image, mask, prompt, n = 1, size = c("1024x1024", "256x256", "512x512"), response_format = c("url", "b64_json"), user = NULL, openai_api_key = Sys.getenv("OPENAI_API_KEY"), openai_organization = NULL )
image |
required; a length one character vector. |
mask |
required; a length one character vector. |
prompt |
required; a length one character vector. |
n |
required; defaults to |
size |
required; defaults to |
response_format |
required; defaults to |
user |
optional; defaults to |
openai_api_key |
required; defaults to |
openai_organization |
optional; defaults to |
For arguments description please refer to the official documentation.
Returns a list, an element of which contain either a link to the edited image or the edited image decoded in Base64.
Other image functions:
create_image_variation()
,
create_image()
## Not run: image <- system.file("extdata", "astronaut.png", package = "openai") mask <- system.file("extdata", "mask.png", package = "openai") create_image_edit( image = image, mask = mask, prompt = "goat", n = 1, response_format = "url" ) ## End(Not run)
## Not run: image <- system.file("extdata", "astronaut.png", package = "openai") mask <- system.file("extdata", "mask.png", package = "openai") create_image_edit( image = image, mask = mask, prompt = "goat", n = 1, response_format = "url" ) ## End(Not run)
Creates a variation of a given image. See this page for details.
create_image_variation( image, n = 1, size = c("1024x1024", "256x256", "512x512"), response_format = c("url", "b64_json"), user = NULL, openai_api_key = Sys.getenv("OPENAI_API_KEY"), openai_organization = NULL )
create_image_variation( image, n = 1, size = c("1024x1024", "256x256", "512x512"), response_format = c("url", "b64_json"), user = NULL, openai_api_key = Sys.getenv("OPENAI_API_KEY"), openai_organization = NULL )
image |
required; a length one character vector. |
n |
required; defaults to |
size |
required; defaults to |
response_format |
required; defaults to |
user |
optional; defaults to |
openai_api_key |
required; defaults to |
openai_organization |
optional; defaults to |
For arguments description please refer to the official documentation.
Returns a list, an element of which contain either a link to the image variation or the image variation decoded in Base64.
Other image functions:
create_image_edit()
,
create_image()
## Not run: image <- system.file("extdata", "astronaut.png", package = "openai") create_image_variation( image = image, n = 1, size = "256x256", response_format = "url" ) ## End(Not run)
## Not run: image <- system.file("extdata", "astronaut.png", package = "openai") create_image_variation( image = image, n = 1, size = "256x256", response_format = "url" ) ## End(Not run)
Classifies if text violates OpenAI's Content Policy. See this page for details.
create_moderation( input, model, openai_api_key = Sys.getenv("OPENAI_API_KEY"), openai_organization = NULL )
create_moderation( input, model, openai_api_key = Sys.getenv("OPENAI_API_KEY"), openai_organization = NULL )
input |
required; an arbitrary length character vector. |
model |
required; a length one character vector. |
openai_api_key |
required; defaults to |
openai_organization |
optional; defaults to |
For arguments description please refer to the official documentation.
Returns a list, elements of which contain information about the model.
## Not run: create_moderation( input = "I want to kill them all.", model = "text-moderation-stable" ) ## End(Not run)
## Not run: create_moderation( input = "I want to kill them all.", model = "text-moderation-stable" ) ## End(Not run)
Transcribes audio into the input language. See this page for details.
create_transcription( file, model, prompt = NULL, response_format = "json", temperature = 0, language = NULL, openai_api_key = Sys.getenv("OPENAI_API_KEY"), openai_organization = NULL )
create_transcription( file, model, prompt = NULL, response_format = "json", temperature = 0, language = NULL, openai_api_key = Sys.getenv("OPENAI_API_KEY"), openai_organization = NULL )
file |
required; a length one character vector. |
model |
required; a length one character vector. |
prompt |
optional; defaults to |
response_format |
required; defaults to |
temperature |
required; defaults to |
language |
optional; defaults to |
openai_api_key |
required; defaults to |
openai_organization |
optional; defaults to |
For arguments description please refer to the official documentation.
Returns a list, elements of which contain a transcription and supplementary information.
Other audio functions:
create_translation()
## Not run: voice_sample_en <- system.file( "extdata", "sample-en.m4a", package = "openai" ) create_transcription(file = voice_sample_en, model = "whisper-1") ## End(Not run)
## Not run: voice_sample_en <- system.file( "extdata", "sample-en.m4a", package = "openai" ) create_transcription(file = voice_sample_en, model = "whisper-1") ## End(Not run)
Translates audio into into English. See this page for details.
create_translation( file, model, prompt = NULL, response_format = "json", temperature = 0, openai_api_key = Sys.getenv("OPENAI_API_KEY"), openai_organization = NULL )
create_translation( file, model, prompt = NULL, response_format = "json", temperature = 0, openai_api_key = Sys.getenv("OPENAI_API_KEY"), openai_organization = NULL )
file |
required; a length one character vector. |
model |
required; a length one character vector. |
prompt |
optional; defaults to |
response_format |
required; defaults to |
temperature |
required; defaults to |
openai_api_key |
required; defaults to |
openai_organization |
optional; defaults to |
For arguments description please refer to the official documentation.
Returns a list, elements of which contain a transcription and supplementary information.
Other audio functions:
create_transcription()
## Not run: voice_sample_ua <- system.file( "extdata", "sample-ua.m4a", package = "openai" ) create_translation(file = voice_sample_ua, model = "whisper-1") ## End(Not run)
## Not run: voice_sample_ua <- system.file( "extdata", "sample-ua.m4a", package = "openai" ) create_translation(file = voice_sample_ua, model = "whisper-1") ## End(Not run)
Deletes a file. See this page for details.
delete_file( file_id, openai_api_key = Sys.getenv("OPENAI_API_KEY"), openai_organization = NULL )
delete_file( file_id, openai_api_key = Sys.getenv("OPENAI_API_KEY"), openai_organization = NULL )
file_id |
required; a length one character vector. |
openai_api_key |
required; defaults to |
openai_organization |
optional; defaults to |
For arguments description please refer to the official documentation.
Returns a list, elements of which contains ID of the deleted file and status whether the file is deleted.
Other file functions:
list_files()
,
retrieve_file_content()
,
retrieve_file()
,
upload_file()
## Not run: file <- system.file("extdata", "classification-file.jsonl", package = "openai") file_info <- upload_file(file = file, purpose = "classification") delete_file(file_info$id) ## End(Not run)
## Not run: file <- system.file("extdata", "classification-file.jsonl", package = "openai") file_info <- upload_file(file = file, purpose = "classification") delete_file(file_info$id) ## End(Not run)
Deletes a fine-tuned model. See this page for details.
delete_fine_tune_model( model, openai_api_key = Sys.getenv("OPENAI_API_KEY"), openai_organization = NULL )
delete_fine_tune_model( model, openai_api_key = Sys.getenv("OPENAI_API_KEY"), openai_organization = NULL )
model |
required; a length one character vector. |
openai_api_key |
required; defaults to |
openai_organization |
optional; defaults to |
For arguments description please refer to the official documentation.
Returns a list, elements of which contains information about the deleted model.
Other fine-tune functions:
cancel_fine_tune()
,
create_fine_tune()
,
list_fine_tune_events()
,
list_fine_tunes()
,
retrieve_fine_tune()
## Not run: fine_tunes <- list_fine_tunes() fine_tunes <- fine_tunes$data id <- fine_tunes[!is.na(fine_tunes[, "fine_tuned_model"]), "fine_tuned_model"] delete_fine_tune_model(model = id[1]) ## End(Not run)
## Not run: fine_tunes <- list_fine_tunes() fine_tunes <- fine_tunes$data id <- fine_tunes[!is.na(fine_tunes[, "fine_tuned_model"]), "fine_tuned_model"] delete_fine_tune_model(model = id[1]) ## End(Not run)
Lists files uploaded by user's organization. See this page for details.
list_files( openai_api_key = Sys.getenv("OPENAI_API_KEY"), openai_organization = NULL )
list_files( openai_api_key = Sys.getenv("OPENAI_API_KEY"), openai_organization = NULL )
openai_api_key |
required; defaults to |
openai_organization |
optional; defaults to |
For arguments description please refer to the official documentation.
Returns a list, an element of which is a data frame containing information about files.
Other file functions:
delete_file()
,
retrieve_file_content()
,
retrieve_file()
,
upload_file()
## Not run: list_files() ## End(Not run)
## Not run: list_files() ## End(Not run)
Returns events related to a specified fine-tune job. See this page for details.
list_fine_tune_events( fine_tune_id, stream = FALSE, openai_api_key = Sys.getenv("OPENAI_API_KEY"), openai_organization = NULL )
list_fine_tune_events( fine_tune_id, stream = FALSE, openai_api_key = Sys.getenv("OPENAI_API_KEY"), openai_organization = NULL )
fine_tune_id |
required; a length one character vector. |
stream |
required; defaults to |
openai_api_key |
required; defaults to |
openai_organization |
optional; defaults to |
For arguments description please refer to the official documentation.
Returns a list, elements of which contains information about the fine-tune events.
Other fine-tune functions:
cancel_fine_tune()
,
create_fine_tune()
,
delete_fine_tune_model()
,
list_fine_tunes()
,
retrieve_fine_tune()
## Not run: training_file <- system.file( "extdata", "sport_prepared_train.jsonl", package = "openai" ) validation_file <- system.file( "extdata", "sport_prepared_train.jsonl", package = "openai" ) training_info <- upload_file(training_file, "fine-tune") validation_info <- upload_file(validation_file, "fine-tune") info <- create_fine_tune( training_file = training_info$id, validation_file = validation_info$id, model = "ada", compute_classification_metrics = TRUE, classification_positive_class = " baseball" # Mind space in front ) id <- ifelse( length(info$data$id) > 1, info$data$id[length(info$data$id)], info$data$id ) list_fine_tune_events(fine_tune_id = id) ## End(Not run)
## Not run: training_file <- system.file( "extdata", "sport_prepared_train.jsonl", package = "openai" ) validation_file <- system.file( "extdata", "sport_prepared_train.jsonl", package = "openai" ) training_info <- upload_file(training_file, "fine-tune") validation_info <- upload_file(validation_file, "fine-tune") info <- create_fine_tune( training_file = training_info$id, validation_file = validation_info$id, model = "ada", compute_classification_metrics = TRUE, classification_positive_class = " baseball" # Mind space in front ) id <- ifelse( length(info$data$id) > 1, info$data$id[length(info$data$id)], info$data$id ) list_fine_tune_events(fine_tune_id = id) ## End(Not run)
Lists organization's fine-tuning jobs. See this page for details.
list_fine_tunes( openai_api_key = Sys.getenv("OPENAI_API_KEY"), openai_organization = NULL )
list_fine_tunes( openai_api_key = Sys.getenv("OPENAI_API_KEY"), openai_organization = NULL )
openai_api_key |
required; defaults to |
openai_organization |
optional; defaults to |
For arguments description please refer to the official documentation.
Returns a list, an element of which is a data frame containing information about fine-tunes.
Other fine-tune functions:
cancel_fine_tune()
,
create_fine_tune()
,
delete_fine_tune_model()
,
list_fine_tune_events()
,
retrieve_fine_tune()
## Not run: list_fine_tunes() ## End(Not run)
## Not run: list_fine_tunes() ## End(Not run)
Lists the currently available models, and provides basic information about each one such as the owner and availability. See this page for details.
list_models( openai_api_key = Sys.getenv("OPENAI_API_KEY"), openai_organization = NULL )
list_models( openai_api_key = Sys.getenv("OPENAI_API_KEY"), openai_organization = NULL )
openai_api_key |
required; defaults to |
openai_organization |
optional; defaults to |
For arguments description please refer to the official documentation.
Returns a list, an element of which is a data frame containing information about models.
Other model functions:
retrieve_model()
## Not run: list_models() ## End(Not run)
## Not run: list_models() ## End(Not run)
Provides information about a specific file. See this page for details.
retrieve_file( file_id, openai_api_key = Sys.getenv("OPENAI_API_KEY"), openai_organization = NULL )
retrieve_file( file_id, openai_api_key = Sys.getenv("OPENAI_API_KEY"), openai_organization = NULL )
file_id |
required; a length one character vector. |
openai_api_key |
required; defaults to |
openai_organization |
optional; defaults to |
For arguments description please refer to the official documentation.
Returns a list, elements of which contains information about the file.
Other file functions:
delete_file()
,
list_files()
,
retrieve_file_content()
,
upload_file()
## Not run: file <- system.file("extdata", "classification-file.jsonl", package = "openai") file_info <- upload_file(file = file, purpose = "classification") retrieve_file(file_info$id) ## End(Not run)
## Not run: file <- system.file("extdata", "classification-file.jsonl", package = "openai") file_info <- upload_file(file = file, purpose = "classification") retrieve_file(file_info$id) ## End(Not run)
Returns the content of the specified file. See this page for details. Please note that only output files are allowed to be downloaded, not the input ones.
retrieve_file_content( file_id, openai_api_key = Sys.getenv("OPENAI_API_KEY"), openai_organization = NULL )
retrieve_file_content( file_id, openai_api_key = Sys.getenv("OPENAI_API_KEY"), openai_organization = NULL )
file_id |
required; a length one character vector. |
openai_api_key |
required; defaults to |
openai_organization |
optional; defaults to |
For arguments description please refer to the official documentation.
Returns a list, an element of which contains the content of the file.
Other file functions:
delete_file()
,
list_files()
,
retrieve_file()
,
upload_file()
Returns information about the specified fine-tune job. See this page for details.
retrieve_fine_tune( fine_tune_id, openai_api_key = Sys.getenv("OPENAI_API_KEY"), openai_organization = NULL )
retrieve_fine_tune( fine_tune_id, openai_api_key = Sys.getenv("OPENAI_API_KEY"), openai_organization = NULL )
fine_tune_id |
required; a length one character vector. |
openai_api_key |
required; defaults to |
openai_organization |
optional; defaults to |
For arguments description please refer to the official documentation.
Returns a list, elements of which contains information about the fine-tune.
Other fine-tune functions:
cancel_fine_tune()
,
create_fine_tune()
,
delete_fine_tune_model()
,
list_fine_tune_events()
,
list_fine_tunes()
## Not run: training_file <- system.file( "extdata", "sport_prepared_train.jsonl", package = "openai" ) validation_file <- system.file( "extdata", "sport_prepared_train.jsonl", package = "openai" ) training_info <- upload_file(training_file, "fine-tune") validation_info <- upload_file(validation_file, "fine-tune") info <- create_fine_tune( training_file = training_info$id, validation_file = validation_info$id, model = "ada", compute_classification_metrics = TRUE, classification_positive_class = " baseball" # Mind space in front ) id <- ifelse( length(info$data$id) > 1, info$data$id[length(info$data$id)], info$data$id ) retrieve_fine_tune(fine_tune_id = id) ## End(Not run)
## Not run: training_file <- system.file( "extdata", "sport_prepared_train.jsonl", package = "openai" ) validation_file <- system.file( "extdata", "sport_prepared_train.jsonl", package = "openai" ) training_info <- upload_file(training_file, "fine-tune") validation_info <- upload_file(validation_file, "fine-tune") info <- create_fine_tune( training_file = training_info$id, validation_file = validation_info$id, model = "ada", compute_classification_metrics = TRUE, classification_positive_class = " baseball" # Mind space in front ) id <- ifelse( length(info$data$id) > 1, info$data$id[length(info$data$id)], info$data$id ) retrieve_fine_tune(fine_tune_id = id) ## End(Not run)
Retrieves a model instance, providing basic information about the model such as the owner and permissioning. See this page for details.
retrieve_model( model, openai_api_key = Sys.getenv("OPENAI_API_KEY"), openai_organization = NULL )
retrieve_model( model, openai_api_key = Sys.getenv("OPENAI_API_KEY"), openai_organization = NULL )
model |
required; a length one character vector. |
openai_api_key |
required; defaults to |
openai_organization |
optional; defaults to |
For arguments description please refer to the official documentation.
Returns a list, elements of which contain information about the model.
Other model functions:
list_models()
## Not run: retrieve_model("text-davinci-002") ## End(Not run)
## Not run: retrieve_model("text-davinci-002") ## End(Not run)
Uploads a file that will be used for various purposes. The size of the storage is limited to 1 Gb. See this page for details.
upload_file( file, purpose = c("search", "answers", "classifications", "fine-tune"), openai_api_key = Sys.getenv("OPENAI_API_KEY"), openai_organization = NULL )
upload_file( file, purpose = c("search", "answers", "classifications", "fine-tune"), openai_api_key = Sys.getenv("OPENAI_API_KEY"), openai_organization = NULL )
file |
required; a length one character vector. |
purpose |
required; defaults to |
openai_api_key |
required; defaults to |
openai_organization |
optional; defaults to |
For arguments description please refer to the official documentation.
Returns a list, elements of which contains ID of the uploaded file and other supplementary information.
Other file functions:
delete_file()
,
list_files()
,
retrieve_file_content()
,
retrieve_file()
## Not run: file <- system.file("extdata", "classification-file.jsonl", package = "openai") upload_file(file = file, purpose = "classification") ## End(Not run)
## Not run: file <- system.file("extdata", "classification-file.jsonl", package = "openai") upload_file(file = file, purpose = "classification") ## End(Not run)