Class: OpenAI::Models::CompletionChoice

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

Defined Under Namespace

Modules: FinishReason Classes: Logprobs

Instance Attribute Summary collapse

Attributes inherited from Internal::Type::BaseModel

#last_response

Class Method Summary collapse

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(finish_reason:, index:, logprobs:, text:) ⇒ CompletionChoice

Returns a new instance of CompletionChoice.

Parameters:

  • finish_reason —

    The reason the model stopped generating tokens. This will be stop if the model hit a natural stop point or a provided stop sequence, length if the maximum number of tokens specified in the request was reached, or content_filter if content was omitted due to a flag from our content filters.

  • finish_reason: (OpenAI::Models::CompletionChoice::finish_reason)
  • index: (Integer)
  • logprobs: (OpenAI::CompletionChoice::Logprobs, nil)
  • text: (String)


# File 'lib/openai/models/completion_choice.rb', line 30

Instance Attribute Details

#finish_reason ⇒ OpenAI::Models::CompletionChoice::finish_reason

The reason the model stopped generating tokens. This will be stop if the model hit a natural stop point or a provided stop sequence, length if the maximum number of tokens specified in the request was reached, or content_filter if content was omitted due to a flag from our content filters.

Returns:

  • (OpenAI::Models::CompletionChoice::finish_reason)


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

required :finish_reason, enum: -> { OpenAI::CompletionChoice::FinishReason }

#index ⇒ Integer

Parameters:

  • value (Integer)

Returns:

  • (Integer)


18
# File 'lib/openai/models/completion_choice.rb', line 18

required :index, Integer

#logprobs ⇒ OpenAI::Models::CompletionChoice::Logprobs?

Parameters:

  • value (OpenAI::CompletionChoice::Logprobs, nil)

Returns:



23
# File 'lib/openai/models/completion_choice.rb', line 23

required :logprobs, -> { OpenAI::CompletionChoice::Logprobs }, nil?: true

#text ⇒ String

Parameters:

  • value (String)

Returns:

  • (String)


28
# File 'lib/openai/models/completion_choice.rb', line 28

required :text, String

Class Method Details

.values ⇒ Array<Symbol>

Returns:

  • (Array<Symbol>)


# File 'lib/openai/models/completion_choice.rb', line 56

Instance Method Details

#to_hash ⇒ { finish_reason: OpenAI::Models::CompletionChoice::finish_reason, index: Integer, logprobs: OpenAI::CompletionChoice::Logprobs?, text: String }

Returns:

  • ({ finish_reason: OpenAI::Models::CompletionChoice::finish_reason, index: Integer, logprobs: OpenAI::CompletionChoice::Logprobs?, text: String })


36
37
38
39
40
41
# File 'sig/openai/models/completion_choice.rbs', line 36

def to_hash: -> {
  finish_reason: OpenAI::Models::CompletionChoice::finish_reason,
  index: Integer,
  logprobs: OpenAI::CompletionChoice::Logprobs?,
  text: String
}