class RubyLLM::Evaluation::Trial
The recorded outcome of one case and repetition, including failed attempts.
Attributes
Returns the number of Ruby assertions attempted.
Returns an assertion failure, or nil.
Returns elapsed wall-clock seconds, including evaluators.
Returns an execution or evidence-conversion error, or nil.
Returns each criterion’s Evaluation::Result.
Returns the frozen evidence supplied to evaluators.
Returns the primary output extracted from the returned value.
Returns the one-based repetition number.
Returns the original value returned by perform, when it completed.
Returns the case whose inputs were executed.
Public Instance Methods
Source
# File lib/ruby_llm/evaluation/trial.rb, line 48 def cost ruby_llm_usage_cost end
Returns a Cost aggregate for this trial, including task and evaluator requests.
Source
# File lib/ruby_llm/evaluation/trial.rb, line 68 def evaluator_cost Cost.aggregate(@evaluator_usage.map(&:cost), complete: @evaluator_usage.all?(&:cost_available?)) end
Returns the cost of the evaluators and their tools.
Source
# File lib/ruby_llm/evaluation/trial.rb, line 58 def evaluator_tokens Tokens.aggregate(@evaluator_usage.map(&:tokens)) end
Returns the tokens used by the evaluators and their tools.
Source
# File lib/ruby_llm/evaluation/trial.rb, line 82 def passed? status == :passed end
Returns whether every assessment passed and no error occurred.
Source
# File lib/ruby_llm/evaluation/trial.rb, line 73 def status statuses = evaluations.map(&:status) statuses << :error if error statuses << :failed if assertion_failure statuses << :measured if evaluations.empty? && assertion_count.to_i.zero? %i[error failed unassessed measured].find { |status| statuses.include?(status) } || :passed end
Returns :passed, :failed, :measured, :unassessed, or :error. Empty trials are never passes.
Source
# File lib/ruby_llm/evaluation/trial.rb, line 63 def task_cost Cost.aggregate(@task_usage.map(&:cost), complete: @task_usage.all?(&:cost_available?)) end
Returns the task’s cost, including setup, assertions, and teardown requests.
Source
# File lib/ruby_llm/evaluation/trial.rb, line 53 def task_tokens Tokens.aggregate(@task_usage.map(&:tokens)) end
Returns the task’s tokens, including setup, assertions, and teardown requests.
Source
# File lib/ruby_llm/evaluation/trial.rb, line 87 def to_h { case: test_case.to_h, repetition:, status:, evidence:, evaluations: evaluations.map(&:to_h), assertion_count:, assertion_failure: assertion_failure&.message, duration:, error: error && { class: error.class.name, message: error.message }, tokens: tokens.to_h, cost: cost.to_h, task_tokens: task_tokens.to_h, evaluator_tokens: evaluator_tokens.to_h, task_cost: task_cost.to_h, evaluator_cost: evaluator_cost.to_h } end
Returns the portable trial record, excluding the live application object.