Class: Ask::Eval::TestCase

Inherits:
Data
  • Object
show all
Defined in:
lib/ask/eval/test_case.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input: nil, actual_output:, expected_output: nil, context: nil) ⇒ TestCase

Returns a new instance of TestCase.

Parameters:

  • input (String, nil) (defaults to: nil)

    the input/prompt that generated the output

  • actual_output (String)

    the LLM output being evaluated

  • expected_output (String, nil) (defaults to: nil)

    the expected/reference output

  • context (String, Array<String>, nil) (defaults to: nil)

    source context for faithfulness checks



10
11
12
13
# File 'lib/ask/eval/test_case.rb', line 10

def initialize(input: nil, actual_output:, expected_output: nil, context: nil)
  super(input: input, actual_output: actual_output,
        expected_output: expected_output, context: context)
end

Instance Attribute Details

#actual_outputObject (readonly)

Returns the value of attribute actual_output

Returns:

  • (Object)

    the current value of actual_output



5
6
7
# File 'lib/ask/eval/test_case.rb', line 5

def actual_output
  @actual_output
end

#contextObject (readonly)

Returns the value of attribute context

Returns:

  • (Object)

    the current value of context



5
6
7
# File 'lib/ask/eval/test_case.rb', line 5

def context
  @context
end

#expected_outputObject (readonly)

Returns the value of attribute expected_output

Returns:

  • (Object)

    the current value of expected_output



5
6
7
# File 'lib/ask/eval/test_case.rb', line 5

def expected_output
  @expected_output
end

#inputObject (readonly)

Returns the value of attribute input

Returns:

  • (Object)

    the current value of input



5
6
7
# File 'lib/ask/eval/test_case.rb', line 5

def input
  @input
end

Instance Method Details

#inspectString

Returns a concise description for logging.

Returns:

  • (String)

    a concise description for logging



16
17
18
19
20
# File 'lib/ask/eval/test_case.rb', line 16

def inspect
  input_preview = input ? " input=#{input.to_s[0..50].inspect}" : ""
  output_preview = " output=#{actual_output.to_s[0..50].inspect}"
  "#<Ask::Eval::TestCase#{input_preview}#{output_preview}>"
end