Class: OpenAICompatibleErrors::RetryContext

Inherits:
Object
  • Object
show all
Defined in:
lib/openai_compatible_errors/retry.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method:, phase:, replay_safety:, attempt:, elapsed_ms:, has_stream_output: false) ⇒ RetryContext

Returns a new instance of RetryContext.



32
33
34
35
36
37
38
39
40
41
# File 'lib/openai_compatible_errors/retry.rb', line 32

def initialize(method:, phase:, replay_safety:, attempt:, elapsed_ms:,
               has_stream_output: false)
  @method = method.is_a?(String) ? method.strip.upcase : ""
  @phase = coerce(phase, REQUEST_PHASES, :unknown)
  @replay_safety = coerce(replay_safety, REPLAY_SAFETY, :unknown)
  @attempt = attempt.is_a?(Integer) && attempt.positive? ? attempt : 0
  @elapsed_ms = elapsed_ms.is_a?(Integer) && elapsed_ms >= 0 ? elapsed_ms : -1
  @has_stream_output = (has_stream_output == true)
  freeze
end

Instance Attribute Details

#attemptObject (readonly)

Returns the value of attribute attempt.



29
30
31
# File 'lib/openai_compatible_errors/retry.rb', line 29

def attempt
  @attempt
end

#elapsed_msObject (readonly)

Returns the value of attribute elapsed_ms.



29
30
31
# File 'lib/openai_compatible_errors/retry.rb', line 29

def elapsed_ms
  @elapsed_ms
end

#has_stream_outputObject (readonly)

Returns the value of attribute has_stream_output.



29
30
31
# File 'lib/openai_compatible_errors/retry.rb', line 29

def has_stream_output
  @has_stream_output
end

#methodObject (readonly)

Returns the value of attribute method.



29
30
31
# File 'lib/openai_compatible_errors/retry.rb', line 29

def method
  @method
end

#phaseObject (readonly)

Returns the value of attribute phase.



29
30
31
# File 'lib/openai_compatible_errors/retry.rb', line 29

def phase
  @phase
end

#replay_safetyObject (readonly)

Returns the value of attribute replay_safety.



29
30
31
# File 'lib/openai_compatible_errors/retry.rb', line 29

def replay_safety
  @replay_safety
end