Class: Legion::LLM::Call::SelectionDispatch::Result
- Inherits:
-
Object
- Object
- Legion::LLM::Call::SelectionDispatch::Result
- Defined in:
- lib/legion/llm/call/selection_dispatch.rb
Overview
Immutable dispatch result. value holds the provider return separately
from the normalized outcome; the outcome never embeds the body.
Instance Attribute Summary collapse
-
#outcome ⇒ Object
readonly
Returns the value of attribute outcome.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
- #failure? ⇒ Boolean
-
#initialize(value:, outcome:) ⇒ Result
constructor
A new instance of Result.
- #success? ⇒ Boolean
Constructor Details
#initialize(value:, outcome:) ⇒ Result
Returns a new instance of Result.
36 37 38 39 40 |
# File 'lib/legion/llm/call/selection_dispatch.rb', line 36 def initialize(value:, outcome:) @value = value @outcome = outcome freeze end |
Instance Attribute Details
#outcome ⇒ Object (readonly)
Returns the value of attribute outcome.
21 22 23 |
# File 'lib/legion/llm/call/selection_dispatch.rb', line 21 def outcome @outcome end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
21 22 23 |
# File 'lib/legion/llm/call/selection_dispatch.rb', line 21 def value @value end |
Class Method Details
.failure(outcome:) ⇒ Object
30 31 32 33 34 |
# File 'lib/legion/llm/call/selection_dispatch.rb', line 30 def self.failure(outcome:) raise ArgumentError, 'SelectionDispatch::Result.failure requires a non-success ProviderOutcome' if outcome.kind == :success new(value: nil, outcome: outcome) end |
.success(value:) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/legion/llm/call/selection_dispatch.rb', line 23 def self.success(value:) new(value: value, outcome: Legion::Extensions::Llm::Routing::ProviderOutcome.new( kind: :success, reason: 'provider call completed' )) end |
Instance Method Details
#failure? ⇒ Boolean
43 |
# File 'lib/legion/llm/call/selection_dispatch.rb', line 43 def failure? = !success? |
#success? ⇒ Boolean
42 |
# File 'lib/legion/llm/call/selection_dispatch.rb', line 42 def success? = @outcome.kind == :success |