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.



325
326
327
328
329
330
331
332
333
# File 'lib/ruby_llm/agents/dsl/reliability.rb', line 325

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.



321
322
323
# File 'lib/ruby_llm/agents/dsl/reliability.rb', line 321

def circuit_breaker_config
  @circuit_breaker_config
end

#fallback_models_listObject (readonly)

Returns the value of attribute fallback_models_list.



321
322
323
# File 'lib/ruby_llm/agents/dsl/reliability.rb', line 321

def fallback_models_list
  @fallback_models_list
end

#fallback_providers_listObject (readonly)

Returns the value of attribute fallback_providers_list.



321
322
323
# File 'lib/ruby_llm/agents/dsl/reliability.rb', line 321

def fallback_providers_list
  @fallback_providers_list
end

#non_fallback_errors_listObject (readonly)

Returns the value of attribute non_fallback_errors_list.



321
322
323
# File 'lib/ruby_llm/agents/dsl/reliability.rb', line 321

def non_fallback_errors_list
  @non_fallback_errors_list
end

#retries_configObject (readonly)

Returns the value of attribute retries_config.



321
322
323
# File 'lib/ruby_llm/agents/dsl/reliability.rb', line 321

def retries_config
  @retries_config
end

#retryable_patterns_listObject (readonly)

Returns the value of attribute retryable_patterns_list.



321
322
323
# File 'lib/ruby_llm/agents/dsl/reliability.rb', line 321

def retryable_patterns_list
  @retryable_patterns_list
end

#total_timeout_valueObject (readonly)

Returns the value of attribute total_timeout_value.



321
322
323
# File 'lib/ruby_llm/agents/dsl/reliability.rb', line 321

def total_timeout_value
  @total_timeout_value
end

Instance Method Details

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



364
365
366
367
368
369
370
# File 'lib/ruby_llm/agents/dsl/reliability.rb', line 364

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

#fallback_models(*models) ⇒ Object



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

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:)



356
357
358
# File 'lib/ruby_llm/agents/dsl/reliability.rb', line 356

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

#non_fallback_errors(*error_classes) ⇒ Object



376
377
378
# File 'lib/ruby_llm/agents/dsl/reliability.rb', line 376

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



335
336
337
338
339
340
341
342
343
# File 'lib/ruby_llm/agents/dsl/reliability.rb', line 335

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



372
373
374
# File 'lib/ruby_llm/agents/dsl/reliability.rb', line 372

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

#total_timeout(seconds) ⇒ Object



360
361
362
# File 'lib/ruby_llm/agents/dsl/reliability.rb', line 360

def total_timeout(seconds)
  @total_timeout_value = seconds
end