class RubyLLM::Evaluation::Case
One dataset example, with application inputs and optional reference evidence.
Attributes
Returns the reference answer, or nil when none was supplied.
Returns the value passed to Evaluation#perform.
Returns application-defined reference evidence and category labels.
Returns the stable case name used to compare runs.
Public Class Methods
# File lib/ruby_llm/evaluation/case.rb, line 19 def initialize(name:, inputs:, metadata: {}, **reference) unless (reference.keys - [:expected_output]).empty? raise ArgumentError, "Unknown case fields: #{reference.keys - [:expected_output]}" end raise ArgumentError, 'A case name cannot be empty' if name.to_s.empty? raise ArgumentError, 'Case metadata must be a Hash' unless metadata.is_a?(Hash) @name = name.to_s.dup.freeze @inputs = Judge::Data.copy(inputs) @metadata = Judge::Data.copy(metadata) @expected_output = Judge::Data.copy(reference[:expected_output]) @reference_supplied = reference.key?(:expected_output) freeze end
Creates a case. Inputs and reference evidence must be JSON-compatible.
Public Instance Methods
Source
# File lib/ruby_llm/evaluation/case.rb, line 36 def expected_output? @reference_supplied end
Returns whether a reference was supplied, including an explicit nil.
Source
# File lib/ruby_llm/evaluation/case.rb, line 41 def to_h data = { name:, inputs:, metadata: } data[:expected_output] = expected_output if expected_output? data end
Returns the portable dataset representation of this case.