Class: OpenAI::Helpers::Streaming::UnknownStreamEvent

Inherits:
Object
  • Object
show all
Defined in:
lib/openai/helpers/streaming/unknown_stream_event.rb,
sig/openai/helpers/streaming/unknown_stream_event.rbs

Overview

A Responses event whose discriminator is newer than this SDK version.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data:) ⇒ UnknownStreamEvent

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of UnknownStreamEvent.

Parameters:

  • data: (::Hash[Symbol, untyped])


18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/openai/helpers/streaming/unknown_stream_event.rb', line 18

def initialize(data:)
  value = data.fetch(:type)
  unless value.is_a?(String) || value.is_a?(Symbol)
    raise ArgumentError, "Responses stream event type must be a string or symbol"
  end

  @type = value.to_sym
  sequence_number = data[:sequence_number]
  @sequence_number = sequence_number if sequence_number.is_a?(Integer)
  @data = freeze_json(data)
  freeze
end

Instance Attribute Details

#dataHash{Symbol=>Object} (readonly)

Returns:

  • (Hash{Symbol=>Object})


15
16
17
# File 'lib/openai/helpers/streaming/unknown_stream_event.rb', line 15

def data
  @data
end

#sequence_numberInteger? (readonly)

Returns:

  • (Integer, nil)


12
13
14
# File 'lib/openai/helpers/streaming/unknown_stream_event.rb', line 12

def sequence_number
  @sequence_number
end

#typeSymbol (readonly)

Returns:

  • (Symbol)


9
10
11
# File 'lib/openai/helpers/streaming/unknown_stream_event.rb', line 9

def type
  @type
end

Instance Method Details

#to_hHash{Symbol=>Object}

Returns:

  • (Hash{Symbol=>Object})


32
# File 'lib/openai/helpers/streaming/unknown_stream_event.rb', line 32

def to_h = @data