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
)required; a length one character vector.
required; defaults to NULL; a list in the following
format: list(list("role" = "user", "content" = "Hey! How old are you?")
required; defaults to 1; a length one numeric vector
with the value between 0 and 2.
required; defaults to 1; a length one numeric vector with the
value between 0 and 1.
required; defaults to 1; a length one numeric vector with the
integer value greater than 0.
required; defaults to FALSE; a length one logical vector.
Currently is not implemented.
optional; defaults to NULL; a character vector of length
between one and four.
required; defaults to (4096 - prompt tokens); a length
one numeric vector with the integer value greater than 0.
required; defaults to 0; a length one numeric
vector with a value between -2 and 2.
required; defaults to 0; a length one numeric
vector with a value between -2 and 2.
optional; defaults to NULL; a named list.
optional; defaults to NULL; a length one character vector.
required; defaults to Sys.getenv("OPENAI_API_KEY")
(i.e., the value is retrieved from the .Renviron file); a length one
character vector. Specifies OpenAI API key.
optional; defaults to NULL; a length one
character vector. Specifies OpenAI organization.
Returns a list, elements of which contain chat completion(s) and supplementary information.
For arguments description please refer to the official documentation.
if (FALSE) { # \dontrun{
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?"
)
)
)
} # }