Class: RubyLLM::Agents::DSL::Reliability::ReliabilityBuilder
- Inherits:
-
Object
- Object
- RubyLLM::Agents::DSL::Reliability::ReliabilityBuilder
- Defined in:
- lib/ruby_llm/agents/dsl/reliability.rb
Overview
Inner builder class for block-style configuration
Reliability DSL collapse
-
#circuit_breaker_config ⇒ Object
readonly
Returns the value of attribute circuit_breaker_config.
-
#fallback_models_list ⇒ Object
readonly
Returns the value of attribute fallback_models_list.
-
#fallback_providers_list ⇒ Object
readonly
Returns the value of attribute fallback_providers_list.
-
#non_fallback_errors_list ⇒ Object
readonly
Returns the value of attribute non_fallback_errors_list.
-
#retries_config ⇒ Object
readonly
Returns the value of attribute retries_config.
-
#retryable_patterns_list ⇒ Object
readonly
Returns the value of attribute retryable_patterns_list.
-
#total_timeout_value ⇒ Object
readonly
Returns the value of attribute total_timeout_value.
Reliability DSL collapse
- #circuit_breaker(errors: 10, within: 60, cooldown: 300) ⇒ Object
- #fallback_models(*models) ⇒ Object
-
#fallback_provider(provider, **options) ⇒ Object
Configures a fallback provider with optional settings.
-
#initialize ⇒ ReliabilityBuilder
constructor
A new instance of ReliabilityBuilder.
- #non_fallback_errors(*error_classes) ⇒ Object
- #retries(max: 0, backoff: :exponential, base: 0.4, max_delay: 3.0, on: []) ⇒ Object
- #retryable_patterns(*patterns) ⇒ Object
- #total_timeout(seconds) ⇒ Object
Constructor Details
#initialize ⇒ ReliabilityBuilder
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_config ⇒ Object (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_list ⇒ Object (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_list ⇒ Object (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_list ⇒ Object (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_config ⇒ Object (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_list ⇒ Object (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_value ⇒ Object (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
334 335 336 |
# File 'lib/ruby_llm/agents/dsl/reliability.rb', line 334 def fallback_provider(provider, **) @fallback_providers_list << {provider: provider, **} 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 |