Class: RubyLLM::Contract::Pipeline::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_llm/contract/pipeline/result.rb

Constant Summary collapse

COL1 =

Column widths for pretty_print table

14
COL2 =

step name

10
COL3 =

status

50
TOP_BORDER =

output

"+#{"-" * (COL1 + COL2 + COL3 + 8)}+".freeze
MID_BORDER =
"+-#{"-" * COL1}-+-#{"-" * COL2}-+-#{"-" * COL3}-+".freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status:, step_results:, outputs_by_step:, failed_step: nil, trace: Trace.new) ⇒ Result

Returns a new instance of Result.



17
18
19
20
21
22
23
24
# File 'lib/ruby_llm/contract/pipeline/result.rb', line 17

def initialize(status:, step_results:, outputs_by_step:, failed_step: nil, trace: Trace.new)
  @status = status
  @step_results = step_results.each(&:freeze).freeze
  @outputs_by_step = outputs_by_step.freeze
  @failed_step = failed_step
  @trace = trace
  freeze
end

Instance Attribute Details

#failed_stepObject (readonly)

Returns the value of attribute failed_step.



7
8
9
# File 'lib/ruby_llm/contract/pipeline/result.rb', line 7

def failed_step
  @failed_step
end

#outputs_by_stepObject (readonly)

Returns the value of attribute outputs_by_step.



7
8
9
# File 'lib/ruby_llm/contract/pipeline/result.rb', line 7

def outputs_by_step
  @outputs_by_step
end

#statusObject (readonly)

Returns the value of attribute status.



7
8
9
# File 'lib/ruby_llm/contract/pipeline/result.rb', line 7

def status
  @status
end

#step_resultsObject (readonly)

Returns the value of attribute step_results.



7
8
9
# File 'lib/ruby_llm/contract/pipeline/result.rb', line 7

def step_results
  @step_results
end

#traceObject (readonly)

Returns the value of attribute trace.



7
8
9
# File 'lib/ruby_llm/contract/pipeline/result.rb', line 7

def trace
  @trace
end

Instance Method Details

#failed?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/ruby_llm/contract/pipeline/result.rb', line 30

def failed?
  @status != :ok
end

#ok?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/ruby_llm/contract/pipeline/result.rb', line 26

def ok?
  @status == :ok
end

#pretty_print(io = $stdout) ⇒ Object



40
41
42
# File 'lib/ruby_llm/contract/pipeline/result.rb', line 40

def pretty_print(io = $stdout)
  build_table.each { |line| io.puts line }
end

#to_sObject



34
35
36
37
38
# File 'lib/ruby_llm/contract/pipeline/result.rb', line 34

def to_s
  lines = [header_line]
  @step_results.each { |sr| lines << step_line(sr) }
  lines.join("\n")
end