Class: Legion::LLM::Router::EscalationChain
- Inherits:
-
Object
- Object
- Legion::LLM::Router::EscalationChain
- Includes:
- Enumerable, Legion::Logging::Helper
- Defined in:
- lib/legion/llm/router/escalation/chain.rb
Instance Attribute Summary collapse
-
#max_attempts ⇒ Object
readonly
Returns the value of attribute max_attempts.
Instance Method Summary collapse
- #each ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(resolutions:, max_attempts: 3) ⇒ EscalationChain
constructor
A new instance of EscalationChain.
- #primary ⇒ Object
- #size ⇒ Object
- #to_a ⇒ Object
Constructor Details
#initialize(resolutions:, max_attempts: 3) ⇒ EscalationChain
Returns a new instance of EscalationChain.
12 13 14 15 16 17 |
# File 'lib/legion/llm/router/escalation/chain.rb', line 12 def initialize(resolutions:, max_attempts: 3) @resolutions = resolutions.dup.freeze @max_attempts = max_attempts log.debug "[llm][escalation_chain] action=built size=#{@resolutions.size} max_attempts=#{@max_attempts} " \ "providers=#{@resolutions.map { |r| "#{r.provider}:#{r.model}" }.join(', ')}" end |
Instance Attribute Details
#max_attempts ⇒ Object (readonly)
Returns the value of attribute max_attempts.
10 11 12 |
# File 'lib/legion/llm/router/escalation/chain.rb', line 10 def max_attempts @max_attempts end |
Instance Method Details
#each ⇒ Object
23 24 25 26 27 |
# File 'lib/legion/llm/router/escalation/chain.rb', line 23 def each(&) return enum_for(:each) unless block_given? capped_resolutions.each(&) end |
#empty? ⇒ Boolean
33 34 35 |
# File 'lib/legion/llm/router/escalation/chain.rb', line 33 def empty? @resolutions.empty? end |
#primary ⇒ Object
19 20 21 |
# File 'lib/legion/llm/router/escalation/chain.rb', line 19 def primary @resolutions.first end |
#size ⇒ Object
29 30 31 |
# File 'lib/legion/llm/router/escalation/chain.rb', line 29 def size @resolutions.size end |
#to_a ⇒ Object
37 38 39 |
# File 'lib/legion/llm/router/escalation/chain.rb', line 37 def to_a @resolutions.dup end |