completions_api {askgpt}R Documentation

Request answer from openai's completions API

Description

Mostly used under the hood for askgpt.

Usage

completions_api(
  prompt,
  model = NULL,
  temperature = NULL,
  max_tokens = NULL,
  api_key = NULL,
  ...
)

Arguments

prompt

character string of the prompt to be completed.

model

character string of the model to be used (defaults to "text-davinci-003").

temperature

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).

max_tokens

The maximum number of tokens to generate in the completion. 2048L is the maximum the models accept.

api_key

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)

Details

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:

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.

Value

a httr2 response object

Examples

## Not run: 
completions_api("The quick brown fox")

## End(Not run)

[Package askgpt version 0.1.3 Index]