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 agent or workflow invocation. It includes the response, usage, updated conversation, state, 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.
-
#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) ⇒ 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.
Constructor Details
#initialize(message:, stop_reason:, usage:, messages:, state:, structured_result: nil) ⇒ RunResult
Returns a new instance of RunResult.
15 16 17 |
# File 'lib/little_ghost/run_result.rb', line 15 def initialize(message:, stop_reason:, usage:, messages:, state:, structured_result: nil) super end |
Instance Attribute Details
#message ⇒ Object (readonly)
Returns the value of attribute message
14 15 16 |
# File 'lib/little_ghost/run_result.rb', line 14 def @message end |
#messages ⇒ Object (readonly)
Returns the value of attribute messages
14 15 16 |
# File 'lib/little_ghost/run_result.rb', line 14 def @messages end |
#state ⇒ Object (readonly)
Returns the value of attribute state
14 15 16 |
# File 'lib/little_ghost/run_result.rb', line 14 def state @state end |
#stop_reason ⇒ Object (readonly)
Returns the value of attribute stop_reason
14 15 16 |
# File 'lib/little_ghost/run_result.rb', line 14 def stop_reason @stop_reason end |
#structured_result ⇒ Object (readonly)
Returns the value of attribute structured_result
14 15 16 |
# File 'lib/little_ghost/run_result.rb', line 14 def structured_result @structured_result end |
#usage ⇒ Object (readonly)
Returns the value of attribute usage
14 15 16 |
# File 'lib/little_ghost/run_result.rb', line 14 def usage @usage end |
Instance Method Details
#output ⇒ Object
Uses the structured value when present and otherwise #text.
30 31 32 |
# File 'lib/little_ghost/run_result.rb', line 30 def output structured? ? structured_result.value : text end |
#structured? ⇒ Boolean
Indicates whether the run produced a validated structured result.
25 26 27 |
# File 'lib/little_ghost/run_result.rb', line 25 def structured? !structured_result.nil? end |
#text ⇒ Object
Reads the final message text, or an empty string when no message exists.
20 21 22 |
# File 'lib/little_ghost/run_result.rb', line 20 def text &.text.to_s end |