Class: Langfuse::Evaluators::ExactMatchEvaluator
- Inherits:
-
BaseEvaluator
- Object
- BaseEvaluator
- Langfuse::Evaluators::ExactMatchEvaluator
- Defined in:
- lib/langfuse/evaluation.rb
Instance Method Summary collapse
- #evaluate(input, output, expected: nil, context: nil) ⇒ Object
-
#initialize(name: 'exact_match', description: 'Exact match evaluator') ⇒ ExactMatchEvaluator
constructor
A new instance of ExactMatchEvaluator.
Constructor Details
#initialize(name: 'exact_match', description: 'Exact match evaluator') ⇒ ExactMatchEvaluator
Returns a new instance of ExactMatchEvaluator.
86 87 88 |
# File 'lib/langfuse/evaluation.rb', line 86 def initialize(name: 'exact_match', description: 'Exact match evaluator') super(name: name, description: description) end |
Instance Method Details
#evaluate(input, output, expected: nil, context: nil) ⇒ Object
90 91 92 93 94 95 96 97 98 |
# File 'lib/langfuse/evaluation.rb', line 90 def evaluate(input, output, expected: nil, context: nil) return create_score(value: 0, comment: 'No expected value provided') unless expected score = output.to_s.strip == expected.to_s.strip ? 1 : 0 create_score( value: score, comment: score == 1 ? 'Exact match' : 'No match' ) end |