Class: RosettAi::AiConfig::FallbackChain
- Inherits:
-
Object
- Object
- RosettAi::AiConfig::FallbackChain
- Defined in:
- lib/rosett_ai/ai_config/fallback_chain.rb
Overview
Ordered engine fallback chain with local-to-remote transition warnings.
When the primary engine is unavailable, the chain specifies fallback engines in order. Warns when a fallback would switch from local to remote (network requirement change).
Constant Summary collapse
- LOCAL_ENGINES =
['ollama', 'gpt_neox'].freeze
Instance Attribute Summary collapse
-
#engines ⇒ Object
readonly
Returns the value of attribute engines.
-
#warnings ⇒ Object
readonly
Returns the value of attribute warnings.
Instance Method Summary collapse
-
#fallbacks ⇒ Array<String>
Fallback engines (all after primary).
-
#initialize(engines: []) ⇒ FallbackChain
constructor
A new instance of FallbackChain.
-
#local_to_remote_transition? ⇒ Boolean
True if chain contains local-to-remote transitions.
-
#primary ⇒ String?
Primary engine (first in chain).
-
#to_h ⇒ Hash
Serializable representation.
Constructor Details
#initialize(engines: []) ⇒ FallbackChain
Returns a new instance of FallbackChain.
19 20 21 22 |
# File 'lib/rosett_ai/ai_config/fallback_chain.rb', line 19 def initialize(engines: []) @engines = engines.freeze @warnings = detect_transition_warnings.freeze end |
Instance Attribute Details
#engines ⇒ Object (readonly)
Returns the value of attribute engines.
16 17 18 |
# File 'lib/rosett_ai/ai_config/fallback_chain.rb', line 16 def engines @engines end |
#warnings ⇒ Object (readonly)
Returns the value of attribute warnings.
16 17 18 |
# File 'lib/rosett_ai/ai_config/fallback_chain.rb', line 16 def warnings @warnings end |
Instance Method Details
#fallbacks ⇒ Array<String>
Returns fallback engines (all after primary).
30 31 32 |
# File 'lib/rosett_ai/ai_config/fallback_chain.rb', line 30 def fallbacks @engines.drop(1) end |
#local_to_remote_transition? ⇒ Boolean
Returns true if chain contains local-to-remote transitions.
35 36 37 |
# File 'lib/rosett_ai/ai_config/fallback_chain.rb', line 35 def local_to_remote_transition? !@warnings.empty? end |
#primary ⇒ String?
Returns primary engine (first in chain).
25 26 27 |
# File 'lib/rosett_ai/ai_config/fallback_chain.rb', line 25 def primary @engines.first end |
#to_h ⇒ Hash
Returns serializable representation.
40 41 42 43 44 45 |
# File 'lib/rosett_ai/ai_config/fallback_chain.rb', line 40 def to_h { 'engines' => @engines.dup, 'warnings' => @warnings.dup } end |