Class: RubyLLM::Contract::Eval::RetryOptimizer::Result

Inherits:
Struct
  • Object
show all
Defined in:
lib/ruby_llm/contract/eval/retry_optimizer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#candidate_labelsObject

Returns the value of attribute candidate_labels

Returns:

  • (Object)

    the current value of candidate_labels



16
17
18
# File 'lib/ruby_llm/contract/eval/retry_optimizer.rb', line 16

def candidate_labels
  @candidate_labels
end

#chainObject

Returns the value of attribute chain

Returns:

  • (Object)

    the current value of chain



16
17
18
# File 'lib/ruby_llm/contract/eval/retry_optimizer.rb', line 16

def chain
  @chain
end

#chain_detailsObject

Returns the value of attribute chain_details

Returns:

  • (Object)

    the current value of chain_details



16
17
18
# File 'lib/ruby_llm/contract/eval/retry_optimizer.rb', line 16

def chain_details
  @chain_details
end

#constraining_evalObject

Returns the value of attribute constraining_eval

Returns:

  • (Object)

    the current value of constraining_eval



16
17
18
# File 'lib/ruby_llm/contract/eval/retry_optimizer.rb', line 16

def constraining_eval
  @constraining_eval
end

#eval_namesObject

Returns the value of attribute eval_names

Returns:

  • (Object)

    the current value of eval_names



16
17
18
# File 'lib/ruby_llm/contract/eval/retry_optimizer.rb', line 16

def eval_names
  @eval_names
end

#score_matrixObject

Returns the value of attribute score_matrix

Returns:

  • (Object)

    the current value of score_matrix



16
17
18
# File 'lib/ruby_llm/contract/eval/retry_optimizer.rb', line 16

def score_matrix
  @score_matrix
end

#step_nameObject

Returns the value of attribute step_name

Returns:

  • (Object)

    the current value of step_name



16
17
18
# File 'lib/ruby_llm/contract/eval/retry_optimizer.rb', line 16

def step_name
  @step_name
end

Instance Method Details



18
19
20
21
22
23
24
25
26
# File 'lib/ruby_llm/contract/eval/retry_optimizer.rb', line 18

def print_summary(io = $stdout)
  io.puts "#{step_name} — retry chain optimization"
  io.puts
  print_table(io)
  io.puts
  print_chain(io)
  io.puts
  print_dsl(io)
end

#to_dslObject



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/ruby_llm/contract/eval/retry_optimizer.rb', line 28

def to_dsl
  return "# No viable chain — no candidate passes all evals" if chain.empty?

  if chain.all? { |c| c.keys == [:model] }
    models_str = chain.map { |c| c[:model] }.join(" ")
    "retry_policy models: %w[#{models_str}]"
  else
    args = chain.map { |c| config_to_ruby(c) }.join(",\n    ")
    "retry_policy do\n  escalate(\n    #{args}\n  )\nend"
  end
end