Class: RubyLLM::Agents::DSL::Reliability::ReliabilityBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_llm/agents/dsl/reliability.rb

Overview

Inner builder class for block-style configuration

Reliability DSL collapse

Reliability DSL collapse

Constructor Details

#initializeReliabilityBuilder

Returns a new instance of ReliabilityBuilder.



303
304
305
306
307
308
309
310
311
# File 'lib/ruby_llm/agents/dsl/reliability.rb', line 303

def initialize
  @retries_config = nil
  @fallback_models_list = []
  @total_timeout_value = nil
  @circuit_breaker_config = nil
  @retryable_patterns_list = nil
  @fallback_providers_list = []
  @non_fallback_errors_list = nil
end

Instance Attribute Details

#circuit_breaker_configObject (readonly)

Returns the value of attribute circuit_breaker_config.



299
300
301
# File 'lib/ruby_llm/agents/dsl/reliability.rb', line 299

def circuit_breaker_config
  @circuit_breaker_config
end

#fallback_models_listObject (readonly)

Returns the value of attribute fallback_models_list.



299
300
301
# File 'lib/ruby_llm/agents/dsl/reliability.rb', line 299

def fallback_models_list
  @fallback_models_list
end

#fallback_providers_listObject (readonly)

Returns the value of attribute fallback_providers_list.



299
300
301
# File 'lib/ruby_llm/agents/dsl/reliability.rb', line 299

def fallback_providers_list
  @fallback_providers_list
end

#non_fallback_errors_listObject (readonly)

Returns the value of attribute non_fallback_errors_list.



299
300
301
# File 'lib/ruby_llm/agents/dsl/reliability.rb', line 299

def non_fallback_errors_list
  @non_fallback_errors_list
end

#retries_configObject (readonly)

Returns the value of attribute retries_config.



299
300
301
# File 'lib/ruby_llm/agents/dsl/reliability.rb', line 299

def retries_config
  @retries_config
end

#retryable_patterns_listObject (readonly)

Returns the value of attribute retryable_patterns_list.



299
300
301
# File 'lib/ruby_llm/agents/dsl/reliability.rb', line 299

def retryable_patterns_list
  @retryable_patterns_list
end

#total_timeout_valueObject (readonly)

Returns the value of attribute total_timeout_value.



299
300
301
# File 'lib/ruby_llm/agents/dsl/reliability.rb', line 299

def total_timeout_value
  @total_timeout_value
end

Instance Method Details

#circuit_breaker(errors: 10, within: 60, cooldown: 300) ⇒ Object



342
343
344
345
346
347
348
# File 'lib/ruby_llm/agents/dsl/reliability.rb', line 342

def circuit_breaker(errors: 10, within: 60, cooldown: 300)
  @circuit_breaker_config = {
    errors: errors,
    within: within,
    cooldown: cooldown
  }
end

#fallback_models(*models) ⇒ Object



323
324
325
# File 'lib/ruby_llm/agents/dsl/reliability.rb', line 323

def fallback_models(*models)
  @fallback_models_list = models.flatten
end

#fallback_provider(provider, **options) ⇒ Object

Configures a fallback provider with optional settings

Examples:

fallback_provider :openai, voice: "nova"
fallback_provider :elevenlabs, voice: "Rachel", model: "eleven_multilingual_v2"

Parameters:

  • provider (Symbol)

    The provider to fall back to (e.g., :openai, :elevenlabs)

  • options (Hash)

    Provider-specific options (e.g., voice:, model:)



334
335
336
# File 'lib/ruby_llm/agents/dsl/reliability.rb', line 334

def fallback_provider(provider, **options)
  @fallback_providers_list << {provider: provider, **options}
end

#non_fallback_errors(*error_classes) ⇒ Object



354
355
356
# File 'lib/ruby_llm/agents/dsl/reliability.rb', line 354

def non_fallback_errors(*error_classes)
  @non_fallback_errors_list = error_classes.flatten
end

#retries(max: 0, backoff: :exponential, base: 0.4, max_delay: 3.0, on: []) ⇒ Object



313
314
315
316
317
318
319
320
321
# File 'lib/ruby_llm/agents/dsl/reliability.rb', line 313

def retries(max: 0, backoff: :exponential, base: 0.4, max_delay: 3.0, on: [])
  @retries_config = {
    max: max,
    backoff: backoff,
    base: base,
    max_delay: max_delay,
    on: on
  }
end

#retryable_patterns(*patterns) ⇒ Object



350
351
352
# File 'lib/ruby_llm/agents/dsl/reliability.rb', line 350

def retryable_patterns(*patterns)
  @retryable_patterns_list = patterns.flatten
end

#total_timeout(seconds) ⇒ Object



338
339
340
# File 'lib/ruby_llm/agents/dsl/reliability.rb', line 338

def total_timeout(seconds)
  @total_timeout_value = seconds
end