Class: RubyLLM::Contract::Eval::StepExpectationApplier
- Inherits:
-
Object
- Object
- RubyLLM::Contract::Eval::StepExpectationApplier
- Defined in:
- lib/ruby_llm/contract/eval/step_expectation_applier.rb
Instance Method Summary collapse
- #call(result:, run_result:, test_case:) ⇒ Object
-
#initialize(expectation_evaluator: ExpectationEvaluator.new) ⇒ StepExpectationApplier
constructor
A new instance of StepExpectationApplier.
Constructor Details
#initialize(expectation_evaluator: ExpectationEvaluator.new) ⇒ StepExpectationApplier
Returns a new instance of StepExpectationApplier.
7 8 9 |
# File 'lib/ruby_llm/contract/eval/step_expectation_applier.rb', line 7 def initialize(expectation_evaluator: ExpectationEvaluator.new) @expectation_evaluator = expectation_evaluator end |
Instance Method Details
#call(result:, run_result:, test_case:) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/ruby_llm/contract/eval/step_expectation_applier.rb', line 11 def call(result:, run_result:, test_case:) return result unless applicable?(test_case, run_result) expectation_results = evaluate_expectations(run_result.outputs_by_step, test_case.step_expectations) return result if expectation_results.values.all? { |entry| entry[:passed] } rebuild_result(result, failure_details_for(expectation_results)) end |