Class: OpenAI::RetryEvent

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

Overview

Details about an API request retry that is about to run.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attempt:, max_attempts:, delay:, response:, error:) ⇒ RetryEvent

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 RetryEvent.

Parameters:



79
80
81
82
83
84
85
86
# File 'lib/openai/http_client.rb', line 79

def initialize(attempt:, max_attempts:, delay:, response:, error:)
  @attempt = Integer(attempt)
  @max_attempts = Integer(max_attempts)
  @delay = Float(delay)
  @response = response
  @error = error
  freeze
end

Instance Attribute Details

#attemptInteger (readonly)

The one-based number of the attempt that will run after the delay.

Returns:

  • (Integer)


49
50
51
# File 'lib/openai/http_client.rb', line 49

def attempt
  @attempt
end

#delayFloat (readonly)

The number of seconds the SDK will wait before the next attempt.

Returns:

  • (Float)


59
60
61
# File 'lib/openai/http_client.rb', line 59

def delay
  @delay
end

#errorOpenAI::Errors::APIConnectionError? (readonly)

The connection error that caused the retry, if the request failed before an HTTP response was received.



70
71
72
# File 'lib/openai/http_client.rb', line 70

def error
  @error
end

#max_attemptsInteger (readonly)

The maximum number of attempts, including the initial request.

Returns:

  • (Integer)


54
55
56
# File 'lib/openai/http_client.rb', line 54

def max_attempts
  @max_attempts
end

#responseOpenAI::ResponseMetadata? (readonly)

Metadata from the retryable HTTP response, if one was received.

Returns:



64
65
66
# File 'lib/openai/http_client.rb', line 64

def response
  @response
end

Instance Method Details

#request_idString?

The request ID of the retryable response, if one was received.

Returns:

  • (String, nil)


96
# File 'lib/openai/http_client.rb', line 96

def request_id = @response&.request_id

#statusInteger?

The status of the retryable response, if one was received.

Returns:

  • (Integer, nil)


91
# File 'lib/openai/http_client.rb', line 91

def status = @response&.status