Class: RubyLLM::Contract::Pipeline::Runner::ExecutionState

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

Overview

Encapsulates mutable state during pipeline execution

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input) ⇒ ExecutionState

Returns a new instance of ExecutionState.



103
104
105
106
107
108
109
110
111
# File 'lib/ruby_llm/contract/pipeline/runner.rb', line 103

def initialize(input)
  @trace_id = SecureRandom.uuid
  @step_results = []
  @step_traces = []
  @outputs_by_step = {}
  @current_input = input
  @status = :ok
  @failed_step = nil
end

Instance Attribute Details

#current_inputObject (readonly)

Returns the value of attribute current_input.



100
101
102
# File 'lib/ruby_llm/contract/pipeline/runner.rb', line 100

def current_input
  @current_input
end

#failed_stepObject (readonly)

Returns the value of attribute failed_step.



100
101
102
# File 'lib/ruby_llm/contract/pipeline/runner.rb', line 100

def failed_step
  @failed_step
end

#outputs_by_stepObject (readonly)

Returns the value of attribute outputs_by_step.



100
101
102
# File 'lib/ruby_llm/contract/pipeline/runner.rb', line 100

def outputs_by_step
  @outputs_by_step
end

#statusObject (readonly)

Returns the value of attribute status.



100
101
102
# File 'lib/ruby_llm/contract/pipeline/runner.rb', line 100

def status
  @status
end

#step_resultsObject (readonly)

Returns the value of attribute step_results.



100
101
102
# File 'lib/ruby_llm/contract/pipeline/runner.rb', line 100

def step_results
  @step_results
end

#step_tracesObject (readonly)

Returns the value of attribute step_traces.



100
101
102
# File 'lib/ruby_llm/contract/pipeline/runner.rb', line 100

def step_traces
  @step_traces
end

#trace_idObject (readonly)

Returns the value of attribute trace_id.



100
101
102
# File 'lib/ruby_llm/contract/pipeline/runner.rb', line 100

def trace_id
  @trace_id
end

Instance Method Details

#failed?Boolean

Returns:

  • (Boolean)


132
133
134
# File 'lib/ruby_llm/contract/pipeline/runner.rb', line 132

def failed?
  @status != :ok
end

#mark_limit_failure(status, failed_alias) ⇒ Object



127
128
129
130
# File 'lib/ruby_llm/contract/pipeline/runner.rb', line 127

def mark_limit_failure(status, failed_alias)
  @status = status
  @failed_step = failed_alias
end

#record_step(step_alias, result) ⇒ Object



113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/ruby_llm/contract/pipeline/runner.rb', line 113

def record_step(step_alias, result)
  @step_results << { alias: step_alias, result: result }
  @step_traces << result.trace

  if result.ok?
    output = result.parsed_output
    @outputs_by_step[step_alias] = output
    @current_input = output
  else
    @status = result.status
    @failed_step = step_alias
  end
end