Mostly used under the hood for askgpt
.
completions_api(
prompt,
model = NULL,
temperature = NULL,
max_tokens = NULL,
api_key = NULL,
...
)
a httr2 response object
character string of the prompt to be completed.
character string of the model to be used (defaults to "text-davinci-003").
numeric value between 0 and 1 to control the randomness of the output (defaults to 0.2; lower values like 0.2 will make answers more focused and deterministic).
The maximum number of tokens to generate in the completion. 2048L is the maximum the models accept.
set the API key. If NULL, looks for the env OPENAI_API_KEY.
additional parameters to be passed to the API (see [the API documentation](https://platform.openai.com/docs/api-reference/completions)
Only a few parameters are implemented by name. Most can be sent
through the ...
. For example, you could use the n
parameter
just like this completions_api("The quick brown fox", n = 2)
.
A couple of defaults are used by the package:
the model used by default is "text-davinci-003"
the default temperature is 0.2
the default for max_tokens is 2048L
You can configure how askgpt
makes requests by setting
options that start with askgpt_*
. For example, to use a different
model use options(askgpt_model = "text-curie-001")
. It does not
matter if the API parameter ist listed in the function or not. All are
used.
if (FALSE) {
completions_api("The quick brown fox")
}
Run the code above in your browser using DataLab