Class: OpenAI::Models::Completion

Inherits:
Internal::Type::BaseModel show all
Defined in:
lib/openai/models/completion.rb,
sig/openai/models/completion.rbs

Overview

See Also:

  • OpenAI::Resources::Completions#create
  • OpenAI::Resources::Completions#create_streaming

Instance Attribute Summary collapse

Attributes inherited from Internal::Type::BaseModel

#last_response

Instance Method Summary collapse

Methods inherited from Internal::Type::BaseModel

==, #==, #[], #_request_id, #_set_last_response, coerce, #deconstruct_keys, #deep_to_h, dump, #encode_with, fields, hash, #hash, inherited, #inspect, inspect, known_fields, optional, recursively_to_h, required, #to_h, #to_json, #to_s, to_sorbet_type, #to_yaml

Methods included from Internal::Type::Converter

#coerce, coerce, coerce_cached, coerce_with_error, #dump, dump, #inspect, inspect, meta_info, new_coerce_state, resolve_type, type_info

Methods included from Internal::Util::SorbetRuntimeSupport

#const_missing, #define_sorbet_constant!, #sorbet_constant_defined?, #to_sorbet_type, to_sorbet_type

Constructor Details

#initialize(id:, choices:, created:, model:, system_fingerprint: nil, usage: nil, object: :text_completion) ⇒ Completion

Returns a new instance of Completion.

Parameters:

  • id —

    A unique identifier for the completion.

  • choices —

    The list of completion choices the model generated for the input prompt.

  • created —

    The Unix timestamp (in seconds) of when the completion was created.

  • model —

    The model used for completion.

  • system_fingerprint (defaults to: nil) —

    This fingerprint represents the backend configuration that the model runs with.

    Can be used in conjunction with the seed request parameter to understand when backend changes have been made that might impact determinism.

  • usage (defaults to: nil) —

    Usage statistics for the completion request.

  • object (defaults to: :text_completion) —

    The object type, which is always "text_completion"

  • id: (String)
  • choices: (::Array[OpenAI::CompletionChoice])
  • created: (Integer)
  • model: (String)
  • system_fingerprint: (String) (defaults to: nil)
  • usage: (OpenAI::CompletionUsage) (defaults to: nil)
  • object: (:text_completion) (defaults to: :text_completion)


# File 'lib/openai/models/completion.rb', line 54

Instance Attribute Details

#choices ⇒ ::Array[OpenAI::CompletionChoice]

The list of completion choices the model generated for the input prompt.

Returns:



19
# File 'lib/openai/models/completion.rb', line 19

required :choices, -> { OpenAI::Internal::Type::ArrayOf[OpenAI::CompletionChoice] }

#created ⇒ Integer

The Unix timestamp (in seconds) of when the completion was created.

Returns:

  • (Integer)


25
# File 'lib/openai/models/completion.rb', line 25

required :created, Integer

#id ⇒ String

A unique identifier for the completion.

Returns:

  • (String)


13
# File 'lib/openai/models/completion.rb', line 13

required :id, String

#model ⇒ String

The model used for completion.

Returns:

  • (String)


31
# File 'lib/openai/models/completion.rb', line 31

required :model, String

#object ⇒ :text_completion

The object type, which is always "text_completion"

Returns:

  • (:text_completion)


37
# File 'lib/openai/models/completion.rb', line 37

required :object, const: :text_completion

#system_fingerprint ⇒ String?

This fingerprint represents the backend configuration that the model runs with.

Can be used in conjunction with the seed request parameter to understand when backend changes have been made that might impact determinism.

Returns:

  • (String, nil)


46
# File 'lib/openai/models/completion.rb', line 46

optional :system_fingerprint, String

#usage ⇒ OpenAI::CompletionUsage?

Usage statistics for the completion request.

Returns:



52
# File 'lib/openai/models/completion.rb', line 52

optional :usage, -> { OpenAI::CompletionUsage }

Instance Method Details

#to_hash ⇒ { id: String, choices: ::Array[OpenAI::CompletionChoice], created: Integer, model: String, ?object: :text_completion, ?system_fingerprint: String, ?usage: OpenAI::CompletionUsage }

Returns:



75
76
77
78
79
80
81
82
83
# File 'sig/openai/models/completion.rbs', line 75

def to_hash: -> {
  id: String,
  choices: ::Array[OpenAI::CompletionChoice],
  created: Integer,
  model: String,
  ?object: :text_completion,
  ?system_fingerprint: String,
  ?usage: OpenAI::CompletionUsage
}