create_chat_completion {openai} | R Documentation |
Create chat completion
Description
Creates a completion for the chat message. See this page for details.
Usage
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
)
Arguments
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 |
Details
For arguments description please refer to the official documentation.
Value
Returns a list, elements of which contain chat completion(s) and supplementary information.
Examples
## 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)