View Source OpenAI.Completions (OpenAI API Wrapper v0.1.0)

Provides the ability to interact with the OpenAI completions API.

See the OpenAI Completions API documentation here.

Link to this section Summary

Types

The parameters allowed for create/3.

Functions

Create a completion given a prompt(s) and parameters.

Link to this section Types

@type create_params() ::
  {:suffix, binary()}
  | {:max_tokens, integer()}
  | {:temperature, number()}
  | {:top_p, number()}
  | {:n, integer()}
  | {:logprobs, integer()}
  | {:echo, boolean()}
  | {:stop, binary() | [binary()]}
  | {:presence_penalty, number()}
  | {:frequency_penalty, number()}
  | {:best_of, integer()}
  | {:logit_bias, map()}
  | {:user, binary()}

The parameters allowed for create/3.

We make no effort to assign defaults, and so if params are left blank they will be set to whatever the OpenAI API defaults are by the server. Consult with the OpenAI documentation for more details.

The parameters are mapped 1:1 with those that OpenAI (except for streaming) offers and so we do not explain them in detail here.

Note: The :stream param is not currently supported.

Link to this section Functions

Link to this function

create(model, prompt, params \\ [])

View Source
@spec create(binary(), binary() | [binary()], [create_params()]) ::
  {:ok, map()} | {:error, OpenAI.Error.t()}

Create a completion given a prompt(s) and parameters.

args

Args

  • model - The OpenAI model to use to create the completion.
  • prompt - The prompt to create a completion for.
  • params - Keyword list of params. See create_params/0.