Class: Braintrust::Scorer::Block
- Inherits:
-
Object
- Object
- Braintrust::Scorer::Block
- Includes:
- Braintrust::Scorer
- Defined in:
- lib/braintrust/scorer.rb
Overview
Block-based scorer. Stores a Proc and delegates #call to it. Includes Scorer so it satisfies Scorer === checks (e.g. in Context::Factory). Exposes #call_parameters so KeywordFilter can introspect the block’s declared kwargs rather than Block#call’s **kwargs signature.
Constant Summary
Constants included from Braintrust::Scorer
Instance Attribute Summary collapse
- #name ⇒ String readonly
Instance Method Summary collapse
-
#call(**kwargs) ⇒ Array<Hash>
Normalized score results.
-
#call_parameters ⇒ Array<Array>
Exposes the block’s parameter list so KeywordFilter can filter kwargs to match the block’s declared keywords.
-
#initialize(name: DEFAULT_NAME, &block) ⇒ Block
constructor
A new instance of Block.
Methods included from Braintrust::Scorer
Constructor Details
#initialize(name: DEFAULT_NAME, &block) ⇒ Block
Returns a new instance of Block.
123 124 125 126 |
# File 'lib/braintrust/scorer.rb', line 123 def initialize(name: DEFAULT_NAME, &block) @name = name @block = wrap_block(block) end |
Instance Attribute Details
#name ⇒ String (readonly)
119 120 121 |
# File 'lib/braintrust/scorer.rb', line 119 def name @name end |
Instance Method Details
#call(**kwargs) ⇒ Array<Hash>
Returns normalized score results.
130 131 132 |
# File 'lib/braintrust/scorer.rb', line 130 def call(**kwargs) @block.call(**kwargs) end |
#call_parameters ⇒ Array<Array>
Exposes the block’s parameter list so KeywordFilter can filter kwargs to match the block’s declared keywords.
137 138 139 |
# File 'lib/braintrust/scorer.rb', line 137 def call_parameters @block.parameters end |