Class: OpenAI::Models::Chat::ChatCompletionChunk

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

Defined Under Namespace

Modules: ServiceTier Classes: Choice, Moderation

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Internal::Type::BaseModel

==, #==, #[], coerce, #deconstruct_keys, #deep_to_h, dump, 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, #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(code:, message:, type: :error) ⇒ Object

An error produced while attempting moderation.

Parameters:

  • code (String)

    The error code.

  • message (String)

    The error message.

  • type (Symbol, :error) (defaults to: :error)

    The object type, which is always error.



# File 'lib/openai/models/chat/chat_completion_chunk.rb', line 373

Instance Attribute Details

#choicesArray<OpenAI::Models::Chat::ChatCompletionChunk::Choice>

A list of chat completion choices. Can contain more than one elements if n is greater than 1. Can also be empty for the last chunk if you set stream_options: {"include_usage": true}.

Parameters:

  • value (::Array[OpenAI::Chat::ChatCompletionChunk::Choice])

Returns:



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

required :choices, -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Chat::ChatCompletionChunk::Choice] }

#createdInteger

The Unix timestamp (in seconds) of when the chat completion was created. Each chunk has the same timestamp.

Parameters:

  • value (Integer)

Returns:

  • (Integer)


26
# File 'lib/openai/models/chat/chat_completion_chunk.rb', line 26

required :created, Integer

#idString

A unique identifier for the chat completion. Each chunk has the same ID.

Parameters:

  • value (String)

Returns:

  • (String)


11
# File 'lib/openai/models/chat/chat_completion_chunk.rb', line 11

required :id, String

#modelString

The model to generate the completion.

Parameters:

  • value (String)

Returns:

  • (String)


32
# File 'lib/openai/models/chat/chat_completion_chunk.rb', line 32

required :model, String

#moderationOpenAI::Models::Chat::ChatCompletionChunk::Moderation?

Moderation results for the request input and generated output. Present on the moderation chunk when moderated completions are requested.

Parameters:

  • value (OpenAI::Chat::ChatCompletionChunk::Moderation, nil)

Returns:



45
# File 'lib/openai/models/chat/chat_completion_chunk.rb', line 45

optional :moderation, -> { OpenAI::Chat::ChatCompletionChunk::Moderation }, nil?: true

#objectSymbol, :"chat.completion.chunk"

The object type, which is always chat.completion.chunk.

Parameters:

  • value (:"chat.completion.chunk")

Returns:

  • (Symbol, :"chat.completion.chunk")


38
# File 'lib/openai/models/chat/chat_completion_chunk.rb', line 38

required :object, const: :"chat.completion.chunk"

#service_tierSymbol, ...

Specifies the processing type used for serving the request.

  • If set to 'auto', then the request will be processed with the service tier configured in the Project settings. Unless otherwise configured, the Project will use 'default'.
  • If set to 'default', then the request will be processed with the standard pricing and performance for the selected model.
  • If set to 'flex' or 'priority', then the request will be processed with the corresponding service tier.
  • When not set, the default behavior is 'auto'.

When the service_tier parameter is set, the response body will include the service_tier value based on the processing mode actually used to serve the request. This response value may be different from the value set in the parameter.

Parameters:

  • value (OpenAI::Models::Chat::ChatCompletionChunk::service_tier, nil)

Returns:



66
# File 'lib/openai/models/chat/chat_completion_chunk.rb', line 66

optional :service_tier, enum: -> { OpenAI::Chat::ChatCompletionChunk::ServiceTier }, nil?: true

#system_fingerprintString?

Deprecated.

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.

Parameters:

  • (String)

Returns:

  • (String, nil)


76
# File 'lib/openai/models/chat/chat_completion_chunk.rb', line 76

optional :system_fingerprint, String

#usageOpenAI::Models::CompletionUsage?

An optional field that will only be present when you set stream_options: {"include_usage": true} in your request. When present, it contains a null value except for the last chunk which contains the token usage statistics for the entire request.

NOTE: If the stream is interrupted or cancelled, you may not receive the final usage chunk which contains the total token usage for the request.

Parameters:

Returns:



88
# File 'lib/openai/models/chat/chat_completion_chunk.rb', line 88

optional :usage, -> { OpenAI::CompletionUsage }, nil?: true

Instance Method Details

#to_hash{

Returns:

  • ({)


52
# File 'sig/openai/models/chat/chat_completion_chunk.rbs', line 52

def to_hash: -> {