Learn R Programming

openai (version 0.2.0)

create_answer: Create answer

Description

[Deprecated]

Note: This endpoint is deprecated and will be removed on December 3, 2022. Please see Answers Transition Guide for details.

Answers the specified question based on the documents and examples. See this page for details.

Usage

create_answer(
  model = c("ada", "babbage", "curie", "davinci"),
  question,
  examples,
  examples_context,
  documents = NULL,
  file = NULL,
  search_model = c("ada", "babbage", "curie", "davinci"),
  max_rerank = 200,
  temperature = 0,
  logprobs = NULL,
  max_tokens = 16,
  stop = NULL,
  n = 1,
  logit_bias = NULL,
  return_metadata = FALSE,
  return_prompt = FALSE,
  expand = NULL,
  user = NULL,
  openai_api_key = Sys.getenv("OPENAI_API_KEY"),
  openai_organization = NULL
)

Value

Returns a list, elements of which contain an answer and other supplementary information.

Arguments

model

required; defaults to "ada"; a length one character vector, one among "ada", "babbage", "curie", and "davinci".

question

required; a length one character vector.

examples

required; a list.

examples_context

required; a length one character vector.

documents

optional; defaults to NULL; an arbitrary length character vector.

file

optional; defaults to NULL; a length one character vector.

search_model

required; defaults to ada; a length one character vector, one among "ada", "babbage", "curie", and "davinci".

max_rerank

required; defaults to 200; a length one numeric vector with the integer value greater than 0.

temperature

required; defaults to 0; a length one numeric vector with the value between 0 and 2.

logprobs

optional; defaults to NULL; a length one numeric vector with the integer value between 0 and 5.

max_tokens

required; defaults to 16; a length one numeric vector with the integer value greater than 0.

stop

optional; defaults to NULL; a character vector of length between one and four.

n

required; defaults to 1; a length one numeric vector with the integer value greater than 0.

logit_bias

optional; defaults to NULL; a named list.

return_metadata

required; defaults to FALSE; a length one logical vector.

return_prompt

required; defaults to FALSE; a length one logical vector.

expand

optional; defaults to NULL; a list elements of which are among completion and file.

user

optional; defaults to NULL; a length one character vector.

openai_api_key

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.

openai_organization

optional; defaults to NULL; a length one character vector. Specifies OpenAI organization.

Details

For arguments description please refer to the official documentation.

Examples

Run this code
if (FALSE) {
create_answer(
    search_model = "ada",
    model = "curie",
    question = "How many red apples do I have?",
    documents = c("I have five green apples.", "I love oranges."),
    examples_context = "Jack has three brothers and one sister. His sister is sad",
    examples = list(
        c("How many siblings has Jack?", "Three"),
        c("Who is sad?", "Jack's sister is.")
    ),
    max_tokens = 5,
    stop = c("\n", "<|endoftext|>"),
)
}

Run the code above in your browser using DataLab