Class: RubyLLM::Contract::Step::Result
- Inherits:
-
Object
- Object
- RubyLLM::Contract::Step::Result
- Defined in:
- lib/ruby_llm/contract/step/result.rb
Instance Attribute Summary collapse
-
#observations ⇒ Object
readonly
Returns the value of attribute observations.
-
#parsed_output ⇒ Object
readonly
Returns the value of attribute parsed_output.
-
#raw_output ⇒ Object
readonly
Returns the value of attribute raw_output.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#trace ⇒ Object
readonly
Returns the value of attribute trace.
-
#validation_errors ⇒ Object
readonly
Returns the value of attribute validation_errors.
Instance Method Summary collapse
- #failed? ⇒ Boolean
-
#initialize(status:, raw_output:, parsed_output:, validation_errors: [], trace: nil, observations: []) ⇒ Result
constructor
A new instance of Result.
- #ok? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(status:, raw_output:, parsed_output:, validation_errors: [], trace: nil, observations: []) ⇒ Result
Returns a new instance of Result.
9 10 11 12 13 14 15 16 17 |
# File 'lib/ruby_llm/contract/step/result.rb', line 9 def initialize(status:, raw_output:, parsed_output:, validation_errors: [], trace: nil, observations: []) @status = status @raw_output = raw_output @parsed_output = parsed_output @validation_errors = validation_errors.freeze @observations = observations.freeze @trace = normalize_trace(trace) freeze end |
Instance Attribute Details
#observations ⇒ Object (readonly)
Returns the value of attribute observations.
7 8 9 |
# File 'lib/ruby_llm/contract/step/result.rb', line 7 def observations @observations end |
#parsed_output ⇒ Object (readonly)
Returns the value of attribute parsed_output.
7 8 9 |
# File 'lib/ruby_llm/contract/step/result.rb', line 7 def parsed_output @parsed_output end |
#raw_output ⇒ Object (readonly)
Returns the value of attribute raw_output.
7 8 9 |
# File 'lib/ruby_llm/contract/step/result.rb', line 7 def raw_output @raw_output end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
7 8 9 |
# File 'lib/ruby_llm/contract/step/result.rb', line 7 def status @status end |
#trace ⇒ Object (readonly)
Returns the value of attribute trace.
7 8 9 |
# File 'lib/ruby_llm/contract/step/result.rb', line 7 def trace @trace end |
#validation_errors ⇒ Object (readonly)
Returns the value of attribute validation_errors.
7 8 9 |
# File 'lib/ruby_llm/contract/step/result.rb', line 7 def validation_errors @validation_errors end |
Instance Method Details
#failed? ⇒ Boolean
23 24 25 |
# File 'lib/ruby_llm/contract/step/result.rb', line 23 def failed? @status != :ok end |
#ok? ⇒ Boolean
19 20 21 |
# File 'lib/ruby_llm/contract/step/result.rb', line 19 def ok? @status == :ok end |
#to_s ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/ruby_llm/contract/step/result.rb', line 40 def to_s if ok? "#{@status} (#{@trace})" else errors = @validation_errors.first(3).join(", ") errors += ", ..." if @validation_errors.size > 3 "#{@status}: #{errors}" end end |