Class: OpenAI::Models::Chat::ChatCompletionMessage

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

Direct Known Subclasses

ChatCompletionStoreMessage

Defined Under Namespace

Classes: Annotation, FunctionCall

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(end_index:, start_index:, title:, url:) ⇒ ChatCompletionMessage

Returns a new instance of ChatCompletionMessage.

Parameters:

  • content —

    The contents of the message.

  • refusal —

    The refusal message generated by the model.

  • annotations —

    Annotations for the message, when applicable, as when using the web search tool.

  • audio —

    If the audio output modality is requested, this object contains data about the audio response from the model. Learn more.

  • function_call —

    Deprecated and replaced by tool_calls. The name and arguments of a function that should be called, as generated by the model.

  • tool_calls —

    The tool calls generated by the model, such as function calls.

  • role —

    The role of the author of this message.

  • content: (String, nil)
  • refusal: (String, nil)
  • annotations: (::Array[OpenAI::Chat::ChatCompletionMessage::Annotation])
  • audio: (OpenAI::Chat::ChatCompletionAudio, nil)
  • function_call: (OpenAI::Chat::ChatCompletionMessage::FunctionCall)
  • tool_calls: (::Array[OpenAI::Models::Chat::chat_completion_message_tool_call])
  • role: (:assistant)


# File 'lib/openai/models/chat/chat_completion_message.rb', line 136

Instance Attribute Details

#annotations ⇒ ::Array[OpenAI::Chat::ChatCompletionMessage::Annotation]?

Annotations for the message, when applicable, as when using the web search tool.

Returns:

  • (::Array[OpenAI::Chat::ChatCompletionMessage::Annotation], nil)


30
31
32
33
# File 'lib/openai/models/chat/chat_completion_message.rb', line 30

optional(
  :annotations,
  -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Chat::ChatCompletionMessage::Annotation] }
)

#audio ⇒ OpenAI::Chat::ChatCompletionAudio?

If the audio output modality is requested, this object contains data about the audio response from the model. Learn more.

Returns:

  • (OpenAI::Chat::ChatCompletionAudio, nil)


41
# File 'lib/openai/models/chat/chat_completion_message.rb', line 41

optional :audio, -> { OpenAI::Chat::ChatCompletionAudio }, nil?: true

#content ⇒ String?

The contents of the message.

Returns:

  • (String, nil)


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

required :content, String, nil?: true

#function_call ⇒ OpenAI::Chat::ChatCompletionMessage::FunctionCall?

Deprecated and replaced by tool_calls. The name and arguments of a function that should be called, as generated by the model.

Returns:

  • (OpenAI::Chat::ChatCompletionMessage::FunctionCall, nil)


50
# File 'lib/openai/models/chat/chat_completion_message.rb', line 50

optional :function_call, -> { OpenAI::Chat::ChatCompletionMessage::FunctionCall }

#refusal ⇒ String?

The refusal message generated by the model.

Returns:

  • (String, nil)


17
# File 'lib/openai/models/chat/chat_completion_message.rb', line 17

required :refusal, String, nil?: true

#role ⇒ :assistant

The role of the author of this message.

Returns:

  • (:assistant)


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

required :role, const: :assistant

#tool_calls ⇒ ::Array[OpenAI::Models::Chat::chat_completion_message_tool_call]?

The tool calls generated by the model, such as function calls.

Returns:

  • (::Array[OpenAI::Models::Chat::chat_completion_message_tool_call], nil)


56
57
58
59
# File 'lib/openai/models/chat/chat_completion_message.rb', line 56

optional(
  :tool_calls,
  -> { OpenAI::Internal::Type::ArrayOf[union: OpenAI::Chat::ChatCompletionMessageToolCall] }
)

Instance Method Details

#to_hash ⇒ { content: String?, refusal: String?, ?role: :assistant, ?annotations: ::Array[OpenAI::Chat::ChatCompletionMessage::Annotation], ?audio: OpenAI::Chat::ChatCompletionAudio?, ?function_call: OpenAI::Chat::ChatCompletionMessage::FunctionCall, ?tool_calls: ::Array[OpenAI::Models::Chat::chat_completion_message_tool_call] }

Returns:

  • ({ content: String?, refusal: String?, ?role: :assistant, ?annotations: ::Array[OpenAI::Chat::ChatCompletionMessage::Annotation], ?audio: OpenAI::Chat::ChatCompletionAudio?, ?function_call: OpenAI::Chat::ChatCompletionMessage::FunctionCall, ?tool_calls: ::Array[OpenAI::Models::Chat::chat_completion_message_tool_call] })


88
89
90
91
92
93
94
95
96
# File 'sig/openai/models/chat/chat_completion_message.rbs', line 88

def to_hash: -> {
  content: String?,
  refusal: String?,
  ?role: :assistant,
  ?annotations: ::Array[OpenAI::Chat::ChatCompletionMessage::Annotation],
  ?audio: OpenAI::Chat::ChatCompletionAudio?,
  ?function_call: OpenAI::Chat::ChatCompletionMessage::FunctionCall,
  ?tool_calls: ::Array[OpenAI::Models::Chat::chat_completion_message_tool_call]
}