Learn R Programming

openai (version 0.2.0)

create_search: Create search

Description

[Deprecated]

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

Computes similarity scores between the query and provided documents. See this page for details.

Usage

create_search(
  engine_id = c("ada", "babbage", "curie", "davinci"),
  query,
  documents = NULL,
  file = NULL,
  max_rerank = 200,
  return_metadata = FALSE,
  user = NULL,
  openai_api_key = Sys.getenv("OPENAI_API_KEY"),
  openai_organization = NULL
)

Value

Returns a list, elements of which contain score of each document and supplementary information.

Arguments

engine_id

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

query

required; length one character vector.

documents

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

file

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

max_rerank

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

return_metadata

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

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_search(
    documents = c("White House", "hospital", "school"),
    query = "the president"
)
}

Run the code above in your browser using DataLab