View source: R/completions4R.R
completions4R | R Documentation |
This function sends a request to the OpenAI completions API (Legacy) to generate text based on the provided prompt and parameters.
completions4R(
prompt,
api_key = Sys.getenv("OPENAI_API_KEY"),
Model = "davinci-002",
max_tokens = 50,
temperature = 1,
simple = TRUE
)
prompt |
A string. The initial text that the model responds to. |
api_key |
A string. The API key for OpenAI. Defaults to the value of the environment variable "OPENAI_API_KEY". |
Model |
A string. The model ID to use, such as "davinci-002". |
max_tokens |
Integer. The maximum number of tokens to generate. |
temperature |
A numeric value to control the randomness of the generated text. A value close to 0 produces more deterministic output, while a higher value (up to 2) produces more random output. |
simple |
If TRUE, returns the generated text without newline characters. If FALSE, returns the full response from the API. |
The generated text or the full response from the API, depending on the value of 'simple'.
Satoshi Kume
## Not run:
#This is a legacy function
Sys.setenv(OPENAI_API_KEY = "Your API key")
prompt <- "Translate the following English text to French: 'Hello, world!'"
completions4R(prompt)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.