Class: OmniAgent::Eval::Case

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, input: nil, context: {}, run_alias: nil, row: nil, &block) ⇒ Case

Returns a new instance of Case.



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/omni_agent/eval/case.rb', line 6

def initialize(name, input: nil, context: {}, run_alias: nil, row: nil, &block)
  @name = name
  @input = input
  @context = context || {}
  @run_alias = run_alias
  @assertions = []

  if block
    row.nil? ? instance_eval(&block) : instance_exec(row, &block)
  end
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/omni_agent/eval/case.rb', line 4

def name
  @name
end

Instance Method Details

#configured_assertionsObject



51
52
53
# File 'lib/omni_agent/eval/case.rb', line 51

def configured_assertions
  @assertions
end

#configured_contextObject



43
44
45
# File 'lib/omni_agent/eval/case.rb', line 43

def configured_context
  @context
end

#configured_inputObject



39
40
41
# File 'lib/omni_agent/eval/case.rb', line 39

def configured_input
  @input
end

#configured_run_aliasObject



47
48
49
# File 'lib/omni_agent/eval/case.rb', line 47

def configured_run_alias
  @run_alias
end

#expect_output(to_include: nil, to_match: nil, &block) ⇒ Object



31
32
33
# File 'lib/omni_agent/eval/case.rb', line 31

def expect_output(to_include: nil, to_match: nil, &block)
  @assertions << OutputAssertion.new(to_include: to_include, to_match: to_match, &block)
end

#expect_tool_call(tool_name, with: nil) ⇒ Object



27
28
29
# File 'lib/omni_agent/eval/case.rb', line 27

def expect_tool_call(tool_name, with: nil)
  @assertions << ToolCallAssertion.new(tool_name, with: with)
end

#input(text, with: {}) ⇒ Object



18
19
20
21
# File 'lib/omni_agent/eval/case.rb', line 18

def input(text, with: {})
  @input = text
  @context = with || {}
end

#judge(criteria, threshold: 0.7, provider: nil, model: nil) ⇒ Object



35
36
37
# File 'lib/omni_agent/eval/case.rb', line 35

def judge(criteria, threshold: 0.7, provider: nil, model: nil)
  @assertions << JudgeAssertion.new(criteria, threshold: threshold, provider: provider, model: model)
end

#run_alias(name) ⇒ Object



23
24
25
# File 'lib/omni_agent/eval/case.rb', line 23

def run_alias(name)
  @run_alias = name
end