View Source ExOpenAi.Completion (ex_open_ai v0.1.8)

Represents a completion request to the OpenAI API.

examples

Examples

iex> params = %{
...>   model: "text-model",
...>   prompt: "tell me a joke",
...>   max_tokens: 500
...> }
iex> ExOpenAi.Completion.create(params)
{:ok, %ExOpenAi.Completion{...}}

iex> ExOpenAi.Completion.create(%{})
{:error, %{}}

Link to this section Summary

Link to this section Types

@type t() :: %ExOpenAi.Completion{
  choices: list(),
  created: integer(),
  id: String.t(),
  model: String.t(),
  object: String.t(),
  usage: map()
}

Link to this section Functions

Link to this function

create(data, options \\ [])

View Source
Link to this function

create_stream(data, options \\ [])

View Source
@spec create_stream(ExOpenAi.Api.data(), list()) :: ExOpenAi.Parser.parsed_response()
@spec do_new(
  %ExOpenAi.Completion{
    choices: term(),
    created: term(),
    id: term(),
    model: term(),
    object: term(),
    usage: term()
  },
  attributes :: list()
) :: %ExOpenAi.Completion{
  choices: term(),
  created: term(),
  id: term(),
  model: term(),
  object: term(),
  usage: term()
}
Link to this function

keep_it_simple(response, arg2)

View Source
@spec new() :: %ExOpenAi.Completion{
  choices: term(),
  created: term(),
  id: term(),
  model: term(),
  object: term(),
  usage: term()
}
@spec new(attributes :: list()) :: %ExOpenAi.Completion{
  choices: term(),
  created: term(),
  id: term(),
  model: term(),
  object: term(),
  usage: term()
}