Class: OpenAI::Models::Chat::ChatCompletion::Choice
- Inherits:
-
Internal::Type::BaseModel
- Object
- Internal::Type::BaseModel
- OpenAI::Models::Chat::ChatCompletion::Choice
- Defined in:
- lib/openai/models/chat/chat_completion.rb,
sig/openai/models/chat/chat_completion.rbs
Direct Known Subclasses
Defined Under Namespace
Modules: FinishReason Classes: Logprobs
Instance Attribute Summary collapse
-
#finish_reason ⇒ Symbol, OpenAI::Models::Chat::ChatCompletion::Choice::FinishReason
The reason the model stopped generating tokens.
-
#index ⇒ Integer
The index of the choice in the list of choices.
-
#logprobs ⇒ OpenAI::Models::Chat::ChatCompletion::Choice::Logprobs?
Log probability information for the choice.
-
#message ⇒ OpenAI::Models::Chat::ChatCompletionMessage
A chat completion message generated by the model.
Attributes inherited from Internal::Type::BaseModel
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_with_error, dump, #dump, #inspect, inspect, meta_info, new_coerce_state, 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:, message:) ⇒ Object
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 |
# File 'lib/openai/models/chat/chat_completion.rb', line 167 class Choice < OpenAI::Internal::Type::BaseModel # @!attribute 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, `content_filter` if # content was omitted due to a flag from our content filters, `tool_calls` if the # model called a tool, or `function_call` (deprecated) if the model called a # function. Read the [Model Spec](https://model-spec.openai.com/2025-12-18.html) # for more. # # @return [Symbol, OpenAI::Models::Chat::ChatCompletion::Choice::FinishReason] required :finish_reason, enum: -> { OpenAI::Chat::ChatCompletion::Choice::FinishReason } # @!attribute index # The index of the choice in the list of choices. # # @return [Integer] required :index, Integer # @!attribute logprobs # Log probability information for the choice. # # @return [OpenAI::Models::Chat::ChatCompletion::Choice::Logprobs, nil] required :logprobs, -> { OpenAI::Chat::ChatCompletion::Choice::Logprobs }, nil?: true # @!attribute message # A chat completion message generated by the model. # # @return [OpenAI::Models::Chat::ChatCompletionMessage] required :message, -> { OpenAI::Chat::ChatCompletionMessage } # @!method initialize(finish_reason:, index:, logprobs:, message:) # @param finish_reason [Symbol, OpenAI::Models::Chat::ChatCompletion::Choice::FinishReason] # 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, `content_filter` if # content was omitted due to a flag from our content filters, `tool_calls` if the # model called a tool, or `function_call` (deprecated) if the model called a # function. Read the [Model Spec](https://model-spec.openai.com/2025-12-18.html) # for more. # # @param index [Integer] # The index of the choice in the list of choices. # # @param logprobs [OpenAI::Models::Chat::ChatCompletion::Choice::Logprobs, nil] # Log probability information for the choice. # # @param message [OpenAI::Models::Chat::ChatCompletionMessage] # A chat completion message generated by the model. # 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, `content_filter` if # content was omitted due to a flag from our content filters, `tool_calls` if the # model called a tool, or `function_call` (deprecated) if the model called a # function. Read the [Model Spec](https://model-spec.openai.com/2025-12-18.html) # for more. # # @see OpenAI::Models::Chat::ChatCompletion::Choice#finish_reason module FinishReason extend OpenAI::Internal::Type::Enum STOP = :stop LENGTH = :length TOOL_CALLS = :tool_calls CONTENT_FILTER = :content_filter FUNCTION_CALL = :function_call # @!method self.values # @return [Array<Symbol>] end # @see OpenAI::Models::Chat::ChatCompletion::Choice#logprobs class Logprobs < OpenAI::Internal::Type::BaseModel # @!attribute content # A list of message content tokens with log probability information. # # @return [Array<OpenAI::Models::Chat::ChatCompletionTokenLogprob>, nil] required( :content, -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Chat::ChatCompletionTokenLogprob] }, nil?: true ) # @!attribute refusal # A list of message refusal tokens with log probability information. # # @return [Array<OpenAI::Models::Chat::ChatCompletionTokenLogprob>, nil] required( :refusal, -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Chat::ChatCompletionTokenLogprob] }, nil?: true ) # @!method initialize(content:, refusal:) # Log probability information for the choice. # # @param content [Array<OpenAI::Models::Chat::ChatCompletionTokenLogprob>, nil] # A list of message content tokens with log probability information. # # @param refusal [Array<OpenAI::Models::Chat::ChatCompletionTokenLogprob>, nil] # A list of message refusal tokens with log probability information. end end |
Instance Attribute Details
#finish_reason ⇒ Symbol, OpenAI::Models::Chat::ChatCompletion::Choice::FinishReason
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, content_filter if
content was omitted due to a flag from our content filters, tool_calls if the
model called a tool, or function_call (deprecated) if the model called a
function. Read the Model Spec
for more.
178 |
# File 'lib/openai/models/chat/chat_completion.rb', line 178 required :finish_reason, enum: -> { OpenAI::Chat::ChatCompletion::Choice::FinishReason } |
#index ⇒ Integer
The index of the choice in the list of choices.
184 |
# File 'lib/openai/models/chat/chat_completion.rb', line 184 required :index, Integer |
#logprobs ⇒ OpenAI::Models::Chat::ChatCompletion::Choice::Logprobs?
Log probability information for the choice.
190 |
# File 'lib/openai/models/chat/chat_completion.rb', line 190 required :logprobs, -> { OpenAI::Chat::ChatCompletion::Choice::Logprobs }, nil?: true |
#message ⇒ OpenAI::Models::Chat::ChatCompletionMessage
A chat completion message generated by the model.
196 |
# File 'lib/openai/models/chat/chat_completion.rb', line 196 required :message, -> { OpenAI::Chat::ChatCompletionMessage } |
Class Method Details
.values ⇒ Array<Symbol>
|
|
# File 'lib/openai/models/chat/chat_completion.rb', line 235
|
Instance Method Details
#to_hash ⇒ {
95 |
# File 'sig/openai/models/chat/chat_completion.rbs', line 95
def to_hash: -> {
|