Class: OmniAgent::Eval::OutputAssertion

Inherits:
Object
  • Object
show all
Defined in:
lib/omni_agent/eval/output_assertion.rb

Instance Method Summary collapse

Constructor Details

#initialize(to_include: nil, to_match: nil, &block) ⇒ OutputAssertion

Returns a new instance of OutputAssertion.



4
5
6
7
8
# File 'lib/omni_agent/eval/output_assertion.rb', line 4

def initialize(to_include: nil, to_match: nil, &block)
  @to_include = to_include
  @to_match = to_match
  @block = block
end

Instance Method Details

#call(run) ⇒ Object

Raises:

  • (ArgumentError)


10
11
12
13
14
15
16
17
18
# File 'lib/omni_agent/eval/output_assertion.rb', line 10

def call(run)
  output = run.output

  return call_block(output) if @block
  return call_to_include(output) if @to_include
  return call_to_match(output) if @to_match

  raise ArgumentError, "expect_output requires to_include:, to_match:, or a block"
end