Class: LittleGhost::RunResult
- Inherits:
-
Data
- Object
- Data
- LittleGhost::RunResult
- Defined in:
- lib/little_ghost/run_result.rb,
lib/little_ghost/run_result.rb
Overview
RunResult gives callers one final view of an Assembly invocation. It includes the response, usage, updated conversation, state, coordination steps, and any validated structured value.
Use #output when the caller should accept either structured or textual agents. It returns the validated structured value when present and #text otherwise.
Instance Attribute Summary collapse
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#messages ⇒ Object
readonly
Returns the value of attribute messages.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
-
#steps ⇒ Object
readonly
Returns the value of attribute steps.
-
#stop_reason ⇒ Object
readonly
Returns the value of attribute stop_reason.
-
#structured_result ⇒ Object
readonly
Returns the value of attribute structured_result.
-
#usage ⇒ Object
readonly
Returns the value of attribute usage.
Instance Method Summary collapse
-
#initialize(message:, stop_reason:, usage:, messages:, state:, structured_result: nil, steps: []) ⇒ RunResult
constructor
A new instance of RunResult.
-
#output ⇒ Object
Uses the structured value when present and otherwise #text.
-
#structured? ⇒ Boolean
Indicates whether the run produced a validated structured result.
-
#text ⇒ Object
Reads the final message text, or an empty string when no message exists.
-
#trajectory ⇒ Object
Returns immutable coordination queries for this result.
Constructor Details
#initialize(message:, stop_reason:, usage:, messages:, state:, structured_result: nil, steps: []) ⇒ RunResult
Returns a new instance of RunResult.
8 9 10 |
# File 'lib/little_ghost/run_result.rb', line 8 def initialize(message:, stop_reason:, usage:, messages:, state:, structured_result: nil, steps: []) super(message:, stop_reason:, usage:, messages:, state:, structured_result:, steps: Array(steps).freeze) end |
Instance Attribute Details
#message ⇒ Object (readonly)
Returns the value of attribute message
7 8 9 |
# File 'lib/little_ghost/run_result.rb', line 7 def @message end |
#messages ⇒ Object (readonly)
Returns the value of attribute messages
7 8 9 |
# File 'lib/little_ghost/run_result.rb', line 7 def @messages end |
#state ⇒ Object (readonly)
Returns the value of attribute state
7 8 9 |
# File 'lib/little_ghost/run_result.rb', line 7 def state @state end |
#steps ⇒ Object (readonly)
Returns the value of attribute steps
7 8 9 |
# File 'lib/little_ghost/run_result.rb', line 7 def steps @steps end |
#stop_reason ⇒ Object (readonly)
Returns the value of attribute stop_reason
7 8 9 |
# File 'lib/little_ghost/run_result.rb', line 7 def stop_reason @stop_reason end |
#structured_result ⇒ Object (readonly)
Returns the value of attribute structured_result
7 8 9 |
# File 'lib/little_ghost/run_result.rb', line 7 def structured_result @structured_result end |
#usage ⇒ Object (readonly)
Returns the value of attribute usage
7 8 9 |
# File 'lib/little_ghost/run_result.rb', line 7 def usage @usage end |
Instance Method Details
#output ⇒ Object
Uses the structured value when present and otherwise #text.
23 24 25 |
# File 'lib/little_ghost/run_result.rb', line 23 def output structured? ? structured_result.value : text end |
#structured? ⇒ Boolean
Indicates whether the run produced a validated structured result.
18 19 20 |
# File 'lib/little_ghost/run_result.rb', line 18 def structured? !structured_result.nil? end |
#text ⇒ Object
Reads the final message text, or an empty string when no message exists.
13 14 15 |
# File 'lib/little_ghost/run_result.rb', line 13 def text &.text.to_s end |
#trajectory ⇒ Object
Returns immutable coordination queries for this result.
28 |
# File 'lib/little_ghost/run_result.rb', line 28 def trajectory = Assembly::Trajectory.new(steps) |